Batrium BMS Monitoring

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

Batrium BMS Monitoring

Post by bigjsl »

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: ... 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)

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 =[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))
Posts: 18
Joined: Wed, 07 Oct 2009, 03:08
Real Name: John Lindsay
Location: Adelaide

Re: AVASS Battery order details

Post by bigjsl »

It produces output like this:
soc%: 79.0
min: 3.28
max: 3.32
bypass: 0
volts: 52.67
amps: -12.2866875
Site Admin
Posts: 480
Joined: Fri, 25 Jul 2008, 01:57
Real Name: Rob Hills
Location: Waikiki, WA

Re: Batrium BMS Monitoring

Post by rhills »

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.

Rob Hills
AEVA Webmaster
2014 Mitsubishi Outlander Aspire PHEV
Petrol Usage to last refill: Jul 2014 - Oct 2020
Total Petrol: 756.3L
ODO: 67508
Av Consumption: 1.12 L/100km
User avatar
Senior Member
Posts: 3616
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Re: Batrium BMS Monitoring

Post by jonescg »

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 chair.
Post Reply