diy solar

diy solar

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

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
you have tried to turn off the mosfet with this code?
 
Hello
I sniffed the bluetooth for my unit Ant 20PHB-TB-8-20S-400A dated from 21-09-08 and got the follwing connection string
(test in the script) test='7EA1010000BE1855AA55' which gives and answer that however is partly scrambled. I have not checked the rest of the code, it could be that I have only 16 cells not 21. The only thing that is reasonable is MOS and balance temp
 
Is there any possibility of getting the data from the ANT BMS onto the rPi via a wired connection?
Hi, has anyone tried that meanwhile? According to this thread the original display wires just interface with the STM32 microcontroller on the BMS

I have the display but don't use it so I'm wondering if I can get this connected. On my RPi I'm running the Home Assistant OS image and can't connect to the BMS via bluetooth (for whatever stupid reason) so wiring it up would be handy, especially since the RPi is just next to my batteries. I don't want another RPi. Alternatively, I'll have to use an ESP32.
 
Hello!

I also have Ant 20PHB-TB-8-20S-400A and a pi ZeroW. ulrikk - did you mange to talk to the BMS ? Can you share the py script?
Thank you!
Adrian
 
Spent couple of hours yesterday trying to get it to work, but I had no success. I realized that I must install (legacy version) of PI OS, since the latest comes with python3. And as you can see in the picture in the attach, the errors are different with python2 or with python3. Well since right now, by default I have python2 installed on the PI, trying to get rid of the "ImportError: No module named serial", from google search I found that maybe pyserial is missing. I installed it but the pyserial now installed is for python3. And the error is the same! What can I do now?

Another thing that is confusing me, is that the scan for BT devices founds 2 devices related to ANTBMS. (see the picture in attach.) One is ANT-BLE20PHUB" and another is "BMS-ANT20PHUB"

