diy solar

diy solar

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

Notez également que mon code ajoute 0,7V à la tension du pack. Mon BMS lit bas, c'est donc un bon moyen de corriger.

#BMS V
data = (Antw33.encode ('hex') [8:12])
data = struct.unpack ('> H', unhexlify (données)) [0] * 0.1
données = données + 0,7
Le n ° 0,7

Also, take note that my code is adding 0.7V to the pack voltage. My BMS reads low so this is a good way to correct.

#BMS V
data = (Antw33.encode('hex') [8:12])
data = struct.unpack('>H',unhexlify(data))[0]*0.1
data = data+0.7
#0.7 was added as BMS low.
print (data)
OK I had seen but I use another code which transmits the data by Simple-api, I checked the voltage of the bms with my multimeter and it indicates the same thing on the other hand I did not check the amps nor the watts
 
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. :)
I edit the file of @JaseZA and now i can see the mosfet status with mqtt,but i wish i could change the status from mqtt ... Is it possible?
 

Attachments

  • Immagine 2021-05-09 193553.jpg
    Immagine 2021-05-09 193553.jpg
    41.5 KB · Views: 43
Thank you guys for the python code posted in this thread, I also want to port it to arduino but currently I had some issues with my HC-05 module and I gave up trying with arduino, so I grab a spare Raspberry Pi Zero w and happily after a few hours I was able to talk to Ant BMS module.

I modified the code as I needed to have the information's sent to my local server trough http (I never had enough free time to learn, install and work with MQTT) and I also didn't like the approach of sending each value with a different request, so I modified the code, created a different variable for each value, and at the end of the code I used only one request to my local server, that includes all the values, tomorrow I will post the entire code here, after adding the temperature values too, for all 4 cell sensors + MOS temperature.

I wanted to ask you guys, regarding the power value, I sometimes seen -5 in the printed response, can someone tell me why this inversion of the number is made in this section of the code ? I understand that if data_power > 2147483648 -> invert the value of data, but why ?

Code:
try:
  if int(data_power,16)>2147483648:
    data_power=(-(2*2147483648)+int(data_power,16))
    print data_power
  else:
    data_power=int(data_power,16)
    print data_power


  data_power_url = 'BMS_power='+str(data_power)
  #  resp = req.get(url+'BMS_pow'+'?value='+str(data))
except:
   pass

Thank you
 

Attachments

  • photo_2021-06-10_01-42-34.jpg
    photo_2021-06-10_01-42-34.jpg
    60.5 KB · Views: 40
  • photo_2021-06-09_21-40-50.jpg
    photo_2021-06-09_21-40-50.jpg
    14.6 KB · Views: 40
Here is the modified code, I also confirm all 4 Cells temperature sensors work, the sensor 3 and 4 use the 100 and 102 pointer , as in the attached file.

Here is the return of my code, and the request from apache local server

Code:
pi@raspberrypizero:~ $ sudo python /home/ant-bms-bt-to-http.py
SoC=31
Remaining Ah  166.727274
BMS Power -5w
BMS current -0.1A
BMS Voltage 54.0v
Cell AVG 3.601v
Cell MIN 3.599v
Cell MAX 3.603v
Cell 01 3.603v
Cell 02 3.6v
Cell 03 3.6v
Cell 04 3.603v
Cell 05 3.599v
Cell 06 3.602v
Cell 07 3.603v
Cell 08 3.6v
Cell 09 3.6v
Cell 10 3.6v
Cell 11 3.601v
Cell 12 3.602v
Cell 13 3.602v
Cell 14 3.601v
Cell 15 3.603v
MOS Temp:  26
Balance Temp:  25
Battery Temp Sensor 1:  32
Battery Temp Sensor 2:  24
Battery Temp Sensor 3:  23
Battery Temp Sensor 4:  23

Code:
192.168.100.199 - - [10/Jun/2021:09:32:00 +0300] "GET /push.php?SoC=31%&BMS_power=-5&BMS_Current=-0.1&BMS_V=54.0&cell_avg=3.601&cell_min=3.599&cell_max=3.603&cell_1=3.603&cell_2=3.6&cell_3=3.6&cell_4=3.603&cell_5=3.599&cell_6=3.602&cell_7=3.603&cell_8=3.6&cell_9=3.6&cell_10=3.6&cell_11=3.601&cell_12=3.602&cell_13=3.602&cell_14=3.601&cell_15=3.603&mos_temperature=26&balance_temperature=25&cell_temperature_1=29&cell_temperature_2=24&cell_temperature_3=23&cell_temperature_4=23&remaining_ah=166.727274
 

Attachments

  • ant-bms-bt-to-http.txt
    8.2 KB · Views: 148
Last edited:
I wanted to ask you guys, regarding the power value, I sometimes seen -5 in the printed response, can someone tell me why this inversion of the number is made in this section of the code ? I understand that if data_power > 2147483648 -> invert the value of data, but why ?

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.
I don't know yet what is the raw value of the power, but I will try to find out myself when I will also start discharging the battery. I believe @chadhouser wanted to have the power value negative when discharging battery, and positive when charging?

In my dashboard the power value is inverted, for now I set my invertor to only charge the battery, and not discharge it, it's the first time I connected the battery to my inverter, after the battery will be full I will change the inverter to SBU mode, from SUB to also discharge it.

1623837537557.png

I will increase the maximum charging current, and if I will see the temperature of the MOSfet's in the BMS will increase, I will also mount a fan or two. So far the temperature of MOSfets is very low, as you can see in the photo above.

Bellow you can see how I mounted the radiators over the ANT BMS board
 

Attachments

  • antbms radiator 3.jpg
    antbms radiator 3.jpg
    215.6 KB · Views: 42
  • antbms radiator 2.jpg
    antbms radiator 2.jpg
    139.3 KB · Views: 39
  • antbms radiator 1.jpg
    antbms radiator 1.jpg
    110.5 KB · Views: 38
Last edited:
That would be great getting the real soc from the battery.
But as a noob at the moment i'm getting following errors:


>>> %Run test.py
Traceback (most recent call last):
File "/home/pi/pybluez/test.py", line 7, in <module>
import bluetooth
File "/home/pi/pybluez/bluetooth/__init__.py", line 45, in <module>
from bluetooth.bluez import *
File "/home/pi/pybluez/bluetooth/bluez.py", line 10, in <module>
import bluetooth._bluetooth as _bt
ModuleNotFoundError: No module named 'bluetooth._bluetooth'
>>>

Please help me out
 
do you have python-bluez installed? , if not install it using :

Code:
sudo apt-get install python-bluez
 
The python script works great but i want to use a ESP board to collect the bms stats, no one has done this?
 
I also plan to use an ESP.. but didn't had time yet to try again with an different BT module. With the only BT module I had, I was stuck when I tried to detect the ANT BMS BT Address, I got ERROR (16) as I described on the arduino forum
 
I don' think we must reverse engineer anything, the communication protocol documentation is available, we need just free time, something I don't have :( .. and while the rPi Zero is working, I try to finish my other projects first, and only after that work on modifying already working projects.
 
Back
Top