syssi / esphome-seplos-bms

ESPHome component to monitor a Seplos Battery Management System (Seplos-BMS) via UART or RS485
Apache License 2.0
61 stars 27 forks source link

Decoding RichPower BMS073 protocol #87

Open clowrey opened 5 months ago

clowrey commented 5 months ago

This BMS seems to use a very similar protocol to the Seplos, as this project is able to decode some of the data already when I connect it in parallel with the other batteries RS485 (it needs a different read command which this code does not send by default) But it can decode most of the data when it is received.

Battery not connected currently so current showing zero is fine. The battery SOC did not display yet.

I tried updating the protocol to 80 which shows it outputting "~80004642E00200FD31\r" which is farily close to the command coming from the master battery that produces the mostly decodable data "~8000D542E00201FD21\r"

That is the data for the battery 1 the slave battery. The master battery is probably just not requesting data of itself I suppose..

I will try to hack on it more later ran out of time. Any hints appreciated.

[11:47:29][D][uart_debug:158]: >>> "~80004642E00200FD31\r"
[11:47:29][D][uart_debug:158]: <<< "~8000D542E00201FD21\r"
[11:47:29][W][seplos_bms:022]: Unhandled data received (data_len: 0x02): 80.00.D5.42.E0.02.01 (7)
[11:47:29][D][uart_debug:158]: <<< "~8000D500B07E0001100CE10CE00CE00CDF0CE00CE00CE00CE00CDF0CE00CE00CE00CE00CE10CE00CDF060B750B760B770B750B920B8C0000149A2BA2046D600000000003E8E1B9\r"
[11:47:29][I][seplos_bms:030]: Telemetry frame (69 bytes) received
[11:47:29][V][seplos_bms:048]: Command group: 1
[11:47:29][V][seplos_bms:052]: Number of cells: 16
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 1': Received new state 3.297000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 1': Sending state 3.29700 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 2': Received new state 3.296000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 2': Sending state 3.29600 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 3': Received new state 3.296000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 3': Sending state 3.29600 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 4': Received new state 3.295000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 4': Sending state 3.29500 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 5': Received new state 3.296000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 5': Sending state 3.29600 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 6': Received new state 3.296000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 6': Sending state 3.29600 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 7': Received new state 3.296000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 7': Sending state 3.29600 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 8': Received new state 3.296000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 8': Sending state 3.29600 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 9': Received new state 3.295000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 9': Sending state 3.29500 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 10': Received new state 3.296000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 10': Sending state 3.29600 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 11': Received new state 3.296000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 11': Sending state 3.29600 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 12': Received new state 3.296000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 12': Sending state 3.29600 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 13': Received new state 3.296000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 13': Sending state 3.29600 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 14': Received new state 3.297000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 14': Sending state 3.29700 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 15': Received new state 3.296000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 15': Sending state 3.29600 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 cell voltage 16': Received new state 3.295000
[11:47:29][D][sensor:094]: 'seplos-bms-2 cell voltage 16': Sending state 3.29500 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 min cell voltage': Received new state 3.295000
[11:47:29][D][sensor:094]: 'seplos-bms-2 min cell voltage': Sending state 3.29500 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 max cell voltage': Received new state 3.297000
[11:47:29][D][sensor:094]: 'seplos-bms-2 max cell voltage': Sending state 3.29700 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 max voltage cell': Received new state 1.000000
[11:47:29][D][sensor:094]: 'seplos-bms-2 max voltage cell': Sending state 1.00000  with 0 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 min voltage cell': Received new state 4.000000
[11:47:29][D][sensor:094]: 'seplos-bms-2 min voltage cell': Sending state 4.00000  with 0 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 delta cell voltage': Received new state 0.002000
[11:47:29][D][sensor:094]: 'seplos-bms-2 delta cell voltage': Sending state 0.00200 V with 3 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 average cell voltage': Received new state 3.295938
[11:47:29][D][sensor:094]: 'seplos-bms-2 average cell voltage': Sending state 3.29594 V with 3 decimals of accuracy
[11:47:29][V][seplos_bms:088]: Number of temperature sensors: 6
[11:47:29][V][sensor:043]: 'seplos-bms-2 temperature 1': Received new state 20.200001
[11:47:29][D][sensor:094]: 'seplos-bms-2 temperature 1': Sending state 20.20000 °C with 0 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 temperature 2': Received new state 20.300001
[11:47:29][D][sensor:094]: 'seplos-bms-2 temperature 2': Sending state 20.30000 °C with 0 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 temperature 3': Received new state 20.400000
[11:47:29][D][sensor:094]: 'seplos-bms-2 temperature 3': Sending state 20.40000 °C with 0 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 temperature 4': Received new state 20.200001
[11:47:29][D][sensor:094]: 'seplos-bms-2 temperature 4': Sending state 20.20000 °C with 0 decimals of accuracy
[11:47:29][V][sensor:043]: 'seplos-bms-2 environment temperature': Received new state 23.100000
[11:47:29][D][sensor:094]: 'seplos-bms-2 environment temperature': Sending state 23.10000 °C with 0 decimals of accuracy
[11:47:30][V][sensor:043]: 'seplos-bms-2 mosfet temperature': Received new state 22.500000
[11:47:30][D][sensor:094]: 'seplos-bms-2 mosfet temperature': Sending state 22.50000 °C with 0 decimals of accuracy
[11:47:30][V][sensor:043]: 'seplos-bms-2 current': Received new state 0.000000
[11:47:30][D][sensor:094]: 'seplos-bms-2 current': Sending state 0.00000 A with 2 decimals of accuracy
[11:47:30][V][sensor:043]: 'seplos-bms-2 total voltage': Received new state 52.739998
[11:47:30][D][sensor:094]: 'seplos-bms-2 total voltage': Sending state 52.74000 V with 2 decimals of accuracy
[11:47:30][V][sensor:043]: 'seplos-bms-2 power': Received new state 0.000000
[11:47:30][D][sensor:094]: 'seplos-bms-2 power': Sending state 0.00000 W with 2 decimals of accuracy
[11:47:30][V][sensor:043]: 'seplos-bms-2 charging power': Received new state 0.000000
[11:47:30][D][sensor:094]: 'seplos-bms-2 charging power': Sending state 0.00000 W with 2 decimals of accuracy
[11:47:30][V][sensor:043]: 'seplos-bms-2 discharging power': Received new state 0.000000
[11:47:30][D][sensor:094]: 'seplos-bms-2 discharging power': Sending state 0.00000 W with 2 decimals of accuracy
[11:47:30][V][sensor:043]: 'seplos-bms-2 residual capacity': Received new state 111.699997
[11:47:30][D][sensor:094]: 'seplos-bms-2 residual capacity': Sending state 111.70000 Ah with 2 decimals of accuracy
[11:47:30][V][sensor:043]: 'seplos-bms-2 battery capacity': Received new state 280.000000
[11:47:30][D][sensor:094]: 'seplos-bms-2 battery capacity': Sending state 280.00000 Ah with 2 decimals of accuracy
[11:47:30][V][sensor:043]: 'seplos-bms-2 state of charge': Received new state 0.000000
[11:47:30][D][sensor:094]: 'seplos-bms-2 state of charge': Sending state 0.00000 % with 1 decimals of accuracy
[11:47:30][V][sensor:043]: 'seplos-bms-2 rated capacity': Received new state 0.000000
[11:47:30][D][sensor:094]: 'seplos-bms-2 rated capacity': Sending state 0.00000 Ah with 2 decimals of accuracy
[11:47:30][V][sensor:043]: 'seplos-bms-2 charging cycles': Received new state 1000.000000
[11:47:30][D][sensor:094]: 'seplos-bms-2 charging cycles': Sending state 1000.00000  with 0 decimals of accuracy
clowrey commented 5 months ago

I made a simple change to get the request accepted by the BMS!

In the seplos_modbus.cpp line 158

data.push_back(0x46);              // CID1
data.push_back(0xD5);              // CID1  was 0x46

Then I started hacking up the seplos_modbus.cpp file to get the last bits of data.. This BMS does not output a SOC - you have to calculate it based on the residual_capacity / rated_capacity - But its now working!!

You can see the changes I have made in my fork here: https://github.com/clowrey/esphome-seplos-bms/blob/main/components/seplos_bms/seplos_bms.cpp

I need to clean it up and update the comments which are still from the old data types.. not sure how or if these changes would be pushed back to origin. I am open to suggestions, just trying to get mine working currently, obviously current method breaks things for the other batteries.