Monday 13 June 2022

Victron VE.Direct to SignalK

Hi everyone,

Another technical post today, following on from our recent Lifeline/Victron Lithium Power Upgrade post.  Our plan was to feed selected data from the Victron gear into our SignalK system.  We've started with the 712smart battery monitor which provides the most useful summary data.  The overall goal was to integrate live battery state with other boat data on our Macs, iPads and iPhones, record the data in our SignalK system and graph historic data.

WilhelmSK app with battery data in blue oval

All of the Victron gear we purchased for the Lithium upgrade is 'smart', meaning each provides a Bluetooth connection for setup and monitoring.  This is great but historical data is limited.  In contrast our SignalK system accepts live data and stores it in a database which we can interrogate and graph at any time.  Apart from occasional maintenance outages every second of all our NMEA 2000 data is already stored in the database and can be graphed.  The record goes back to September 2020.  We're now recording the 712smart's data in the same database.

In addition to Bluetooth each of our Victron gear has a VE.Direct port.  Victron provides useful information on this interface here.  Here's one helpful picture from the VE.Direct Protocol document...

VE.Direct Socket Pinout

The VE.Direct physical plug is a JST PH 2mm 4-pin.  The electrical interface is 3.3V RS232 serial with pins 1 o 4 being ground (black), TxD (green), TxD (white) and power (red).  The interface runs at 19200 baud.  Victron sells VE.Direct to VE.Direct cables of various lengths and also a VE.Direct to USB Interface cable.  Very importantly the latter is isolated so differential ground voltages don't matter.  Local grounds at each charger and at the house distribution panel could differ due to the large currents the chargers inject.  We sourced Victron cables at Island Water World and Turbulence here in Grenada.

JST PH 2mm 4-pin plug (not VE.Direct wiring pinout!)

Our 712smart is mounted on the rear face of the pedestal in the saloon.  The cable run from there to the BeagleBone Black SignalK computer in the navstation is about 8m.  The VE.Direct to USB Interface cable is only about 1.5m so we used a 10m VE.Direct to VE.Direct cable for most of the run.  With no known local source of JST sockets we instead decided to cut the two cables and solder the wires.  Should be simple.

After cutting the VE.Direct to VE.Direct cable then exposing and stripping the four wires I plugged the other end into the 712smart.  The wires were black, green, white and red as expected.  I measured the voltage from red to black and got -3.3V.  Not what I expected.  I then disconnected from the 712smart and buzzed out the cable.  Pins 1 to 4 were connected to the cable wires in reverse order!  Not impressed!  Only TxD (white) and RxD (green) should be reversed.

With the wire reversal understood I could then reconnect to the 712smart and look for output data on the white and green wires.  It was on the green (measured with respect to the red!).  I then knew which wires to connect to the 'matching' exposed and stripped wires on the VE.Direct to USB Interface cable.  I only needed ground and the TxD wires from the 712smart.  It's really not nice soldering red to black, but that's what was required.  And green went to green, when normally you'd go white to green.

Before heat shrinking the connections and the cable overall I connected the 712smart and plugged the USB plug into our Macbook.  Displaying serial data on MacOS is tricky since it really likes 9600 baud.  The following command worked for me...

stty -f /dev/ttyUSB0 19200 | cat /dev/ttyUSB0

Sadly I failed to take a screenshot of the data.  There is a burst of text lines each second.  Each line contains a paramater name and value.  

With the cable assembly now tidied up and known good I connected the USB plug into the SignalK computer.  I then listed /dev and found a new ttyUSB device.  With the SignalK Server running I could also check the identity of serial devices by listing /dev/by-id.

SignalK Server's helpful Serial Port aliases

Earlier I had installed the SignalK Server vedirect-signalk plugin.  With it installed and data available the next step was plugin configuration.  Here's ours..


SignalK Server vedirect-signalk plugin configuration

With the configuration saved I checked connection activity on the SignalK Server's home page.  Data was flowing...

vedirect-signalk interface up and running

And on the Data Monitor page I could see the data...

vedirect-signalk data set

So we now had 712smart VE.Direct data flowing into the SignalK Server and onward into the InfluxDB database.  The final steps were to create a new Grafana page to display the data, and to modify other Grafana pages and the WilhelmSK app's pages to show key new data.  I'm not going to try to describe how to make Grafana pages - consult youtube!

The new Grafana "Electrical" page below shows our house battery bank state on the dials in the middle, and historical graphs of each parameter for a selectable time period.  The engine battery voltage is also shown on the voltage graph.  Here we're showing about 30 hours of data...

Grafana graph page of Victron data

The graphs above start with the battery bank 50Ah below full.  We had just turned on the mains charger which was injecting 30A in Bulk charge mode.  The solar charger was adding a little.  Voltage gradually increased then sharply increased - a characteristic of LiFePo4 batteries.  The chargers then backed off the current in Absorb then Float modes.  For the rest of the day the mains and solar chargers kept the battery full.

In the evening the mains charger was turned off and overnight the battery gradually lost charge, mainly running the fridge.  This consumed about 25Ah.  The following morning the solar charger filled the battery bank by midday, under a very cloudy and rainy sky.

Our solar panels are two parallel SunForce 130W panels.  They guarantee 80% power after 20 years and ours are 10 years old, so should yield 234W.  A few days ago when the batteries were fairly low and we had sunlight I measured 220W which I'm happy with.

Here are our new batteries' charge and discharge curves from the Lifeline manual...

Charge Curve (note voltage step)

Discharge Curves

It's great to be recording battery data only a few days after installation.  We're already learning more about our power consumption as well as the new batteries and chargers.

Trust all's well where you are!


No comments:

Post a Comment