diy solar

diy solar

For those of you looking to monitor your ANT-BMS with Pi3 via Bluetooth.

The python script works great but i want to use a ESP board to collect the bms stats, no one has done this?
Dear @Lucasss, welcome to the forum,

This other thread is of someone with different BMS (JBD BMS, not Ant BMS) who made ESP board to collect BMS stats

Might have information to assist with ESP ANT-BMS stats collection. Sorry if it feels not relevant

 
Anyone knows the reason for this inversion made in the code ? I can modify the code, but I want to know why @chadhouser made that inversion.
It is long time ago since I coded that but if I remember properly the value was encoded in 1’s complement, thus the inversion. I am no specialist so maybe there is a “better” way to get the proper value. This worked for me.
 
Hi all, Chad used parts of the code I wrote and posted in GitHub. https://github.com/juamiso/ANT_BMS

I have the ANT BMS running since July 2019 in combination with a Raspi 3B+ connected via Bluetooth. It is pretty robust I must say! Via the python control script the Raspi sends the data I want to log directly to an influxdb server (local network but running in another computer). And this other computer runs grafana and I can monitor from anywhere very useful stuff. See:

View attachment 28371
View attachment 28372
View attachment 28373
I would very much appreciate some help duplicating your lovely graphs. I'm not running an AntBMS. I'm monitoring 3 Overkill solar 8s BMS's and my graphs aren't pretty like yours. Currently only using one of the 8s packs. Also using a thornwave Powermon-5s. Besides the point. Can you link to some good tuts on grafana?

Not looking to hi-jack the thread.

1631671834610.png
 
there is enough github documentation for ant bms, but some projects have not been carried out however here I put the most relevant ones and hopefully they will help to implement everything on an esp module @sibianul

this is for victron but there is a lot of information about the protocol


 
Last edited:
Eh unfortunately I do not know in the least where to start, however I found a lot of stuff concerning both my inverter mpp and ant bms and I saw in the Arduino forum that you too have an mpp solar inverter? @sibianul
 
Hello everybody!
Reworked sending to Influxdb via crontab and telegraph agent (instead of node-red)
you need to install the telegraph package replase config /etc/telegraf/telegraf.conf and add the script launch to crontab (crontab -e), I attach a dashboard for grafana
 

Attachments

  • root.txt
    1.5 KB · Views: 37
  • telegraf.conf.txt
    471 bytes · Views: 23
  • ANT_BMS-1632237541892.json.txt
    83.2 KB · Views: 38
  • ant_bms.png
    ant_bms.png
    14 KB · Views: 28
  • grafana_ant_bms.png
    grafana_ant_bms.png
    215.9 KB · Views: 28
  • getbms.py.txt
    5.8 KB · Views: 55
  • ant_bms2.png
    ant_bms2.png
    172.3 KB · Views: 26
Last edited:
Eh unfortunately I do not know in the least where to start, however I found a lot of stuff concerning both my inverter mpp and ant bms and I saw in the Arduino forum that you too have an mpp solar inverter? @sibianul

Yes, I do have an MPP Solar 8048MAX inverter and ANT BMS, but I didn't had more time to try to connect to ant bms with ESP8266, a friend of mine just received the BMS, and he also want's to use an ESP32 board to connect to the BMS, I-ll tell him to join the forum and post back his code/ or the problems he has :)

But Lucas, do you have all the devices (BMS, Inverter, Arduino), except an raspberryPi , what is your problem? I used an RaspberryPy Zero W which is much cheaper than a normal one.

PS . I use an Arduino Mega to read info from MPP Solar inverter, and I wanted to use the same mega to read from ant bms, and also from the smart meter ... but unfortunately there's no free time , so I let the system work as it is now, RaspberryPi Zero communicates over BT with Ant BMS, and MPP Solar 8048 MAX communicates over RS232 with Arduino Mega board.
 

Attachments

  • dashboard.jpg
    dashboard.jpg
    136.5 KB · Views: 33
Last edited:
Sorry, cut & paste error. Should end in "BTPROTO_RFCOMM)". Full code attached.

Hello. After some time, i managed to get the Bluetooth connection to work with your fixed code, but unable to get any info out of this BMS. After few minutes the process quits with "Connection timed out".

bluetoothctl exposes following Bluetooth devices, and I have tried both. BMS-ANT16* seems to work better.
Device 16:AA:22:01:23:45 BMS-ANT16ZMUB
Device 16:AA:22:02:23:45 ANT-BLE16ZMUB

I have raspberry pi zero w powered next to the ANT BMS that is attached to battery I want to read.

I randomly get these readings to console when running the code, I have no idea if they are linked.
ManufacturerData Key: 0x0657
ManufacturerData Value:
88 a0 16 aa 22 01 23 45 ....".#E

Now, after trying to backtrack my process, my error has changed from the previous timeout that hung on line 22 -> Antw33 = s.recv(140)
pi@raspberrypi:~ $ sudo python joinbms.py
Traceback (most recent call last):
File "joinbms.py", line 14, in <module>
s.connect((serverMACAddress,port))
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 115] Operation now in progress

[bluetooth]# [bluetooth]# scan on
[bluetooth]# Failed to start discovery: org.bluez.Error.InProgress

It's been a while since I last used linux/python but I know some of it, would any of you know what to do next?
 
BTW, I can control the BMS now. The checksum is just the sum of the 3 bytes (address + data + data).

So.... sending it:

'A5A5FA0000FA' # Turn Off Charge MOSFET
'A5A5FA0001FB' # Turn On Charge MOSFET
'A5A5FE0000FE' # Reboot BMS
'A5A5F90000F9' # Turn Off DisCharge MOSFET
'A5A5F90001FA' # Turn On DisCharge MOSFET
'A5A5FC0000FC' # Toggles balancing

