This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connect Victron Battery monitor to Openplotter SignalK?
#2
(2017-03-22, 11:00 AM)kste Wrote: I ask for help on how data can be read in the Victron battery monitor and send them to SignaK Openplotter of using this software?
http://www.jeperez.com/online-monitor-vi...-bmv-602s/

You are on the right way. I tried to emulate the bmv-600 (with a fixed string) and used this code for sending it to SignalK. (I didn't test it with a real bmv-600 so there will be many errors. Perhaps you can combine this code with the one you found.)
Code:
#!/usr/bin/python
#victron BMV600S

import signal, sys, time, socket, datetime, subprocess, math, serial, re

# Control-C signal handler to suppress exceptions if user presses Control C
# This is totally optional.
def signal_handler(sig, frame):
   print('You pressed Ctrl+C!!!!')
   sys.exit(0)
   
# init
signal.signal(signal.SIGINT, signal_handler)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
ser = serial.Serial('/dev/ttyOP_LEONARDO', 19200, timeout=2)
ser.flush()

ValueH1 = 0
ValueH2 = 0
ValueH3 = 0
ValueH4 = 0
ValueH5 = 0
ValueH6 = 0
ValueH7 = 0
ValueH8 = 0
ValueH9 = 0
ValueH10 = 0
ValueH11 = 0
ValueH12 = 0
ValueV = 0
ValueI = 0
ValueCE = 0
ValueSOC = 0
ValueTTG = 0
ValueALARM = 0
ValueRELAY = 0
ValueAR = 0

error = False
i = 0

def safefloat(value,line):
   if re.match('^-?[0-9]+$', line):
       value = float(line)
   return value

# forever loop until user presses Control-C
while 1:
   i += 1
   serLine = ser.readline().split()
   #print serLine,len(serLine)
   
   if len(serLine) == 2:
   
       if 'H1' == serLine[0]:
           ValueH1 = safefloat(ValueH1,serLine[1])/100
           print 'H1 dpst DOD ',ValueH1
       elif 'H2' == serLine[0]:
           ValueH2 = safefloat(ValueH2,serLine[1])/100
           print 'H2 lst DOD ',ValueH2
       elif 'H3' == serLine[0]:
           ValueH3 = safefloat(ValueH3,serLine[1])/100
           print 'H3 avg DOD ',ValueH3
       elif 'H4' == serLine[0]:
           ValueH4 = safefloat(ValueH4,serLine[1])/100
           print 'H4 cycles ',ValueH4
       elif 'H5' == serLine[0]:
           ValueH5 = safefloat(ValueH5,serLine[1])/100
           print 'H5 FD ',ValueH5
       elif 'H6' == serLine[0]:
           ValueH6 = safefloat(ValueH6,serLine[1])/100
           print 'H6 Tot.AH ',ValueH6
       elif 'H7' == serLine[0]:
           ValueH7 = safefloat(ValueH7,serLine[1])/100
           print 'H7 Min V ',ValueH7
       elif 'H8' == serLine[0]:
           ValueH8 = safefloat(ValueH8,serLine[1])/100
           print 'H8 Max V ',ValueH8
       elif 'H9' == serLine[0]:
           ValueH9 = safefloat(ValueH9,serLine[1])/100
           print 'H9 day aft. full ',ValueH9
       elif 'H10' == serLine[0]:
           ValueH10 = safefloat(ValueH10,serLine[1])/100
           print 'H10 Sync ',ValueH10
       elif 'H11' == serLine[0]:
           ValueH11 = safefloat(ValueH11,serLine[1])/100
           print 'H11 Low V al ',ValueH11
       elif 'H12' == serLine[0]:
           ValueH12 = safefloat(ValueH12,serLine[1])/100
           print 'H12 High V al. ',ValueH12

       elif 'V' == serLine[0]:
           ValueV = safefloat(ValueV,serLine[1])/1000
           print 'V ',ValueV
       elif 'I' == serLine[0]:
           ValueI = safefloat(ValueI,serLine[1])/1000
           print 'I ',ValueI
       elif 'I' == serLine[0]:
           if ('---' in serLine) == False:
               ValueCE = safefloat(ValueCE,serLine[1])/1000
               print 'CE ',ValueCE
       elif 'SOC' == serLine[0]:
           if ('---' in serLine) == False:
               ValueSOC = safefloat(ValueSOC,serLine[1])/10
               print 'SOC ',ValueSOC
       elif 'TTG' == serLine[0]:
           if ('---' in serLine) == False:
               ValueTTG = safefloat(ValueTTG,serLine[1])/10
               print 'TTG ',ValueTTG
       elif 'ALARM' == serLine[0]:
           if 'OFF' in serLine:
               ValueALARM = '0'
           else:
               ValueALARM = '1'

   if i >= 24:
       print 'send'
       SignalK = '{"updates": [{"source": {"type": "BAT","src" : "BMV601"},"values":['
       SignalK += '{"path": "electrical.batteries.main.voltage","value":'+str(round(ValueV, 2))+'}'
       SignalK += ',{"path": "electrical.batteries.main.current","value":'+str(round(ValueI, 2))+'}'
       SignalK += ',{"path": "electrical.batteries.main.capacity.stateOfCharge","value":'+str(ValueSOC)+'}'
       SignalK += ',{"path": "electrical.batteries.main.capacity.timeRemaining","value":'+str(round(ValueTTG, 1))+'}'
       SignalK += ']}]}\n'
       sock.sendto(SignalK, ('localhost', 55559))
       i = 0
       time.sleep(.500)
Reply


Messages In This Thread
RE: Connect Victron Battery monitor to Openplotter SignalK? - by e-sailing - 2017-03-22, 07:57 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)