fatbeard / vbus-arduino-library Goto Github PK
View Code? Open in Web Editor NEWVBUS Decoder Library for Arduino
VBUS Decoder Library for Arduino
I have created this code to link this arduino library to an esp8266 device with tasmota firmware, with the driver
https://tasmota.github.io/docs/TasmotaClient/
It is very useful to send an MQTT message via Wi-Fi to link with Domoticz, Node Red, etc ...
I am not a programmer but the code works.
#include <avr/wdt.h>
#include <VBUSDecoder.h>
VBUSDecoder vb;
#include <Arduino.h>
#include <TasmotaSlave.h>
#if !(defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__))
//The #if condition is evaluated only at compile time. The "if" is evaluated at run time.
TasmotaSlave slave(&Serial);//Serial for Arduino UNO
#else
TasmotaSlave slave(&Serial3);//Serial3 para Arduino Mega
#endif
long lastTimevbus = 0;
long intervalvbus = 60000;
#define DEBUG 0
void setup() {
#if DEBUG
Serial.begin(9600);
Serial.println("Arduino debugging started");
#endif
#if !(defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__))
Serial.begin(115200); // Configure the Serial port for the correct baud rate. Serial for Arduino UNO
#else
Serial3.begin(115200); // Configure the Serial port for the correct baud rate. Serial3 for Arduino Mega
#endif
vb.initialise();
wdt_disable();
wdt_enable(WDTO_8S);
}
void loop() {
slave.loop(); // Call the slave loop function every so often to process incoming requests
vb.readSensor(); // Read the data from Vbus-UART in Serial1
wdt_reset();
if (millis() - lastTimevbus > intervalvbus) {
lastTimevbus = millis();
int S1Temp = vb.getS1Temp();
int S2Temp = vb.getS2Temp();
int S3Temp = vb.getS3Temp();
int S4Temp = vb.getS4Temp();
int P1Speed = vb.getP1Speed();
char SystemTime[5]; // The buffer to copy the characters into
vb.getSystemTime().toCharArray(SystemTime, 6); // To convert this string to a character array such that sprintf is expecting
int P1 = vb.getP1OperatingHours();
int P2 = vb.getP2OperatingHours();
uint32_t HeatQuantity = vb.getHeatQuantity();
float presion = 0.0689476 * 43.50 * (5.15 * analogRead(A0) / 1023.0 - 0.5); // el 0.15 se lo sumo al voltje de 5V como error de lectura del transductor en low
char* buffpresion = "";
dtostrf(presion, 4, 2, buffpresion);
char buffer[70];//sprintf works only on char array's
sprintf(buffer, "{%02d,%02d,%02d,%02d,%s,%02d,%02d,%lu,%s,%02d}", S1Temp, S2Temp, S3Temp, S4Temp, SystemTime, P1, P2, HeatQuantity, buffpresion, P1Speed); // Format data into character array
slave.SendTele(buffer); // SendTele(char *data) publish character array via MQTT to Tasmota
#if DEBUG
Serial.println("");
Serial.println("*** Fresh Read ***");
Serial.print("Collector Temp: ");
Serial.println(vb.getS1Temp());
Serial.print("Top Tank Temp: ");
Serial.println(vb.getS3Temp());
Serial.print("Bottom Tank Temp: ");
Serial.println(vb.getS2Temp());
Serial.print("Flow in Temp: ");
Serial.println(vb.getS4Temp());
Serial.print("Water Pump Status: ");
Serial.println(vb.getP1Status());
Serial.print("Water Pump Speed: ");
Serial.println(vb.getP1Speed());
Serial.print("Pump Hours Operation: ");
Serial.println(vb.getP1OperatingHours());
Serial.print("Backup Heater Hours Operation: ");
Serial.println(vb.getP2OperatingHours());
Serial.print("System Alert Status: ");
Serial.println(vb.getAlertStatus());
Serial.print("Scheme: ");
Serial.println(vb.getScheme());
Serial.print("System Time: ");
Serial.println(vb.getSystemTime());
Serial.print("HeatQuantity: ");
Serial.println(vb.getHeatQuantity());
Serial.println("*** End Read ***");
#endif
}
}
Hi @FatBeard, this project looks super interesting and I'm looking to give it a try.
Would you happen to have a BOM for the components in the PCB you linked?
Thanks!
Hello @FatBeard
I have finally managed to connect to my Resol solar controller's VBUS using this Sketch (thank you!) with components on a breadboard - so I'd like to move on to packaging it up nicely on a PCB.
I found your PCB on PCBs.io via the mentioned link, and ordered it from them - but it's not moving in the fabrication process after 16 days, and they're not replying to my emails/tweets at all!
Could you please share your Vbus PCB's board file (e.g. Eagle BRD file?) so I can get it printed somewhere else?
This is the code for the Deltasol CS Plus in case it is useful for someone
else if (Source_address == 0x2211)
{
// Frame info for the Resol DeltaSol CS Plus (Joule)
// check VBusprotocol specification for other products
// This library is made for the Resol DeltaSol CS Plus (0x2211)
//Offset Mask Name Factor Unit
//0 Temperature S1 1.0 °C
//1 Temperature S1 256.0 °C
//2 Temperature S2 1.0 °C
//3 Temperature S2 256.0 °C
//4 Temperature S3 1.0 °C
//5 Temperature S3 256.0 °C
//6 Temperature S4 1.0 °C
//7 Temperature S4 256.0 °C
//8 Pump Speed R1 1 %
//10 Operating Hours R1 1 h
//11 Operating Hours R1 256 h
//12 Pump Speed R2 1 %
//14 Operating Hours R2 1 h
//15 Operating Hours R2 256 h
//16 UnitType 1
//17 System 1
//20 1 Sensor 1 defekt 1
//20 2 Sensor 2 defekt 1
//20 4 Sensor 3 defekt 1
//20 8 Sensor 4 defekt 1
//20 Error Mask 1
//20 Error Mask 256
//22 Time 1
//23 Time 256
//24 Statusmask 1
//25 Statusmask 256
//26 Statusmask 65536
//27 Statusmask 16777216
//28 Heat Quantity 1 Wh
//29 Heat Quantity 256 Wh
//30 Heat Quantity 65536 Wh
//31 Heat Quantity 16777216 Wh
//32 SW-Version 0.01
//33 SW-Version 2.56
//
// Each frame has 6 bytes, FLength
// byte 1 to 4 are data bytes -> MSB of each bytes
// byte 5 is a septet and contains MSB of bytes 1 to 4, FSeptet
// byte 6 is a checksum
// FOffset 10, Offset start of Frames
//******************* Frame 1 *******************
#if DEBUG
Serial.println("---------------");
Serial.println("Now decoding for DeltaSol CS Plus 0x2211");
Serial.println("---------------");
#endif
//******************* Frame 1 *******************
F = FOffset;
Septet = Buffer[F + FSeptet];
InjectSeptet(Buffer, F, 4);
sensor1Temp = calcTemp(Buffer[F + 1], Buffer[F]);
sensor2Temp = calcTemp(Buffer[F + 3], Buffer[F + 2]);
//******************* Frame 2 *******************
F = FOffset + FLength;
Septet = Buffer[F + FSeptet];
InjectSeptet(Buffer, F, 4);
sensor3Temp = calcTemp(Buffer[F + 1], Buffer[F]);
sensor4Temp = calcTemp(Buffer[F + 3], Buffer[F + 2]);
//******************* Frame 3 *******************
F = FOffset + FLength * 2;
Septet = Buffer[F + FSeptet];
InjectSeptet(Buffer, F, 4);
Relay1 = (Buffer[F]);
OperatingHoursRelay1 = Buffer[F + 2] + Buffer[F + 3]*256; //Numero de horas rele 1
ErrorMask = Buffer[F + 2];
Scheme = Buffer[F + 3];
//******************* Frame 4 *******************
F = FOffset + FLength * 3;
Septet = Buffer[F + FSeptet];
InjectSeptet(Buffer, F, 4);
Relay2 = (Buffer[F]);
OperatingHoursRelay2 = Buffer[F + 2] + Buffer[F + 3]*256;
//******************* Frame 5 *******************
F = FOffset + FLength * 4;
Septet = Buffer[F + FSeptet];
InjectSeptet(Buffer, F, 4);
//******************* Frame 6 *******************
F = FOffset + FLength * 5;
Septet = Buffer[F + FSeptet];
InjectSeptet(Buffer, F, 4);
SystemTime = Buffer[F + 3] << 8 | Buffer[F + 2];
//******************* Frame 7 *******************
F = FOffset + FLength * 6;
Septet = Buffer[F + FSeptet];
InjectSeptet(Buffer, F, 4);
//******************* Frame 8 *******************
F = FOffset + FLength * 7;
Septet = Buffer[F + FSeptet];
InjectSeptet(Buffer, F, 4);
HeatQuantity = Buffer[F] + Buffer[F + 1]*256 + Buffer[F + 2]*65536 + Buffer[F + 3]*16777216;
uint32_t HeatQuantity1 = Buffer[F + 1]*256 ;
uint32_t HeatQuantity2 = Buffer[F + 2]*65536 + Buffer[F + 3]*16777216;
//HeatQuantity = HeatQuantity1;
///******************* End of frames ****************
} // end 0x2211 DeltaSol CS Plus
Hello FatBeard,
I am now trying for days to get it working on my system without any succes.
For the VBUS to RS485 im awaiting a few components but i want to have it connected to my nodeMCU and send the data through esp to home assistant.
Any other way is also fine I don´t mind but whatever I try I seem to not understand it all.
Can you help me out? I just want to have the values in my Home asisstant but my knowledge is lacking.
Hello,
in function vBusRead()
the following code:
if (Bufferlength < 20)
{
lastTimeTimer = millis();
Bufferlength = 0;
}
else // <----- missing {
stop = true;
}
Please correct cpp file.
Hello,
I have added further CRC tests, now testing all the frames and a little bit of code cleanup.
Before making a PR I think it would be wise if someone else could do some testing.
The fork is at https://github.com/alfredosola/vbus-arduino-library
Thanks.
Is there a way to make this work on a esp32? I am not been able to do it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.