Batrium BMS Monitoring

non-EV Solar, Wind and other renewable power sources
non-EV batteries and other energy storage stuff
Forum rules
Important!
This forum is for discussion of Non-EV matters.
Post Reply
bigjsl
Noobie
Posts: 13
Joined: Wed, 07 Oct 2009, 03:08
Real Name: John Lindsay
Location: Adelaide
Contact:

Batrium BMS Monitoring

Post by bigjsl » Tue, 23 Oct 2018, 21:25

Hope this is the right place to post this.

I wrote a bit of python3 to monitor my Batrium BMS.

You can modify it using info here: https://github.com/Batrium/WatchMonUdpL ... 20v1.0.pdf

I plan to incorporate it into my pvoutput upload script.
# Batrium UDP monitor in Python3
# John Lindsay

import select, socket
import struct

port = 18542  # where do you expect to get a msg?
bufferSize = 1024 # whatever you need

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('',port))
s.setblocking(0)

byterecord = struct.Struct('B')
intrecord = struct.Struct('H')
floatrecord = struct.Struct('f')
global got_soc
got_soc = False
global got_volts
got_volts = False

completed = False

while not(completed):
    result = select.select([s],[],[])
    msg = result[0][0].recv(bufferSize)
    if msg[:3] == b'\x3a\x33\x3f':
      battery_soc=((float(byterecord.unpack(msg[32:33])[0])/2)-5) # byte -5% to 105% 0.5% per bit => /2 - 5
      got_soc = True
    if msg[:3] == b'\x3a\x32\x3e':
      battery_min = intrecord.unpack(msg[8:10])[0]/1000.0  #Uint16 x 1000
      battery_max = intrecord.unpack(msg[10:12])[0]/1000.0  #Uint16 x 1000
      battery_bypass_count = (byterecord.unpack(msg[33:34])[0])
      battery_volts = intrecord.unpack(msg[40:42])[0]/100.0  #Uint16 x 100
      battery_amps = floatrecord.unpack(msg[42:46])[0]/1000.0 #float4 x 1000
      got_volts = True
    completed = (got_volts and got_soc)

print ("soc%:",battery_soc)
print ("min:", battery_min)
print ("max:", battery_max)
print ("bypass:", battery_bypass_count)
print ("volts:",(battery_volts))
print ("amps:",(battery_amps))

bigjsl
Noobie
Posts: 13
Joined: Wed, 07 Oct 2009, 03:08
Real Name: John Lindsay
Location: Adelaide
Contact:

Re: AVASS Battery order details

Post by bigjsl » Tue, 23 Oct 2018, 21:26

It produces output like this:
soc%: 79.0
min: 3.28
max: 3.32
bypass: 0
volts: 52.67
amps: -12.2866875

rhills
Site Admin
Posts: 333
Joined: Fri, 25 Jul 2008, 01:57
Real Name: Rob Hills
Location: Waikiki, WA

Re: Batrium BMS Monitoring

Post by rhills » Tue, 23 Oct 2018, 22:18

Hi John,

The topic you originally posted this in (AVASS Battery Order Details wasn't really the right place for it. That wasn't your fault as it had been starting to wander off the original subject anyway so I have now locked it.

I think your posts deserved their own topic, so I created one for them.

Cheers,
Rob Hills
AEVA Webmaster
2014 Mitsubishi Outlander Aspire PHEV
Jul 2014 - Jun 2018
Total Petrol: 586.8L
ODO: 42885
Av Consumption: 1.37 L/100km

User avatar
jonescg
Senior Member
Posts: 2366
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Re: Batrium BMS Monitoring

Post by jonescg » Wed, 24 Oct 2018, 08:48

Also, if you want to post code you can do it using this feature:

Code: Select all

Code code code {stuff}
More code more code more code
colon slash break curly braces etc.
Using the [c0de] blah [/code ] (with an 'o' instead of a zero, obviously)
AEVA National Secretary, WA branch vice-chair

Post Reply