VeDirectFrameHandler icon indicating copy to clipboard operation
VeDirectFrameHandler copied to clipboard

hex protocol implementation

Open giacinti opened this issue 4 years ago • 3 comments

Hello,

Many thanks for your original work and repository. I have created this PR for adding support for the VE.Direct HEX protocol as described in this document: https://www.victronenergy.fr/download-document/4459/bluesolar-hex-protocol-mppt.pdf

Some notes:

  • I'm using (successfully) this implementation in my MPPT monitoring with esphome and homeassistant (see my code here: https://github.com/giacinti/vedirect)
  • the consumer has to record one or many callback functions which will then be called when the hex message has been validated (checksum valid) - it is necessary to process the data right away as the buffer could potentially be changed by an async message. I updated the example file accordingly - please check it out
  • when a hex message is detected, the current machine state is saved and restored after processing. This way we can manage sync and async messages and avoid text checksum errors & text frame miss
  • I also added a way to externally record an helper function for debugging (making easier to integrate with other debug system, like for esphome.io)

I hope it will be helpful

Best regards, Philippe

giacinti avatar Feb 06 '21 16:02 giacinti

Interesting. I missed that there could be async messages interfering with text. However, the latest spec says this: Firmware Asynchronous messages 1.53 Text messages not suppressed/delayed anymore due to hex requests. Now the text messages will always be sent every 2 seconds. Furthermore, a response to a hex message will always wait until the text message finishes to be sent (will not be interrupted in the middle of it as it was before).

Have you seen async messages still interrupt?

cterwilliger avatar Sep 08 '22 21:09 cterwilliger

my bad, crappy internet...

cterwilliger avatar Sep 08 '22 21:09 cterwilliger

I have noticed this effect on my MPPT which firmware has not been updated since a while (v139). This is a very basic version and I don't have the tools for updating. I guess there are plenty of devices with old firmware still in the wild which may experience the same side effect. Having it handled in the code could help. Eventually implementing hex protocol was super helpful for me for modifying system parameters - for instance my MPPT was wrongly installed and automatically configured itself for 24v instead of 12v (it's in a RV). With hex protocol I could re-configure it just by sending an mqtt message :-)

giacinti avatar Sep 09 '22 03:09 giacinti