If I connect to "ANT-BLE20PHUB" the pair is succesfully (BT led on the BMS - steady ON), but is not asking for the "1234" password, and after a couple of seconds (15-20sec) the pair is lost. (the BT led from the BMS starts flashing - indicating that it has no pair.

If I connect to "BMS-ANT20PHUB" now is asking for "1234" password and pair is succesfully, then it gets disconnected after a short period of time, and the BT led on the BMS keeps flashing (indicating that it has no pair - as you can see in the err5.jpg picture).

So, at wich device I must connect the PI? "ANT-BLE20PHUB" or "BMS-ANT20PHUB" ?
And why the connection is cut out from the bms after seconds? If I launch the antBMS app on the phone, it automatically connect and the pair remains active until I close the app.

Thank you!
Adrian.
 

Attachments

  • err4.jpg
    err4.jpg
    44.1 KB · Views: 14
  • Img022-01-16 at 01.27.03.jpeg
    Img022-01-16 at 01.27.03.jpeg
    44.5 KB · Views: 13
  • err5.jpg
    err5.jpg
    79.8 KB · Views: 13
Last edited:
Hello!

I also have Ant 20PHB-TB-8-20S-400A and a pi ZeroW. ulrikk - did you mange to talk to the BMS ? Can you share the py script?
Thank you!
Adrian
Hi Adrian I used the previous ant bms code, but modified the calling string, and commented out libraries not loading. with my RPI Zero W. As you noted the ant bms seees tobe python2. It seems however that frequently the RPI cannot read the entire string properly (304 bytes), when I compared with what I found on wireshark. Thus I analysed the string in wireshark with another python program in jupiter (python 3), reading 4 bytes incrementally and trying to compare with know data and realized that only a few of 16 batteries voltages were correct in each reading. I am suspecting that there is some sort of flag to tell when a reading is complete and that BMS responds only with a few correct readings every time, maybe the software displays the correct values only. At least I did never find 16 correct reading in one string. I also got two ants i Bluetooth and selected that with password. It work for while at least. I am starting to systematize the response and also asking for the protocol from the dealer without no success.
Ulrik
 

Attachments

  • antbmsstep.txt
    11.1 KB · Views: 47
  • Byte4decodingANT.txt
    409 bytes · Views: 35
Thank you for your response.
I've tested your code, with no success, since I am stuck at "no module named serial" error. (see picture).
How I resolve this?

I will ask my seller too, for the communication protocol. Maybe they will give me the protocol (since for old versions I saw somewhere on the internet). I will post back here if have the protocol.

Meantime I must resolve the python error, and I don't know how:(

Thank you!
Adrian
 

Attachments

  • err6.jpg
    err6.jpg
    19.1 KB · Views: 13
Meanwhile, Did you notice the DTU feauture in the ParameterSet settings? It says IOT there? It is what I think it is? Can we extract data via phoneapp and put it somewhere to a server? Where can we found more detailes about this? I haven't found any manual for this app. The support is very poor...
 

Attachments

  • Screenshot_20220116_145713_com.mayi.bms.jpg
    Screenshot_20220116_145713_com.mayi.bms.jpg
    75.7 KB · Views: 18
  • Screenshot_20220116_145745_com.mayi.bms.jpg
    Screenshot_20220116_145745_com.mayi.bms.jpg
    112.6 KB · Views: 19
Thank you for your response.
I've tested your code, with no success, since I am stuck at "no module named serial" error. (see picture).
How I resolve this?

I will ask my seller too, for the communication protocol. Maybe they will give me the protocol (since for old versions I saw somewhere on the internet). I will post back here if have the protocol.

Meantime I must resolve the python error, and I don't know how:(

Thank you!
Adrian
You need to load the serial library from internet to your RPI
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-serial
 
Meanwhile, Did you notice the DTU feauture in the ParameterSet settings? It says IOT there? It is what I think it is? Can we extract data via phoneapp and put it somewhere to a server? Where can we found more detailes about this? I haven't found any manual for this app. The support is very poor...
Yes I noted the DTU things, I thought it was something for connecting the GPS for some tracking. It is also on the BMS display (if I remember coorect), so it is probably more connected to the BMS than the phone.
 
Sorry I did not mention this, but I have tried the solution you suggest. This is the error after last one:
I need to install it from another repo or what?
 

Attachments

  • err7.jpg
    err7.jpg
    39.3 KB · Views: 12
OK I deliberatetly installed debian buster with raspberryimager, not the latest Bullseye, because I had trouble with Bullseye in other projects. Maybe the serial is not available in bullseye? I got the impression that the serial BT is shaky in python. Or google on your errorsmessage and see if others had the same trouble.
I am running python 2
python --version
Python 2.7.16
 
Last edited:
Well, I reinstall the RPI OS (legagy) again. Made progress with your string code. I have response from ANT (as you see in the pict), but as you said, there are incorrect. Well, the SOC is 15% and it shows 156%, maybe only the first 2 characters are correct... Anyways, what I trully want is the SOC and the POWER, Cell voltages is something that I want too, but it is not a must, since I can check them by phone every now and then.
I left a message to the seller asking for the protocol... Please post any update or progress. That string is the key!

The "MrLaptop" sugestion on post #124 it's not working! Maybe he will post back something, if he said that he discovered the solution for this model...

PS: temperature sensors are connected to the BMS correctly, but in the APP shows 0 value. you have values for temperature?

Best regards,
Adrian
 

Attachments

  • response.jpg
    response.jpg
    121.8 KB · Views: 27
Super, then we are at least two with this type o unit. Check string length, my was varying (insert and print len(str..)).
 
I have almoust zero experience in programming, since I am not a programmer. I will do anything you want to check if you give me the exact code and tell me where to put it :)
 
No guessing ?. . I monitored my bluetooth communication with a built in tool in android, but little tricky to set up and many instructions are outdated with android 10 and higher. When finally had some bluetooth communcation with my bms with the android app I used wireshark, that can decode communication,identify all bluetooth overhead, just leaving a string that was left over. There I could see what my phone was sending and the answer from bms. I can find the links if hyou need more information.
 
Super cool, and clever :)

Are you optimistic about this whole communication issue we encounter? or should we go in another direction? I don't know, switch the bms brand eventually, or there is another way to get the data from this? I made my decision to buy this BMS because my friend bought this brand (older model), about a year ago and he managed to get data easy and preety straightforward. I am willing to pay for a code that works, just to resolve this problem.
 
Ok. I have response from the seller. They don't have the protocol, but they send me a new (updated) link for the android app. Right now there are (or at least I have) 3 versions of the app - The best, full working version is "MY-APP-1116.apk". The rest of the apps "mybms_v1.2.4_20210803.apk" and "mybms_v1.3.25_20210926(2).apk" are not fully functional, for example I don't have the MOS, balance and cell temperatures displayed.

I was wondering if you can, install the MYApp1116, and try with this app to find that string, because this is may be more accurate, and has all the data.
Or if you dont have the time, tell me what software (links) you used to find that string.

Here is the link that the seller gaved me:

http://mysharegadget.com/947324863
 