Adding this in case the future me forgets and has to google it. :)
Hi How do you go about writing to the ant bms?

I want to toggle the balancing.

Any help would be much appreciated :)

Cheers
 
import socket
import time
import requests as req
from binascii import unhexlify
import struct
import sys
import serial
import bluetooth
from bluetooth import *

serverMACAddress = 'AA:BB:CC:B1:23:45'
port = 1
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
s.connect((serverMACAddress,port))

test='A5A5FC0000FC'
try:
s.send(test.decode('hex'))
except:
s.close()
time.sleep(1)

s.close()
 
Hi,

Thank you for your reply :)

Your code didnt quite work but certainly pointed me in the right direction.

This code below works. Thought I would share this if any one else has want to do the same. As everyone probaly knows that the balance current is not much and only enables when charging.

I wanted to set a automation that when my battery system is in idle to enable auto balancing if the cells are out of balance. Im using node red exec node to run this python script.

import sys
import time
import serial
import struct
from binascii import unhexlify
import requests as req
import bluetooth
from bluetooth import *
import sys

#if sys.version < '3':
# input = raw_input

bd_addr = "AA:BB:CC:B1:23:45"

port = 1

#sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
#sock.connect((bd_addr, port))
#sock.close()
#time.sleep(1)

#Define RS485 serial port
ser = serial.Serial(
port='/dev/rfcomm2',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout = 1)

#while True :
test='A5A5FC0000FC'
try:
ser.write (test.decode('hex'))
except:
ser.close()
time.sleep(3)

s.close()


Thanks for your help :)

Cheers

Gareth
 
Late to the game, I have two modules I want to get connected.
ANT H-24S 180A
ANT 32S 300A

I am trying to follow along, but getting lost on the node vs socket, vs org code and where to begin.
Is there a full guide to setup a blank pi3, or pi-zero BT-> to http gateway?
Can I connect two modules to the same pi?
I'm really wanting to build something to remind me to plug my NEV in, I almost lost my battery pack as a result.
Would be great to the the ANT BMS connect to the internet and send e-mail notifications on low cell or percentage of pack.
 
Hi Jon,

Start by flashing a SD card with the latest version of raspbrian here. Im running it on a Pi4 with a 32GB sd card.


Then enable SSH in the settings.

I use Putty to connect to the Pi.

Then use the getbms-ant.txt file to load in influx (if that what you want to use), node red and the other programs.

Then you will need to tweek the python program to how ever many cells you have.

Once you have node red running you will be able to tweek the output data and set up some push notifcations using push over or something similar. For logging on to the bms when you remote you can just use the bluetooth app.

Sound like you want to connect your Pi logging data from the ANT BMS on the move? Which would mean you need some sort 3G/LTE dongle to connect to the Pi and be powered from you battery pack. Ive not heard of anyone doing this but is possible.

My Pi loggin the data is connected the battery via step down dc/dc converter.

I would get node red running and then go from there!

Hope this helps.

Cheers

Gareth
 

Attachments

  • getbms-ant.txt
    10.7 KB · Views: 75
I plan on either using a pepwave (cellular router) when on the move.
Or I may just connect it to wifi when it's near the front door or garage.
Pushover is a great idea! I've used it for other scripts and stuff.
I'm excited to try this out and will work on this today when I have time.
Thanks for the reply.

If anyone wants more information on pepwave, that's what we do a lot of for our core voip business.
Let me know I'm happy to lend my experience.
 
Upload ANTBMS data directly to EmonCMS.

Instructions for pushing data from ANTBMS to EmonCMS for monitoring and graphing. The script was made for my 21S battery, you can add more codes if you have more than 21S.

Script was inspired by a script called "ant-bms-bt-to-http" by #Sibianul
 

Attachments

  • instructions.txt
    12.2 KB · Views: 70
Hi Jon,

Start by flashing a SD card with the latest version of raspbrian here. Im running it on a Pi4 with a 32GB sd card.


Then enable SSH in the settings.

I use Putty to connect to the Pi.

Then use the getbms-ant.txt file to load in influx (if that what you want to use), node red and the other programs.

Then you will need to tweek the python program to how ever many cells you have.

Once you have node red running you will be able to tweek the output data and set up some push notifcations using push over or something similar. For logging on to the bms when you remote you can just use the bluetooth app.

Sound like you want to connect your Pi logging data from the ANT BMS on the move? Which would mean you need some sort 3G/LTE dongle to connect to the Pi and be powered from you battery pack. Ive not heard of anyone doing this but is possible.

My Pi loggin the data is connected the battery via step down dc/dc converter.

I would get node red running and then go from there!

Hope this helps.

Cheers

Gareth
Hi Gareth, I hope you don't mind me asking but how do you load the "getbms-ant.txt" file into influx & node red?
 
Hi,

You don't load it into influx. The getbms-ant.txt is the instructions of how to set this up from start to finish.

What stage are you at now? Do you have a SD card flashed and rasbrian up running?

Cheers
 
Hi,

You don't load it into influx. The getbms-ant.txt is the instructions of how to set this up from start to finish.

What stage are you at now? Do you have a SD card flashed and rasbrian up running?

Cheers
~Oh okay, I understand. Thanks... my misunderstanding. Yes I've got my pi setup and all running - ssh & logged on etc... I will start by copying the instructions one by one. Thank you.
 
This is the closest I have ever come to getting it working! I have this error... I'm sure it is because I have the location for the "getbms-ant.py" in the wrong location. Is anybody able to help me please?
cant find database.jpg
 
Back
Top