Git Product home page Git Product logo

vedirectframehandler's Introduction

VeDirectFrameHandler

Arduino library to read from Victron devices using VE.Direct protocol.

This library is based on a publically released reference implementation by Victron. Victron only released the framehandler.cpp portion, so some assumptions were made to adapt it to use for Arduino. The VE.Direct Protocol FAQ is located here: https://www.victronenergy.com/live/vedirect_protocol:faq

The library was tested using a NodeMCU-1.0. Doing this requires using SoftwareSerial to connect to the VE device in order to use the hardware UART for debug purposes. If your platform has 2 hardware UARTs, use them, not SoftwareSerial.

The application passes serial bytes to the library. The library parses those bytes, verifies the frame, and makes a public buffer available to the application to read as a name/value pair.

vedirectframehandler's People

Contributors

cterwilliger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vedirectframehandler's Issues

temp buffer overflow possible

Hi,

I am using your lib and want to point out a potential issue.

We had an issue with reading VE-Direct frames from the (software) serial buffer.
This caused strange behavior like existing label names in the public buffer being overwritten (and most possibly also crashes)

I tracked it down to frameIndex becoming larger then FRAME_LEN causing the tempBuffer to overflow (in the rare case where multiple partial frames without a checksum label were somehow stored in the serial buffer after each other. Possibly because I was not reading a circular buffer fast enough).

Maybe it is rare but this can easily be caught by only increasing frameIndex when frameIndex < FRAME_LEN:

void VeDirectFrameHandler::textRxEvent(char* name, char* value) {
  if (frameIndex < FRAME_LEN) {
    strcpy(tempName[frameIndex], name);   // copy name to temporary buffer
    strcpy(tempValue[frameIndex], value); // copy value to temporary buffer
    frameIndex++;
  } else {
    log_w("temp buffer overrun!");
  }
}

Regards,
Jeroen

Can you add a licence?

I'd like to use this library in my project, however I see that there's no licence specified. I figured I'd ask to see if it's open-source and under what licence.

Checksum calculation wrong on Victron 150/70 and other

it looks like victron change something in the communication, so the new devices send at the end and itemdaly after the checksum byte a Async Hex (i think broadcast)

it looks:

PID     0xA071
V       22000
I       0
VPV     0
PPV     0
MPPT    0
CS      0
OR      0x00000001
ERR     0
LOAD    OFF
H19     1077
H20     0
H21     4
H22     117
H23     921
HSDS    16
Checksum        โ–’:A2001002200000008
                                   :ADBED00750806
                                                 :AD5ED009708EA
                                                               :A8DED00970832

so the code doesnt regonize the right end after the checksum byte.

any idea how to fix that?

Requires framehandler.h

This code looks to be just what I am looking for but on compiling it fails asking from framehandler.h file which I have researched and cannot find anywhere.

null values

probably not a issue for this library, but thought I would ask.

Im using on a Wemos d1 mini (along with 9 more), and only plugging into a BVM712. im Trying to read and send to MQTT server, which it does, and its great for a few seconds, then nearly all values start coming in as null.

object PID: "0XA381" V: null I: null P: null CE: null SOC: null TTG: "-1" ALARM: "OFF"

im not really doing anything crazy to the data, so Im just wondering if the timing is off? possbily with loop?

void ReadVEData() {
    while ( Victron.available() ) {             
        myve.rxData(Victron.read());
    }
    yield();
}

void EverySecond() {
    static unsigned long prev_millis;
    if (millis() - prev_millis > 1000) {      
        SendData();
        prev_millis = millis();
    }
}

void SendData(){
  String jsonstring;
   for ( int i = 0; i < myve.veEnd; i++ ) {
      json[myve.veName[i]] = myve.veValue[i];
   }
   serializeJson(json, jsonstring);
   client.publish( "zorro/solar/bvm", jsonstring);
   Serial.println(jsonstring);
}
`

on 8266 value does not update.

Not sure why but after a while the myve.veValue value does not change, Using an 8266 and software serial..

any ideas?

Ceases to read after a while, hangs

Anyone else experienced this? I was able to get it to run fine on a Particle Photon using both hardware serial and software serial, the latter as I needed the one free hw serial to do something else a little more intensive.

Seems like after somewhere between a minute and 5 minutes it'll just cease to read and my output to the arduino IDE serial monitor quits entirely.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.