Last edited:
Ok. I have response from the seller. They don't have the protocol, but they send me a new (updated) link for the android app. Right now there are (or at least I have) 3 versions of the app - The best, full working version is "MY-APP-1116.apk". The rest of the apps "mybms_v1.2.4_20210803.apk" and "mybms_v1.3.25_20210926(2).apk" are not fully functional, for example I don't have the MOS, balance and cell temperatures displayed.

I was wondering if you can, install the MYApp1116, and try with this app to find that string, because this is may be more accurate, and has all the data.
Or if you dont have the time, tell me what software (links) you used to find that string.

Here is the link that the seller gaved me:

http://mysharegadget.com/947324863
That is the same app (MYApp) I was working with. I have been looking on the wireshark from my usb communcation, it is similar to Bluetooth, but manyb more cells are populated with a reasonable values(15 of 16). The cellvoltage are on other places than the standard protocol. But I cannot find eg total voltage .
 
OK now at least I can figure out the response. I monitored the communication between the Display and the BMS. That follows the protocol I got from a dealer attached as pdf (but I got it as excel). The bluetooth sniff and pythonscript via bluetooth seems not be according the protocol , why I don't know and strange. But the serial port speaks according the protocol. I will test if I can get my computer to communicate that way also.
 

Attachments

  • 140byteprotocol.pdf
    346.5 KB · Views: 76
Interesting... I don't mind talking to the BMS by serial. Just want to know how, and what adapters/converters are necesarry like RS485/TTL or so.
I've changed the SOC value for example, by raising the total Ah value of the pack. The result was that in the app was updated accordingly, but the pyhton output is the same. I got different response at every query for battery temp sensor 4... and that value should be the same, since the temp is constant...
 
Well, I guess my BMS is broken, all of the suden. Today I wired the battery bank to the inverter and I've installed the BMS too. After power on, it says DisMosError and it beeps continuosly. Attached you have a picture to see the error. Besides the Dismos error, the SOC is at 100% from 15% Why? It is broken already?
 

Attachments

  • Screenshot_20220120_181032_com.mayi.bms.jpg
    Screenshot_20220120_181032_com.mayi.bms.jpg
    160.8 KB · Views: 38
Well, I guess my BMS is broken, all of the suden. Today I wired the battery bank to the inverter and I've installed the BMS too. After power on, it says DisMosError and it beeps continuosly. Attached you have a picture to see the error. Besides the Dismos error, the SOC is at 100% from 15% Why? It is broken already?
What a unluck. What happens if you disconnect inverter? The voltage seems reasonable for about 100%. Why was it 15% before?. What is connected to give the high current of16A?
 
What a unluck. What happens if you disconnect inverter? The voltage seems reasonable for about 100%. Why was it 15% before?. What is connected to give the high current of16A?
Hello! It's been quite a long time since I visit the forum, and this topic in particular.
I want you to know what it happened to my BMS. Well, I completely understand now, why it has been damaged, and lets say it's my fault.

So, somewhere in the docs, manuals that I received from the seller, I've read that before connecting the bms to the system, I must close the mosfets in the app, which I did. Then I connect the bms to the system, and with a precharge resistor, I charge the inverter capacitors to avoid sparks when connecting the load. (at least that was my intention :) And then I connect the battery to the inverter and power on the system.
Since the BMS had the mosfets in close position, the procedure of precharging the inverter capacitors has not occured (obviously, since there has been no current flow to the inverter). When I switched the power on, a large flow of current passed and at that moment the bms broke. So, I realized this latter on.

I spoked to the seller, and it confirmed that it is short circuit when connecting the load, and he suggested to me to send back the unit for a repair.
I did not wanted that, since the shipping costs and wait time is too long.
A friend of mine, says that if I open the BMS, I can inspect with a multimeter every mosfet (there are 36), and I can easily see what mosfet is broken.
So I open the BMS, I find the problematic mosfet, and I cut it's pins from the PCB. (I was too lazy to unsolder it nicely).
I want to tell you that the BMS is alive again (without 1 mosfet, It's power is reduced by about 15% - no bother).

Now, I am back from where I started it. It is very very frustrating not having the data from it to my dashboard.
Tell me that you have made some progress regarding the BT communication ?
 

Attachments

  • resizeIMG_20220204_151447.jpg
    resizeIMG_20220204_151447.jpg
    273 KB · Views: 41
  • resizeIMG_20220204_154927.jpg
    resizeIMG_20220204_154927.jpg
    202.9 KB · Views: 41

diy solar

diy solar
Back
Top