This library is used to work with an ESP32 Arduino (not for the AVR family as the library uses std::vector).
- [Arduino IDE 2.3.2]
- [Visual Studio 2022 and visual micro]
arduino-esp32 boardlibrary >= 2.0.8 for < 2.0.8 undefine UART_MODE_RS485 in the vebus.h file
//#define UART_MODE_RS485
#ifdef UART_MODE_RS485
#include "hal/uart_types.h"
#endif
This is a sample guide for setting up your project locally.
- ESP32 Board
- RS485 IC
The RS485 IC can be a MAX485 or max1348
Tip
For a simple start (PlugAndPlay) you can use an esp32 arduino board with integrated RS485 LILYGO T-CAN485
There are a few examples to get you started with the library
-
ReadWriteSettings This example is a minimized program for reading out some settings on a Multiplus-II 12/3000
-
VebusSniffer This example can be used to listen to all traffic on the VE.BUS.
-
ReadAllVariableInfos This example can be used to read all variable information. This is necessary to interpret the value sent by the VE.BUS device. If you have a device, it is not in the library. Send me the serial output to integrate the new device.
- Callback for received messages
- Callback for response messages
- Write a value to Multiplus
- Read a value to Multiplus
void SetReceiveCallback(std::function<void(std::vector<uint8_t>& buffer)> cb);
To parse all received messages, the callback can be used as follows
*.ino
void Receive(std::vector<uint8_t>& buffer)
{
_vEBus.DestuffingFAtoFF(buffer);
Serial.printf("Res: ");
for (uint32_t j = 0; j < buffer.size(); j++) Serial.printf("%02X ", buffer[j]);
Serial.println();
}
void setup()
{
_vEBus.SetReceiveCallback(Receive);
}
Tip
If you don't want to see some messages, you can skip them using a blacklist or use the whitelist to see specific messages.
VEBus::Blacklist _blacklist[] = { {.value = 0xE4, .at = 4}, {.value = 0x55, .at = 4} };
void setup()
{
_vEBus.SetReceiveCallback(Receive, _blacklist, sizeofarray(_blacklist));
}
void SetResponseCallback(std::function<void(ResponseData&)> cb);
To parse all response messages, the callback can be used as follows. data.id is specified by the query to indicate that it is the response of the read operation.
*.ino
void Response(VEBus::ResponseData& data)
{
if(requestId == data.id){}
if(WinmonCommand == data.command && Settings == data.address){}
//...to some stuff
}
void setup()
{
_vEBus.SetResponseCallback(Response);
}
uint8_t WriteViaID(RamVariables variable, int16_t rawValue, bool eeprom = false);
uint8_t WriteViaID(RamVariables variable, uint16_t rawValue, bool eeprom = false);
RequestResult WriteViaID(RamVariables variable, float value, bool eeprom = false);
uint8_t WriteViaID(Settings setting, int16_t rawValue, bool eeprom = false);
uint8_t WriteViaID(Settings setting, uint16_t rawValue, bool eeprom = false);
RequestResult WriteViaID(Settings setting, float value, bool eeprom = false);
To write a value, you have three ways to send it. You can store a value to a non-volatile memory. To do this you need to set the eeprom true
Caution
Be careful when repeatedly writing EEPROM (loop) EEPROM writes are limited
- library supported device with value interpretations
*.ino
void loop()
{
if(dataToWrite == true)
{
_vEBus.WriteViaID(Settings::IMainsLimit, 7.2); //set 7.2A
}
}
- no library supported device with value interpretations
*.ino
void setup()
{
_vEBus.ReadInfo(Settings::IMainsLimit);
}
void loop()
{
if(dataToWrite == true)
{
_vEBus.WriteViaID(Settings::IMainsLimit, 7.2); //set 7.2A
}
}
- raw without value interpretations
*.ino
void loop()
{
if(dataToWrite == true)
{
_vEBus.WriteViaID(Settings::IMainsLimit, 72); //set 7.2A
}
}
uint8_t Read(RamVariables variable);
uint8_t Read(Settings setting);
To read a value
*.ino
void loop()
{
if(dataToRead == true)
{
uint8_t requestId = _vEBus.Read(Settings::IMainsLimit);
}
}
- Multiplus-II 12/3000
- add more integrated devices
- VENUS::Write() is currently not working. (Use VENUS::WriteViaID() instead)
- extract more GX commands
This project is licensed under the GNU General Public License v3.0 or later - see the LICENSE.md file for details
- [Hadmut] (https://www.mikrocontroller.net/topic/561834)
- [pv-baxi] (https://github.com/pv-baxi/esp32ess)