syssi / esphome-ant-bms Goto Github PK
View Code? Open in Web Editor NEWESPHome component to monitor and control a ANT-BMS via UART
License: Apache License 2.0
ESPHome component to monitor and control a ANT-BMS via UART
License: Apache License 2.0
ESP_LOGI(TAG, " Permissions: %d", data[6]);
ESP_LOGI(TAG, " Battery status: %d", data[7]);
ESP_LOGI(TAG, " Number of temperature sensors: %d", temperature_sensors);
ESP_LOGI(TAG, " State of health: %.0f %%", ant_get_16bit(44 + offset) * 1.0f);
ESP_LOGI(TAG, " Balanced cell bitmask: %d", ant_get_32bit(70 + offset));
ESP_LOGI(TAG, " Voltage difference: %.2f V", ant_get_16bit(82 + offset) * 0.001f);
ESP_LOGI(TAG, " Accumulated discharging capacity: %.2f Ah", ant_get_32bit(96 + offset) * 0.001f);
ESP_LOGI(TAG, " Accumulated charging capacity: %.2f Ah", ant_get_32bit(100 + offset) * 0.001f);
ESP_LOGI(TAG, " Accumulated discharging time: %s", this->format_total_runtime_(ant_get_32bit(104 + offset)).c_str());
ESP_LOGI(TAG, " Accumulated charging time: %s", this->format_total_runtime_(ant_get_32bit(108 + offset)).c_str());
-> 0xA5 0xA5 0xFA 0x00 0x00 0xFA # Turn Off Charge MOSFET
-> 0xA5 0xA5 0xFA 0x00 0x01 0xFB # Turn On Charge MOSFET
-> 0xA5 0xA5 0xFE 0x00 0x00 0xFE # Reboot BMS
-> 0xA5 0xA5 0xF9 0x00 0x00 0xF9 # Turn Off DisCharge MOSFET
-> 0xA5 0xA5 0xF9 0x00 0x01 0xFA # Turn On DisCharge MOSFET
-> 0xA5 0xA5 0xFC 0x00 0x00 0xFC # Toggles balancing
https://github.com/klotztech/VBMS/wiki/Serial-protocol#control-addresses
https://github.com/klotztech/VBMS/wiki/Serial-protocol#checksums
Hi, I don't know what I'm doing wrong, but the installation will end with a broken wifi connection. Can you advise on what the problem may be? Or how should I install it properly? Thank you
antbms-new.txt
It's possible to control the BMS version 2021 now. The command set for the pre 2021 version is implemented too but heavily untested. I would be happy about some insights / debug logs to get a better understanding which instructions are accepted and working.
cp. #5
Sporadically I have some reading problems as I use the soc% for some automations and turn off the inverter for example, I would like to know if there is a way to set the last value and prevent it from going to 0%
Originally posted by @lucasimons in #33 (comment)
Hello, I want to ask, would it be possible to use an entity from ANT BMS in homeassistant, specifically information about the battery charge in % (sensor.antbms_soc) on pwm signal control from ESP32? For example, if the battery is 95% charged at the ESP32 output, the PWM signal will be 20%, if it is 96% at the output, it will be 35%, 97%=50%, 98%=65%, 99%=85%. 100%=100. Thank you
Hello,
First of all, thanks for your project.
I tried to use it through bluetooth (bt) but it does not connect. I assume it is due to bt password. Indeed, when I try to connect with my PC to the ANT BMS a BT password/code is required the first time. In the log below, you can see the programm detect the bms bt but can not connect
Regards,
View | Button/Method | Message | Notes |
---|---|---|---|
Syslog | 0xDBDB, 0x00, 0x0000 |
||
Main | Authenticate | 0xA5A5, 0xF1, ((pwd.charAt(0) & 255) * 256) + (pwd.charAt(1) & 255) 0xA5A5, 0xF2, ((pwd.charAt(2) & 255) * 256) + (pwd.charAt(3) & 255) 0xA5A5, 0xF3, ((pwd.charAt(4) & 255) * 256) + (pwd.charAt(5) & 255) 0xA5A5, 0xF4, ((pwd.charAt(6) & 255) * 256) + (pwd.charAt(7) & 255) |
8 chars |
Main | Change password | 0xA5A5, 0x66, ((pwd.charAt(0) & 255) * 256) + (pwd.charAt(1) & 255) 0xA5A5, 0x67, ((pwd.charAt(2) & 255) * 256) + (pwd.charAt(3) & 255) 0xA5A5, 0x68, ((pwd.charAt(4) & 255) * 256) + (pwd.charAt(5) & 255) 0xA5A5, 0x69, ((pwd.charAt(6) & 255) * 256) + (pwd.charAt(7) & 255) |
8 chars |
Main | Change parameters lithium iron phosphate | 0xA5A5, 0xF0, 0x0000 |
|
Main | Enable charging | 0xA5A5, 0xFA, 0x0001 |
|
Main | Enable discharging | 0xA5A5, 0xF9, 0x0001 |
|
Main | Are you sure you want to change the Bluetooth address? | 0xA5A5, 0xF6, 0x0000 |
|
Main | Disable charging | 0xA5A5, 0xFA, 0x0000 |
|
Main | Disable discharging | 0xA5A5, 0xF9, 0x0000 |
|
Main | Reboot | 0xA5A5, 0xFE, 0x0000 |
|
Main | Factory reset: After the factory setting, all battery parameters will become default values (ternary battery parameters) | 0xA5A5, 0xFD, 0x0000 |
|
Main | Flip screen | 0xDBDB, 0x01, 0x0000 |
|
Main | Shutdown: Power off the BMS? After shutting down, you need to press the power button or charge the charger to turn it on | 0xA5A5, 0xF7, 0x0000 |
|
Main | Balacing | 0xA5A5, 0xFC, 0x0000 |
|
Main | LiFePO4 Settings: After determination, the parameter will turn into lithium iron phosphate | 0xA5A5, 0xFB, 0x0000 |
|
Main | Current zeroing | 0xA5A5, 0xF8, 0x0000 |
|
Settings | read_data | 0x5A5A, address, 0 |
|
Settings | Apply | 0xA5A5, 0xFF, 0x0000 |
|
States | Query status (old?) | (AtyParam2.this.versions_data == 0) 0x5A5A, 0x5A, 0x0000 |
|
States | Query status | 0xDBDB, 0x00, 0x0000 |
Please remove the icon in the SOC sensor, since device_class: battery supports its own icon.
And she changes color.
Hello.
It's possible to connect Ant BMS to Goodwee inverter with an ESP?
I have a battery with an ANT BMS connected by + and - wires to inverter, don't work in best conditions.
If it's possible, what it's need to put it working?
Inverter is Goodwe GW5048-ES.
Don't have much knowledge about ESP.
Thanks
Nuno Rainha
Hi, i just received the connector for which i can test with the bms 2020 what should i change to the configuration in esphome?
Probably new ANT-BMS versions aren't supported at the moment because the status frame cannot be requested using the old protocol anymore.
See #18 (comment)
Board: D1 mini
Ant bms S Version: 16ZMUB00-220825A
Ant bms H Version: 16ZMA0TB080A
Battery configuration: LiFePO4 8S
Config:
substitutions:
name: ant-bms
device_description: "Monitor and control a ANT Battery Management System (ANT-BMS) via UART"
external_components_source: github://syssi/esphome-ant-bms@main
rx_timeout: 50ms
tx_pin: GPIO4
rx_pin: GPIO5
password: "12345678"
esphome:
name: ${name}
comment: ${device_description}
project:
name: "syssi.esphome-ant-bms"
version: 2.0.0
esp8266:
board: d1_mini
external_components:
- source: ${external_components_source}
refresh: 0s
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "API KEY"
ota:
password: "OTA KEY"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Antbms Fallback Hotspot"
password: "pass"
#captive_portal:
#mqtt:
# broker: !secret mqtt_host
# username: !secret mqtt_username
# password: !secret mqtt_password
# id: mqtt_client
uart:
- id: uart_0
baud_rate: 19200
rx_buffer_size: 384
tx_pin: ${tx_pin}
rx_pin: ${rx_pin}
ant_bms:
- id: bms0
uart_id: uart_0
update_interval: 10s
rx_timeout: ${rx_timeout}
supports_new_commands: true
password: "${password}"
binary_sensor:
- platform: ant_bms
ant_bms_id: bms0
online_status:
name: "${name} online status"
sensor:
- platform: ant_bms
ant_bms_id: bms0
battery_strings:
name: "${name} battery strings"
current:
name: "${name} current"
soc:
name: "${name} soc"
total_battery_capacity_setting:
name: "${name} total battery capacity setting"
capacity_remaining:
name: "${name} capacity remaining"
battery_cycle_capacity:
name: "${name} battery cycle capacity"
total_voltage:
name: "${name} total voltage"
total_runtime:
name: "${name} total runtime"
average_cell_voltage:
name: "${name} average cell voltage"
power:
name: "${name} power"
min_cell_voltage:
name: "${name} min cell voltage"
max_cell_voltage:
name: "${name} max cell voltage"
min_voltage_cell:
name: "${name} min voltage cell"
max_voltage_cell:
name: "${name} max voltage cell"
delta_cell_voltage:
name: "{name} delta cell voltage"
temperature_1:
name: "${name} temperature 1"
temperature_2:
name: "${name} temperature 2"
temperature_3:
name: "${name} temperature 3"
temperature_4:
name: "${name} temperature 4"
cell_voltage_1:
name: "${name} cell voltage 1"
cell_voltage_2:
name: "${name} cell voltage 2"
cell_voltage_3:
name: "${name} cell voltage 3"
cell_voltage_4:
name: "${name} cell voltage 4"
cell_voltage_5:
name: "${name} cell voltage 5"
cell_voltage_6:
name: "${name} cell voltage 6"
cell_voltage_7:
name: "${name} cell voltage 7"
cell_voltage_8:
name: "${name} cell voltage 8"
charge_mosfet_status_code:
name: "${name} charge mosfet status code"
discharge_mosfet_status_code:
name: "${name} discharge mosfet status code"
balancer_status_code:
name: "${name} balancer status code"
text_sensor:
- platform: ant_bms
ant_bms_id: bms0
charge_mosfet_status:
name: "${name} charge mosfet status"
discharge_mosfet_status:
name: "${name} discharge mosfet status"
balancer_status:
name: "${name} balancer status"
total_runtime_formatted:
name: "${name} total runtime formatted"
switch:
- platform: ant_bms
ant_bms_id: bms0
charging:
name: "${name} charging"
discharging:
name: "${name} discharging"
# BMS version 2021 only
# Please enable supports_new_commands
balancer:
name: "${name} balancer"
button:
- platform: ant_bms
ant_bms_id: bms0
shutdown:
name: "${name} shutdown"
clear_counter:
name: "${name} clear counter"
balancer:
name: "${name} balancer"
factory_reset:
name: "${name} factory reset"
restart:
name: "${name} restart"
Logs:
[14:41:03][D][binary_sensor:036]: 'ant-bms online status': Sending state OFF
[14:41:03][D][text_sensor:064]: 'ant-bms discharge mosfet status': Sending state 'Offline'
[14:41:03][D][text_sensor:064]: 'ant-bms charge mosfet status': Sending state 'Offline'
[14:41:03][D][text_sensor:064]: 'ant-bms balancer status': Sending state 'Offline'
[14:41:03][D][text_sensor:064]: 'ant-bms total runtime formatted': Sending state 'Offline'
[14:41:03][D][sensor:093]: 'ant-bms battery strings': Sending state nan with 0 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms current': Sending state nan A with 1 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms soc': Sending state nan % with 0 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms total battery capacity setting': Sending state nan Ah with 2 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms capacity remaining': Sending state nan Ah with 2 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms battery cycle capacity': Sending state nan Ah with 2 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms total voltage': Sending state nan V with 2 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms total runtime': Sending state nan s with 0 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms average cell voltage': Sending state nan V with 2 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms power': Sending state nan W with 2 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms min cell voltage': Sending state nan V with 3 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms max cell voltage': Sending state nan V with 3 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms min voltage cell': Sending state nan with 0 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms max voltage cell': Sending state nan with 0 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms charge mosfet status code': Sending state nan with 0 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms discharge mosfet status code': Sending state nan with 0 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms balancer status code': Sending state nan with 0 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms temperature 1': Sending state nan °C with 0 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms temperature 2': Sending state nan °C with 0 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms temperature 3': Sending state nan °C with 0 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms temperature 4': Sending state nan °C with 0 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms cell voltage 1': Sending state nan V with 3 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms cell voltage 2': Sending state nan V with 3 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms cell voltage 3': Sending state nan V with 3 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms cell voltage 4': Sending state nan V with 3 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms cell voltage 5': Sending state nan V with 3 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms cell voltage 6': Sending state nan V with 3 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms cell voltage 7': Sending state nan V with 3 decimals of accuracy
[14:41:03][D][sensor:093]: 'ant-bms cell voltage 8': Sending state nan V with 3 decimals of accuracy
I soldered to pins inside the display.
I also tried flashing with 4 and 5 pin vice versa.
Anyway I get nan instead of values.
What information should I provide additionally?
Thanks!
$ ls -l AntBMS20210525
total 12340
-rw-r--r-- 1 user user 1434 Nov 27 2020 App.config
-rw-r--r-- 1 user user 2915328 Nov 28 2020 GMap.NET.Core.dll
-rw-r--r-- 1 user user 146944 Nov 28 2020 GMap.NET.WindowsForms.dll
-rw-r--r-- 1 user user 36769 Nov 28 2020 GMap.NET.WindowsForms.xml
-rw-r--r-- 1 user user 53760 Nov 28 2020 GMap.NET.WindowsPresentation.dll
drwxr-xr-x 2 user user 4096 May 25 2021 Languages
-rw-r--r-- 1 user user 19456 Sep 16 2020 LiveCharts.WinForms.dll
-rw-r--r-- 1 user user 217600 Sep 16 2020 LiveCharts.Wpf.dll
-rw-r--r-- 1 user user 152064 Sep 16 2020 LiveCharts.dll
-rw-r--r-- 1 user user 1817 May 25 2021 MaYiSystem.application
-rw-r--r-- 1 user user 1467904 May 25 2021 MaYiSystem.exe
-rw-r--r-- 1 user user 1434 Nov 27 2020 MaYiSystem.exe.config
-rw-r--r-- 1 user user 12808 May 25 2021 MaYiSystem.exe.manifest
-rw-r--r-- 1 user user 1125888 May 25 2021 MaYiSystem.pdb
-rw-r--r-- 1 user user 544768 Oct 27 2018 NPOI.OOXML.dll
-rw-r--r-- 1 user user 91648 Oct 27 2018 NPOI.OpenXml4Net.dll
-rw-r--r-- 1 user user 2128384 Oct 27 2018 NPOI.OpenXmlFormats.dll
-rw-r--r-- 1 user user 1679360 Oct 27 2018 NPOI.dll
-rw-r--r-- 1 user user 333312 May 19 2017 Newtonsoft.Json.dll
-rw-r--r-- 1 user user 146432 Jan 5 2021 SunnyUI.Common.dll
-rw-r--r-- 1 user user 1515520 Jan 5 2021 SunnyUI.dll
drwxr-xr-x 2 user user 4096 May 25 2021 app.publish
Virtualbox -> Windows 7 -> Serial interfaces -> Port 1
$ socat -x -d unix-connect:/tmp/ttydummy -
7e a1 01 00 00 be 18 55 aa 55
~��▒U�U> 2022/02/26 19:52:29.162023 length=10 from=312 to=321
7e a1 01 00 00 be 18 55 aa 55
~��▒U�U> 2022/02/26 19:52:31.162328 length=10 from=322 to=331
7e a1 01 00 00 be 18 55 aa 55
~��▒U�U> 2022/02/26 19:52:33.164344 length=10 from=332 to=341
7e a1 01 00 00 be 18 55 aa 55
~��▒U�U> 2022/02/26 19:52:35.165082 length=10 from=342 to=351
Send some returns to trigger the connected state at the windows application.
Tab | Button | Request payload of the MaYiSystem.exe | Count |
---|---|---|---|
Port | OpenPort | 7e a1 04 00 00 0c 98 ec aa 55 7e a1 01 00 00 be 18 55 aa 55 |
once |
Port | Level5 "123456789abc" | 7e a1 23 6a 01 0c 31 32 33 34 35 36 37 38 39 61 62 63 20 62 aa 55 |
once |
SystemInfo | 7e a1 05 00 00 28 99 0b aa 55 7e a1 02 06 01 20 78 28 aa 55 7e a1 04 00 00 0c 98 ec aa 55 7e a1 02 6c 02 20 58 c4 aa 55 7e a1 01 00 00 be 18 55 aa 55 |
once | |
State | 7e a1 01 00 00 be 18 55 aa 55 |
periodically 0.5s | |
Log | 7e a1 03 01 00 00 c8 5d aa 55 7e a1 03 02 00 00 38 5d aa 55 7e a1 03 03 00 00 69 9d aa 55 7e a1 03 04 00 00 d8 5c aa 55 7e a1 03 05 00 00 89 9c aa 55 7e a1 03 06 00 00 79 9c aa 55 7e a1 03 07 00 00 28 5c aa 55 7e a1 03 08 00 00 18 5f aa 55 7e a1 03 09 00 00 49 9f aa 55 7e a1 03 0a 00 00 b9 9f aa 55 |
once, 1sec gap between requests | |
GPRS | 7e a1 06 00 00 6c 99 7c aa 55 |
periodically 1s | |
Control | Discharge mosfet off | 7e a1 51 01 00 00 d8 e5 aa 55 |
once |
Control | Discharge mosfet on | 7e a1 51 03 00 00 79 25 aa 55 |
once |
Control | Charge mosfet off | 7e a1 51 04 00 00 c8 e4 aa 55 |
once |
Control | Charge mosfet on | 7e a1 51 06 00 00 69 24 aa 55 |
once |
Control | TiLion | 7e a1 51 26 00 00 68 ee aa 55 |
once |
Control | Lion | 7e a1 51 27 00 00 39 2e aa 55 |
once |
Control | Iron Lithium Parameters | 7e a1 51 28 00 00 09 2d aa 55 |
once |
Control | UserPareme | 7e a1 51 2d 00 00 19 2c aa 55 |
once |
Control | Factory reset | 7e a1 51 0c 00 00 49 26 aa 55 |
once |
Control | Reset hardware | 7e a1 51 2a 00 00 a8 ed aa 55 |
once |
Control | Save Apply | 7e a1 51 07 00 00 38 e4 aa 55 |
once |
Control | Current Zero | 7e a1 51 08 00 00 08 e7 aa 55 |
once |
Control | Restart | 7e a1 51 09 00 00 59 27 aa 55 |
once |
Control | Shutdown | 7e a1 51 0b 00 00 f8 e7 aa 55 |
once |
Control | Manual Balance On | 7e a1 51 0d 00 00 18 e6 aa 55 |
once |
Control | Manual Balance Off | 7e a1 51 0e 00 00 e8 e6 aa 55 |
once |
Control | Bluetooth on | 7e a1 51 1d 00 00 19 23 aa 55 |
once |
Control | Bluetooth off | 7e a1 51 1c 00 00 48 e3 aa 55 |
once |
Control | Buzzer on | 7e a1 51 1e 00 00 e9 23 aa 55 |
once |
Control | Buzzer off | 7e a1 51 1f 00 00 b8 e3 aa 55 |
once |
Control | Save Customer Data | 7e a1 51 2c 00 00 48 ec aa 55 |
once |
Control | Clear System Log | 7e a1 51 0f 00 00 b9 26 aa 55 |
once |
Control | Clear Charge Time | 7e a1 51 23 00 00 78 ef aa 55 |
once |
Control | Clear Running Time | 7e a1 51 24 00 00 c9 2e aa 55 |
once |
Control | Clear Protect TIme | 7e a1 51 25 00 00 98 ee aa 55 |
once |
Control | Bluetooth initialization | 7e a1 51 10 00 00 88 e0 aa 55 |
once |
Control | Clear Discharge Cycle Ah | 7e a1 51 20 00 00 88 ef aa 55 |
once |
Control | Clear Charge Cycle Ah | 7e a1 51 21 00 00 d9 2f aa 55 |
once |
Control | Clear Discharge Time | 7e a1 51 22 00 00 29 2f aa 55 |
once |
State | Charging off | 7e a1 51 04 00 00 c8 e4 aa 55 |
once |
State | Charging on | 7e a1 51 06 00 00 69 24 aa 55 |
once |
State | Discharging off | 7e a1 51 01 00 00 d8 e5 aa 55 |
once |
State | Discharging on | 7e a1 51 03 00 00 79 25 aa 55 |
once |
State | Balancer on | 7e a1 51 0d 00 00 18 e6 aa 55 |
once |
State | Balancer off | 7e a1 51 0e 00 00 e8 e6 aa 55 |
once |
Config Parameter | Ternary parameter | 7e a1 51 27 00 00 39 2e aa 55 |
once |
Config Parameter | Iron Lithium parameters | 7e a1 51 28 00 00 09 2d aa 55 |
once |
Config Parameter | Save application parameters | 7e a1 51 07 00 00 38 e4 aa 55 |
once |
Config Parameter | Level 5 auth check "123456789abc" | 7e a1 23 6a 01 0c 31 32 33 34 35 36 37 38 39 61 62 63 20 62 aa 55 |
once |
I am also trying to decode the new protocol. Would you mind sharing the PC application?
Hello. Im pretty new to antbms and looking for help! I got all working but i dont know how all happen but the auth. locked me out. Regardless how i wrote the 123456789abc or whatever it gave me error as it was wrong. This would be in android app and even on pc. Now i do believe the fw got messed up. Is there away to install fw again and how to do or where to download? Thanks
@lucasimons I've pushed a skeleton of a new custom component to this repository. Could you assemble a test setup using esp32-example.yaml
and attach your BMS? This implementation sends the following message/request periodically to the BMS:
[21:21:44][D][uart_debug:114]: >>> 5A:5A:00:00:01:01
The BMS should respond with <<<
. Could you collect and provide some responses? I will add a response parser later on.
there is some issue with the power sensor with 2021 bms version, i see in the app -144w instead the Home Assistant sensor show 9999w
logs_ant-bms_logs.txt
// 108 0x00 0x17: Number of pulses per week # meaning!?
// 110 0x01: Relay switch
// 132 0x00 0x00 0x00 0x00: Battery is in balance bitmask (Bit 1 = Cell 1, Bit 2 = Cell 2, ...)
// 136 0x11 0x62: System log / overall status bitmask?
// 106 0x03 0xE8: Tire length mm
// 124 0x00 0x00: Discharge MOSFET, voltage between D-S 0.1 V
// 126 0x00 0x73: Drive voltage (discharge MOSFET) 0.1 V
// 128 0x00 0x6F: Drive voltage (charge MOSFET) 0.1 V
// 130 0x02 0xA7: When the detected current is 0, the initial value of the comparator
// 87 0x00 0x08 0x57 0x20: Uptime in seconds 546.592 s / 3600 = 151.83 h s
// 115 0x0D: Cell with the highest voltage Cell 13
// 118 0x09: Cell with the lowest voltage Cell 9
Hi!
I have an installation where there are 2x 32s ant bms, and both connected in series a bit 64s). they are in constant charge at around 3.4v per cell (installed on an UPS - The ups mantain the voltage at around 216.7v at the end of the 64 cells).
The voltage from the start was quite well matched (around 108v per bms.), but now is diverging a bit. I have one bms at 106.9v, and the other one at 109.8v. The balancers are configured to mantain the cell matched. of both the bms.
I'm tempted to set an automation to force a balance with impossible parameters (for example 1mv per cell of max difference) on the bms with more voltage, so that i can try to match better the voltages of the 2 sets.
Is there a way to set some parameters of the BMS via the ESP?
Thanks!
Tab | Button | Request payload of the MaYiSystem.exe | Count |
---|---|---|---|
Control | Factory reset | 7e a1 51 0c 00 00 49 26 aa 55 |
once |
Control | Reset hardware | 7e a1 51 2a 00 00 a8 ed aa 55 |
once |
Control | Current Zero | 7e a1 51 08 00 00 08 e7 aa 55 |
once |
Control | Restart | 7e a1 51 09 00 00 59 27 aa 55 |
once |
Control | Shutdown | 7e a1 51 0b 00 00 f8 e7 aa 55 |
once |
Control | Save Customer Data | 7e a1 51 2c 00 00 48 ec aa 55 |
once |
Control | Clear System Log | 7e a1 51 0f 00 00 b9 26 aa 55 |
once |
Control | Clear Charge Time | 7e a1 51 23 00 00 78 ef aa 55 |
once |
Control | Clear Running Time | 7e a1 51 24 00 00 c9 2e aa 55 |
once |
Control | Clear Protect Time | 7e a1 51 25 00 00 98 ee aa 55 |
once |
Control | Bluetooth initialization | 7e a1 51 10 00 00 88 e0 aa 55 |
once |
Control | Clear Discharge Cycle Ah | 7e a1 51 20 00 00 88 ef aa 55 |
once |
Control | Clear Charge Cycle Ah | 7e a1 51 21 00 00 d9 2f aa 55 |
once |
Control | Clear Discharge Time | 7e a1 51 22 00 00 29 2f aa 55 |
once |
Tab | Button | Request payload of the MaYiSystem.exe | Count |
---|---|---|---|
Control | Bluetooth on | 7e a1 51 1d 00 00 19 23 aa 55 |
once |
Control | Bluetooth off | 7e a1 51 1c 00 00 48 e3 aa 55 |
once |
Control | Buzzer on | 7e a1 51 1e 00 00 e9 23 aa 55 |
once |
Control | Buzzer off | 7e a1 51 1f 00 00 b8 e3 aa 55 |
once |
Hello, is there a possibility to adapt it to use in the old ANT-BMS, Bluetooth version? Thank you
# name(address, desc, format, ratio, unit),
SingleOverWarningVoltage(1, "单体过压警告", 0.001d, "%.3f", "V"),
SingleUnderWarningVoltage(2, "单体欠压警告", 0.001d, "%.3f", "V"),
SingleOverProtectVoltage(3, "单体过压保护", 0.001d, "%.3f", "V"),
SingleUnderProtectVoltage(4, "单体欠压保护", 0.001d, "%.3f", "V"),
SingleOverVoltageRestore(5, "单体过压恢复", 0.001d, "%.3f", "V"),
SingleUnderVoltageRestore(6, "单体欠压恢复", 0.001d, "%.3f", "V"),
TotalOverProtectVoltage(7, "总体过压保护", 0.1d, "%.1f", "V"),
TotalUnderProtectVoltage(8, "总体欠压保护", 0.1d, "%.1f", "V"),
ChargeOverCurrentProtect(9, "充电过流保护", 0.1d, "%.1f", "A"),
ChargeOverCurrentProtectDelay(10, "充电过流保护延时", 1.0d, "%.1f", "秒"),
DischargeOverCurrentProtect(11, "放电过流保护", 0.1d, "%.1f", "A"),
DischargeOverCurrentProtectDelay(12, "放电过流保护延时", 1.0d, "%.1f", "秒"),
BalanceExtremeVoltage(13, "均衡极限电压", 0.001d, "%.3f", "V"),
BalanceControlVoltage(14, "均衡开启电压", 0.001d, "%.3f", "V"),
BalanceVoltageDifferential(15, "均衡开启压差", 0.001d, "%.3f", "V"),
BalanceCurrent(16, "均衡电流", 10.0d, "%.0f", "mA"),
SystemBaseVoltage(17, "系统基准电压", 0.001d, "%.3f", "V"),
CurrentSensorRange(18, "电流传感器量程", 0.1d, "%.1f", "A"),
LaunchCurrent(19, "功率启动电流", 1.0d, "%.0f", "A"),
ShortedPretectCurrent(20, "短路保护电流", 1.0d, "%.0f", "A"),
ShortedPretectDelay(21, "短路保护延时", 1.0d, "%.0f", "us"),
NoCurrentAutoStandbyTime(22, "自动待机时间", 1.0d, "%.0f", "us"),
TotoalAd2RealVoltage(23, "总压调节参数", 1.0d, "%.0f", ""),
BatterySerialNumber(24, "电池串数", 1.0d, "%.0f", "S"),
BatteryOverTemperatureChargeProtect(25, "充电高温保护", 1.0d, "%.0f", "℃"),
BatteryOverTemperatureChargeRestore(26, "充电高温恢复", 1.0d, "%.0f", "℃"),
BatteryOverTemperatureDischargeProtect(27, "放电高温保护", 1.0d, "%.0f", "℃"),
BatteryOverTemperatureDischargeRestore(28, "放电高温恢复", 1.0d, "%.0f", "℃"),
PowertubeOverTemperatureProtect(29, "功率高温保护", 1.0d, "%.0f", "℃"),
PowertubeOverTemperatureRestore(30, "功率高温恢复", 1.0d, "%.0f", "℃"),
BatteryLowCapacity(31, "电池物理容量", 1.0E-6d, "%.3f", "AH"),
BatteryHighCapacity(32, "电池高字节容量", 1.0E-6d, "%.3f", "AH"),
BatteryLeftCapacity(33, "电池剩余容量", 0.001d, "%.3f", "AH"),
BatteryLeftHighBitCapacity(34, "剩余容量高位字节", 0.001d, "%.3f", "AH"),
BatteryTotalCycleCapacity(35, "电池总循环容量", 0.001d, "%.3f", "AH"),
BatteryTotalCycleHighBitCapacity(36, "电池循环容量高位字节", 0.001d, "%.3f", "AH"),
ChargeLowTemperatureProtect(37, "充电低温保护", 1.0d, "%.0f", "℃"),
ChargeLowTemperatureRestore(38, "充电低温恢复", 1.0d, "%.0f", "℃"),
DisChargeLowTemperatureProtect(39, "放电低温保护", 1.0d, "%.0f", "℃"),
DisChargeLowTemperatureRestore(40, "放电低温恢复", 1.0d, "%.0f", "℃"),
TireLength(41, "一周轮胎长度", 1.0d, "%.0f", "mm"),
PauseLength(42, "一周脉冲次数", 1.0d, "%.0f", ""),
AutoShutdownVoltage(43, "自动关机电压", 0.001d, "%.3f", "V"),
SingleDiffVoltageProtect(44, "单体压差保护", 0.001d, "%.3f", "V"),
SlaveNumber(45, "从机模块数", 1.0d, "%.0f", ""),
UnderVoltageComplete(46, "欠压内阻补偿", 0.1d, "%.1f", "mΩ"),
StaticCurrent(47, "静态消耗电流", 0.1d, "%.1f", "mA"),
SensorTemperatureMask(48, "温度传感器屏蔽", 1.0d, "%.0f", ""),
BluetoothAddress(49, "蓝牙地址", 1.0d, "%.0f", ""),
HardwareVersion(90, "固件版本号", 1.0d, "%.0f", ""),
RunningTime(100, "运行时间", 1.0d, "%.0f", ""),
SecondDischargeOverCurrentProtect(162, "二级放电过流保护", 0.1d, "%.0f", "A"),
SecondDischargeOverCurrentProtectDelay(163, "二级放电延时", 1.0d, "%.0f", "us"),
IronLithium(251, "铁锂参数", 1.0d, "%.0f", "N"),
TernaryParameter(Callback.DEFAULT_SWIPE_ANIMATION_DURATION, "三元参数", 1.0d, "%.0f", "V"),
LithiumTitanate(240, "钛酸锂参数", 1.0d, "%.0f", "A"),
FirstSoc(150, "初始SOC", 1.0d, "%.0f", ""),
PasswordCheck(245, "密码校验", 1.0d, "%.0f", ""),
FactorySerialNo(255, "出厂序列号", 1.0d, "%.0f", ""),
SocUnderLimit(255, "SOC过低告警", 1.0d, "%.0f", ""),
DefaultType(255, "", 1.0d, "%.0f", "");
https://github.com/klotztech/VBMS/wiki/Serial-protocol#parameter-addresses
Hi
i have a 2019 version ant bms. İ try install your code in my esp32. But no connection. İ attach log.
logs_powerwall-bms_run.txt
my code
substitutions:
name: powerwall-bms
device_description: "Monitor and control a ANT Battery Management System (ANT-BMS) via BLE"
external_components_source: github://syssi/esphome-ant-bms@main
mac_address: aa:bb:cc:92:23:45
esphome:
name: powerwall-bms
platform: ESP32
board: esp32dev
platformio_options:
platform: espressif32
board: az-delivery-devkit-v4
board_build.mcu: esp32
board_build.f_cpu: 240000000L
project:
name: "syssi.esphome-ant-bms"
version: 2.0.0
external_components:
- source: ${external_components_source}
refresh: 5s
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ota:
password:
logger:
# If you use Home Assistant please remove this `mqtt` section and uncomment the native `api` component!
api:
encryption:
key:
# mqtt:
# broker: !secret mqtt_host
# username: !secret mqtt_username
# password: !secret mqtt_password
# id: mqtt_client
esp32_ble_tracker:
on_ble_advertise:
then:
- lambda: |-
if (x.get_name().rfind("ANT-", 0) == 0) {
ESP_LOGI("ble_adv", "New ANT-BMS found");
ESP_LOGI("ble_adv", " Name: %s", x.get_name().c_str());
ESP_LOGI("ble_adv", " MAC address: %s", x.address_str().c_str());
ESP_LOGD("ble_adv", " Advertised service UUIDs:");
for (auto uuid : x.get_service_uuids()) {
ESP_LOGD("ble_adv", " - %s", uuid.to_string().c_str());
}
}
ble_client:
- id: client0
mac_address: ${mac_address}
ant_bms_ble:
- id: bms0
ble_client_id: client0
update_interval: 5s
binary_sensor:
- platform: ant_bms_ble
ant_bms_ble_id: bms0
online_status:
name: "${name} online status"
sensor:
- platform: ant_bms_ble
ant_bms_ble_id: bms0
battery_strings:
name: "${name} battery strings"
current:
name: "${name} current"
soc:
name: "${name} soc"
total_battery_capacity_setting:
name: "${name} total battery capacity setting"
capacity_remaining:
name: "${name} capacity remaining"
battery_cycle_capacity:
name: "${name} battery cycle capacity"
total_voltage:
name: "${name} total voltage"
total_runtime:
name: "${name} total runtime"
average_cell_voltage:
name: "${name} average cell voltage"
power:
name: "${name} power"
min_cell_voltage:
name: "${name} min cell voltage"
max_cell_voltage:
name: "${name} max cell voltage"
min_voltage_cell:
name: "${name} min voltage cell"
max_voltage_cell:
name: "${name} max voltage cell"
temperature_1:
name: "${name} temperature 1"
temperature_2:
name: "${name} temperature 2"
temperature_3:
name: "${name} temperature 3"
temperature_4:
name: "${name} temperature 4"
temperature_5:
name: "${name} temperature 5"
temperature_6:
name: "${name} temperature 6"
cell_voltage_1:
name: "${name} cell voltage 1"
cell_voltage_2:
name: "${name} cell voltage 2"
cell_voltage_3:
name: "${name} cell voltage 3"
cell_voltage_4:
name: "${name} cell voltage 4"
cell_voltage_5:
name: "${name} cell voltage 5"
cell_voltage_6:
name: "${name} cell voltage 6"
cell_voltage_7:
name: "${name} cell voltage 7"
cell_voltage_8:
name: "${name} cell voltage 8"
cell_voltage_9:
name: "${name} cell voltage 9"
cell_voltage_10:
name: "${name} cell voltage 10"
cell_voltage_11:
name: "${name} cell voltage 11"
cell_voltage_12:
name: "${name} cell voltage 12"
cell_voltage_13:
name: "${name} cell voltage 13"
cell_voltage_14:
name: "${name} cell voltage 14"
charge_mosfet_status_code:
name: "${name} charge mosfet status code"
discharge_mosfet_status_code:
name: "${name} discharge mosfet status code"
balancer_status_code:
name: "${name} balancer status code"
text_sensor:
- platform: ant_bms_ble
ant_bms_ble_id: bms0
charge_mosfet_status:
name: "${name} charge mosfet status"
discharge_mosfet_status:
name: "${name} discharge mosfet status"
balancer_status:
name: "${name} balancer status"
total_runtime_formatted:
name: "${name} total runtime formatted"
device_model:
name: "${name} device model"
software_version:
name: "${name} software version"
switch:
- platform: ant_bms_ble
ant_bms_ble_id: bms0
charging:
name: "${name} charging"
discharging:
name: "${name} discharging"
balancer:
name: "${name} balancer"
buzzer:
name: "${name} buzzer"
button:
- platform: ant_bms_ble
ant_bms_ble_id: bms0
shutdown:
name: "${name} shutdown"
clear_system_log:
name: "${name} clear system log"
factory_reset:
name: "${name} factory reset"
restart:
name: "${name} restart"
Quick start guide:
mac_address
substitution to the MAC address of your device. The MAC address should be reported at the ESPHome log:
[ble_adv] New ANT-BMS found
[ble_adv] Name: ...
[ble_adv] MAC address: AA:BB:CC:DD:EE:FF
[ble_adv] Advertised service UUIDs: ...
mqtt
and remove the api
component if you want to use MQTT instead of the native API.Please round up to 3 decimal places in average cell voltage.
The application on the phone is rounded up to 3 characters, and you have up to 2 characters.
# 0xF7 Shutdown the BMS
# 0xF8 Current zeroing?
# 0xFD Factory default
# 0xFE Reboot button
# 0xFF Apply button
Possible data value: 0x00
this is my config
esphome:
name: sottoscala
platform: ESP8266
board: nodemcuv2
external_components:
- source: github://syssi/esphome-ant-bms@main
refresh: 0s
- source: github://andreashergert1984/esphome@test_newcrc
refresh: 0s
components: [pipsolar]
# Enable logging
logger:
baud_rate: 0
# Enable Home Assistant API
api:
captive_portal:
uart:
- id: uart0
baud_rate: 19200
rx_buffer_size: 384
tx_pin: GPIO1
rx_pin: GPIO3
debug:
direction: BOTH
ant_modbus:
id: modbus0
uart_id: uart0
ant_bms:
id: bms0
ant_modbus_id: modbus0
password: "12345678"
update_interval: 10s
supports_new_commands: false
sensor:
- platform: ant_bms
current:
name: "bms1 current"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
soc:
name: "bms1 soc"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
capacity_remaining:
name: "bms1 capacity remaining"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
battery_cycle_capacity:
name: "bms1 battery cycle capacity"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
total_voltage:
name: "bms1 total voltage"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
total_runtime:
name: "bms1 total runtime"
average_cell_voltage:
name: "bms1 average cell voltage"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
power:
name: "bms1 power"
min_cell_voltage:
name: "bms1 min cell voltage"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
max_cell_voltage:
name: "bms1 max cell voltage"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
min_voltage_cell:
name: "bms1 min voltage cell"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
max_voltage_cell:
name: "bms1 max voltage cell"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
temperature_1:
name: "bms1 temperature 1"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
temperature_2:
name: "bms1 temperature 2"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
temperature_3:
name: "bms1 temperature 3"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
temperature_4:
name: "bms1 temperature 4"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
cell_voltage_1:
name: "bms1 cell voltage 1"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
cell_voltage_2:
name: "bms1 cell voltage 2"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
cell_voltage_3:
name: "bms1 cell voltage 3"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
cell_voltage_4:
name: "bms1 cell voltage 4"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
cell_voltage_5:
name: "bms1 cell voltage 5"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
cell_voltage_6:
name: "bms1 cell voltage 6"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
cell_voltage_7:
name: "bms1 cell voltage 7"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
cell_voltage_8:
name: "bms1 cell voltage 8"
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
charge_mosfet_status_code:
name: "bms1 charge mosfet status code"
discharge_mosfet_status_code:
name: "bms1 discharge mosfet status code"
balancer_status_code:
name: "bms1 balancer status code"
- platform: uptime
name: "Ant Uptime"
id: uptime_s
update_interval: 5s
text_sensor:
- platform: ant_bms
charge_mosfet_status:
name: "bms1 charge mosfet status"
discharge_mosfet_status:
name: "bms1 discharge mosfet status"
balancer_status:
name: "bms1 balancer status"
total_runtime_formatted:
name: "bms1 total runtime formatted"
button:
- platform: ant_bms
balancer:
name: "bms1 balancer"
Hi @syssi,
I tried both the old and ant_bms platform without success. I got an old custom components working with : https://pastebin.com/0bBPx33L
Maybe you can see the difference with your current implementations ....
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.