Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ANT BMS #1396

Closed
lucasimons opened this issue Sep 2, 2021 · 67 comments
Closed

Add support for ANT BMS #1396

lucasimons opened this issue Sep 2, 2021 · 67 comments

Comments

@lucasimons
Copy link

lucasimons commented Sep 2, 2021

Describe the problem you have/What new integration you would like

Add support for ANT BMS over UART or ble uart
Please describe your use case for this integration and alternatives you've tried:

Now i use a python script to read the data and send to mqtt on a rpi4
Additional context

https://github.com/juamiso/ANT_BMS
https://github.com/Sgw32/BMSCtl
https://github.com/Louisvdw/dbus-serialbattery/wiki/Driver-BMS-support
https://github.com/imval/AntBMS/blob/main/AntBMS.cpp

ANT_communication_protocol_EN.1.pdf

https://diysolarforum.com/threads/for-those-of-you-looking-to-monitor-your-ant-bms-with-pi3-via-bluetooth.6726/page-6

@SeByDocKy
Copy link

I got a custom sensor for the ANTBMS 2020 ... Unfortunatly they changed the protocol for the 2021 model :(

@lucasimons
Copy link
Author

Can you explain to me how you did it? did you connect to the display port? I currently use a script and connect to the bms via bluetooth

@SeByDocKy
Copy link

Yes on the display port.... it's an UART ... so basic wiring, ANTBMS: (GND,TX,RX) <=> ESP32 : (GND,RX,TX)

@lucasimons
Copy link
Author

Have you used esphome? Do you also have the option to switch the mosfet?

@SeByDocKy
Copy link

Yes ESPhome with a custom sensor : https://drive.google.com/file/d/1dwPWgargfSiYi-KMFOFXDH9V1jTvhBTh/view?usp=sharing

You can play with it... Tuned for a 16S battery

@lucasimons
Copy link
Author

thank you very much, how did you connect the cables? i.e. you only connected gnd to gnd, rx to tx (gpio01), tx to rx (gpio03)

@SeByDocKy
Copy link

right

@lucasimons
Copy link
Author

How does it work when you connect the display cable to the esp, the bluetooth still works?

@lumiror
Copy link

lumiror commented Jan 4, 2022

Yes ESPhome with a custom sensor : https://drive.google.com/file/d/1dwPWgargfSiYi-KMFOFXDH9V1jTvhBTh/view?usp=sharing

You can play with it... Tuned for a 16S battery

You can describe it in more detail, I'm not an experienced user, I would need a little more detailed explanation if possible. Thank you

@SeByDocKy
Copy link

Juste install the yaml and .h files into your /config/Esphome directory. Edit in Esphome the yaml file and change your WiFi informations... Be sure to connect the TX & RX to the pins specified in the top of the .h file... Than compile and install the file on your ESP32.

@lucasimons
Copy link
Author

lucasimons commented Jan 20, 2022

I received the batteries so now I would like to use the bms if I'm not mistaken this connector I have to use it to power the two wires to turn on the bms after connecting them in short circuit, instead the other two wires are rx and tx right? Can you send some pictures of the links? I thank you in advanceIMG_20220120_133129.jpg

@lumiror
Copy link

lumiror commented Jan 23, 2022

Juste install the yaml and .h files into your /config/Esphome directory. Edit in Esphome the yaml file and change your WiFi informations... Be sure to connect the TX & RX to the pins specified in the top of the .h file... Than compile and install the file on your ESP32.

Thank you for the answer, it is possible to use the module WeMos D1 Mini, ie ESP8266 . Will it work with the new version of ANT BMS 2021?

@SeByDocKy
Copy link

As I wrote from the beginnin the code I wrote sometimes ago was for the ANTbms model 2020.... Not sure it will work with the 2021 version as you have since the Appz changed between.... I guess they changed something in the protocol. But yes it's possible to use a simple WeMos D1 mini

@lumiror
Copy link

lumiror commented Jan 24, 2022

I don't know what I'm doing wrong but if I add an "includes" command I get an error, can you please help me how to fix it? I created a new file "antbms_custom_sensor.h" is that ok? Thanks.
yaml
antbms

@SeByDocKy
Copy link

SeByDocKy commented Jan 24, 2022

The include part must be in the esphome: section like

esphome:
  name: antbms
  platform: ESP32
  board: esp32dev
  includes:
    - antbms_custom_sensor.h```

@lumiror
Copy link

lumiror commented Jan 24, 2022

Thank you for the quick reply it helped. Can you please help me again? I got a SERIAL error, I changed the SERIAL2 to SERIAL1 error then only to SERIAL and also the error so I don't know how to fix it.
error

@lumiror
Copy link

lumiror commented Jan 30, 2022

So I managed to compile and upload to esp32 because esp 8266 didn't work. But now I have a problem, in homeassistant I see no data for entities. In antbms_custom_sensor.h is RX at 17 and TX at 16, is that correct? It should not be the other way around. Can there be a problem with that? I also tried TX on Tx RX on RX but I still don't see any data just unknown. Plus contact from BMS should not be connected? Because if I connect a display without a plus contact, the BMS will not connect to the display. Can you please help where there may be a mistake, maybe I'm close to making it work, I'd be very grateful. That's how I connected it.

ant

@HaraldRuppert
Copy link

HaraldRuppert commented Feb 2, 2022

Hi,
same for me. I've also just tried to connect it the way it's described here: imval/AntBMS#1
@lumiror are you using it for 8S or 16S? I've also tried to port it to ESP8266 but even with my ESP32 and unmodified code, ​it doesn't read anything.

Look at the pinout of your ANT-BMS LCD btw. the colors for the wires don´t make logical sense.
​For me, green = ground, red = VCC, yellow = RX and black = TX.

But I also struggle to read anything on any wire with a multimeter so I wonder if they even work.

It works via bluetooth so that's probably the way I need to go

@lumiror
Copy link

lumiror commented Feb 2, 2022

Hi, I use 16S exactly as the author. Unfortunately, I still don't get any data. Maybe if the author gave a photo of which version of BMS he used, we would move somewhere. I had those cables just like you, but before the assembly I swapped them according to the standard. Do you have a program that works via bluetooth?

@lucasimons
Copy link
Author

lucasimons commented Feb 3, 2022

hi,
but you have turned on the bms?
is through bluetooh it works for you?
I always have to receive the cells then I try if it works, as I asked in this discussion I did not know if I had to connect the black and red cables together because in the manual it is written that you have to apply a voltage of 3.2v between the two cables and then connect them later together, what procedure did you use?

@lumiror
Copy link

lumiror commented Feb 3, 2022

Via bluetooth it works with the original application, but only locally and limited bluetooth range. I don't understand the question, what red and black cable do you want to connect?

........I already understand what cables you want to connect together. On my BMS it is enough if I connect those cables together for 1-2 seconds and the BMS turns on and if I connect them for more than 3 seconds the BMS turns off, ie without using a battery or another source ,but I have two black cables.

BMS

@lumiror
Copy link

lumiror commented Feb 16, 2022

So I managed to make it work. I just have a little problem. The program freezes quite often, so I want to ask someone who uses it, if it happens to you and if so, how often. Thanks

@SeByDocKy
Copy link

So I managed to make it work. I just have a little problem. The program freezes quite often, so I want to ask someone who uses it, if it happens to you and if so, how often. Thanks

try to remove the date_baud: 0 in the logger and maybe you will have to adjust some timing in the .h

@lumiror
Copy link

lumiror commented Feb 16, 2022

Could you be more detailed please? Where can I find timing in the .h so which line is it. Alternatively, as I delete date_baud: 0 in the logger. I am a beginner and this information will help me a lot.

@lucasimons
Copy link
Author

Hi, unfortunately I have not yet been able to test the communication between bms and esp but I have seen that new repositories have been created for the various bms and integrated with esphome like this for jk bms

https://github.com/syssi/esphome-jk-bms

, it would be interesting to create a repo for ant bms

@lucasimons
Copy link
Author

lucasimons commented Feb 21, 2022

Hi, if you want to join to test and implement ant bms on esphome you can write here

syssi/esphome-ant-bms#1

@lumiror
Copy link

lumiror commented Feb 21, 2022

Just today I finished testing a new version from 2021 which also works. I am very satisfied . I have an old and a new version of BMS and they both work via the display port. If you have a display for yourANT BMS and displays the data it is highly likely that it will work for you as well. Then just tune the stability (this must be done by someone who knows how to program, unfortunately I don't know) and it will be a great version for ANT BMS. Thanks to the author for sharing.
ANT BMS

@lucasimons
Copy link
Author

I also have two bms one 100a old and one new 300a purchased in October 2021, so I think I am in the same condition as you, have you made any changes to the code? Can you explain better?

@SeByDocKy
Copy link

Just today I finished testing a new version from 2021 which also works. I am very satisfied . I have an old and a new version of BMS and they both work via the display port. If you have a display for yourANT BMS and displays the data it is highly likely that it will work for you as well. Then just tune the stability (this must be done by someone who knows how to program, unfortunately I don't know) and it will be a great version for ANT BMS. Thanks to the author for sharing. ANT BMS

It's me :)

@lumiror
Copy link

lumiror commented Feb 21, 2022

It's me :)

I know

perfect

@lumiror
Copy link

lumiror commented Feb 22, 2022

Your BMS is different. Do you have a display? Does it show you data from BMS? As you have it connected, take a picture.

@lucasimons
Copy link
Author

Your BMS is different. Do you have a display? Does it show you data from BMS? As you have it connected, take a picture.

I have two bms both without display, I soldered some wires because I did not have the display connector however starting from the left it says on the pcb positive, gnd, B, A, assuming that the last two pins are for the display

@lumiror
Copy link

lumiror commented Feb 22, 2022

I have it connected like this:
positive to output 3.3v ESP32
gnd = gnd
A = RX
B = TX

@lumiror
Copy link

lumiror commented Feb 22, 2022

still check if you have correctly assigned pins, in the program it is:
#define RXD2 17
#define TXD2 16
but your ESP32 has the other way around

@lucasimons
Copy link
Author

I connected the left pin to 3.3 the pin 2 to gnd then the white cable to 16 and the right cable to 17, so I have no instability problems, but it gives an error trame
image

@lucasimons
Copy link
Author

lucasimons commented Feb 22, 2022

the original display cable have this color red, black, yellow, green

red to 3.3v
gnd to gnd
yellow ( white in my pic) to tx2 (17)
green ( yellow in my pic) to rx2 (16)

the problem is that if I connect the data cables in this way the esp32 disconnects and is unstable

@lumiror
Copy link

lumiror commented Feb 22, 2022

For me, the flood color of cables:
red = VCC
green = GND
yellow = A (RX)
black = B (TX)

@lumiror
Copy link

lumiror commented Feb 22, 2022

Do you see the data in the APP via bluetooth? If so, try to change RX and TX or disconnect the VCC 3,3V from ESP 32. You have to try several options and see what it does.

@lucasimons
Copy link
Author

I think I got confused with the cables ... Anyway, do you know what kind of connector is the one of the display?

@lumiror
Copy link

lumiror commented Feb 22, 2022

I don't know exactly what type it is, but it's this:

connector

@SeByDocKy
Copy link

Should be JST XH2.0 4P or JST/microMolex 1.25mm 4p

@lucasimons
Copy link
Author

I tried but through the custom components it does not work and there are always problems with the esp 32 that I have and unfortunately I do not know the reason but it does not work on esp8266, I had reversed the cables because the black was not gnd but tx

@syssi
Copy link

syssi commented Feb 23, 2022

@lucasimons Could you make some photos again? The BMS mainboard of lumiror is labeled (GND, RX, TX, VCC) nicely.

@lumiror
Copy link

lumiror commented Feb 23, 2022

This is not a BMS mainboard, but a display

@syssi
Copy link

syssi commented Feb 23, 2022

Good point. It helps nevertheless to identify VCC and GND. TX and RX will have to be tried out.

@lumiror
Copy link

lumiror commented Feb 23, 2022

I tried but through the custom components it does not work and there are always problems with the esp 32 that I have and unfortunately I do not know the reason but it does not work on esp8266, I had reversed the cables because the black was not gnd but tx

ESP8266 don't even try it doesn't work, but as Syssi writes take photos as you have it connected. But good quality, focused so we can see the details

@lumiror
Copy link

lumiror commented Feb 23, 2022

..... something to motivate foto1

foto

@lucasimons
Copy link
Author

lucasimons commented Feb 23, 2022

IMG_20220223_175528.jpg
I think that in my bms the cable are swapped

@lumiror
Copy link

lumiror commented Feb 23, 2022

take yet photo of ESP32

@lucasimons
Copy link
Author

IMG_20220223_180041.jpg

@lumiror
Copy link

lumiror commented Feb 23, 2022

It is not visible to which pins you have the green and yellow cable connected

@lucasimons
Copy link
Author

now it works fine
image

@lumiror
Copy link

lumiror commented Feb 23, 2022

That's great. Maybe I would connect it for safety on IO 17 and IO16 TX2 RX2

@arnold34740
Copy link

Hello , not sure to post at the correct place ,
i've got antbms 20A with tx 15 rx 13 on esp8266 wemos d1 mini . All switches works perfectly but no sensors are displayed.
I try to reverse rx with tx but when i do that i loose switch commands . It's a old 2020 protocol with the old app i don't know what to do .
Thanxs 4 ur help

@syssi
Copy link

syssi commented Mar 4, 2022

Could you provide your yaml configuration?

@lucasimons
Copy link
Author

haw many amp? 20a? Can you send a pic?

@nagyrobi nagyrobi closed this as completed Jul 1, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants