tertiuscpt Posted September 10, 2022 Share Posted September 10, 2022 (edited) (Updated info further down in the post) I create a very simple Python script to interrogate the Pace BMS as used in some popular lithium battery brands. I've also packed this as a Home Assistant add-on, but can just as well be used as either a standalone script / within a docker container. It reports the voltage of cells, temperatures, the pack's current, voltage, SOC, SOH, and a few other metrics. Use at own risk. Either a serial link to the RS232 port or via IP (using some port server over TCP) will work. Repository: https://github.com/Tertiush/bmspace The script serves by needs atm, so any further developments can be done by the community. UPDATE: I've rewritten most of this script using the official PACE RS232 Protocol definition. The script now supports multiple packs! I've only implemented informational messages / retrieving data, no commands. Use at own risk! Many new fields are now retrieved such as warnings, balancing data, status indications, etc. Edited July 27, 2023 by tertiuscpt Updated info Iiceman, lcj, jumper and 7 others 10 Quote Link to comment Share on other sites More sharing options...
reapster Posted November 23, 2022 Share Posted November 23, 2022 Heya @tertiuscpt Just wanted to let you know this works great on my Revov R100 too! Can confirm the pinout is the same on the RJ11 Thanks for the project! tertiuscpt 1 Quote Link to comment Share on other sites More sharing options...
malek94 Posted December 5, 2022 Share Posted December 5, 2022 for RG 11 - rs232 Pin3:TX Pin4:RX Pin5:GND Quote Link to comment Share on other sites More sharing options...
tertiuscpt Posted February 11, 2023 Author Share Posted February 11, 2023 Quick update, I've rewritten most of this script using the official PACE RS232 Protocol definition. The script now supports multiple packs! I've only implemented informational messages / retrieving data, no commands. Use at own risk! Many new fields are now retrieved such as warnings, balancing data, status indications, etc. system32, P1000, zsde and 1 other 4 Quote Link to comment Share on other sites More sharing options...
HavocBase Posted May 5, 2023 Share Posted May 5, 2023 I will play with your Python script! May I ask you where the PACE protocol definition is to be found? Quote Link to comment Share on other sites More sharing options...
tertiuscpt Posted May 5, 2023 Author Share Posted May 5, 2023 Linked below. Another user on github shared it: https://github.com/Tertiush/bmspace/files/10372932/72651.11625-PACE-RS232commuciation-protocal.PACE-RS232-TY16S.-20180705.pdf zsde 1 Quote Link to comment Share on other sites More sharing options...
MarkV Posted May 10, 2023 Share Posted May 10, 2023 Hi Tertius, I'm getting the following error in the log after starting the addon. I've cut out the voltage info of my two AM-2 packs from the log to shorten it. After I get the error below, the addon halts, and I have to start it again. " Hello BMS Pace Starting up ... -all the voltage info of the two packs- ... Pack 2, SOH: 100.0 % Script running.... Pack Remaining Capacity: 124870 mAh Pack Full Capacity: 125000 mAh Pack Design Capacity: 125000 mAh Pack SOC: 99.9 % Pack SOH: 100.0 % Packs for warnings: 2 Pack 1, warnings: Protection State 2: Fully Pack 1, balancing1: 00000000 Pack 1, balancing2: 00000000 Error parsing BMS warning data: b'0D' Error retrieving BMS warning info: Error parsing BMS warning data: b'0D' Publishing HA Discovery topic... " I also turned on debugging 2, here's an extract of the bottom part of the log: " Pack SOC: 99.89 % Pack SOH: 100.0 % SOI: 0x7e VER: b'25' ADR: b'01' CID1 (Type): b'46' RTN: b'00' LENGTH: b'C08C' - LCHKSUM: 67 - LENID: b'08C' - LENID (int): 140 INFO: b'00020D0000000000000000000000000006000000000000000000008006000000000000010D000000000000000000000000000600000000000000000000800600000000000000' CHKSUM: b'E2ED' Calc CHKSUM: E2ED Packs for warnings: 2 Pack 1, warnings: Protection State 2: Fully Pack 1, balancing1: 00000000 Pack 1, balancing2: 00000000 Error parsing BMS warning data: b'0D' Error retrieving BMS warning info: Error parsing BMS warning data: b'0D' " Am I missing something? Quote Link to comment Share on other sites More sharing options...
tertiuscpt Posted May 12, 2023 Author Share Posted May 12, 2023 The script is reading the warnings as ASCII data, not expecting the hex 0xD character representing a carriage-return. There's small variances between some BMS' causing this, I've compensated once before for it. Please drop a full debug log at Github in the Issues for me to look at. Quote Link to comment Share on other sites More sharing options...
lcj Posted May 20, 2023 Share Posted May 20, 2023 I have a Revov R9 with what looks like a PACE BMS and tried to use the pacebms code but RS232 and RS485 is not responding when sending out serial commans. I'm not sure which port to use for USB to RS485. Quote Link to comment Share on other sites More sharing options...
tertiuscpt Posted May 20, 2023 Author Share Posted May 20, 2023 Should be the RS232 port, if there's no reply whatsoever then it's likely not a PACE BMS, or maybe the baudate is different Quote Link to comment Share on other sites More sharing options...
lcj Posted May 20, 2023 Share Posted May 20, 2023 (edited) I'm thinking it is either a PACE BMS or CAN BMS. Revov's earlier model the R100 looks very very similar. The biggest difference is the BMS is built into the battery on the R100. @tertiuscpt, I want to confirm, the BAUD is 9600 by default on bmspace software? How would I set the BAUD to say 2400 @reapster mentioned earlier in this thread the RJ11 jack of the R100 pinout, so I'm hopfull the R9 with its 6S6C type, would most propably have the middle two conductors be TXD, and RXD. Will be finding a RJ11 with 6 conductors and experimenting with it. Attached a picture of the front of a R100. Edited May 20, 2023 by lcj Quote Link to comment Share on other sites More sharing options...
tertiuscpt Posted May 20, 2023 Author Share Posted May 20, 2023 The PACE documentation requires a baud rate of 9600, as such this is hard-coded in my script. If you are using a networked serial device then you can change the baud rate on it, which the script accesses with its socket IP:Port. If you're connecting directly with serial then its not currently an optional setting. Your photo is an exact layout of the PACE BMS. Quote Link to comment Share on other sites More sharing options...
lcj Posted May 27, 2023 Share Posted May 27, 2023 @tertiuscpt, happy to report that I got it working by getting the right RJ12 connector for the RS232 port. tertiuscpt 1 Quote Link to comment Share on other sites More sharing options...
IrcI Posted July 12, 2023 Share Posted July 12, 2023 HI, I have LifePO4 Batery system called "Yechuang" from China. This system is equiped with Pace BMS..I have tried to connect this BMS to home assistant, and In log i have found this: Connection Type: IP MQTT connected with result code 0 Connecting to BMS... trying to connect 10.0.0.221:8234 BMS socket connected -> Outgoing Data: b'~250146C10000FD9A\r' <- Incoming data: b'~250146C10000FD9A\r' SOI: 0x7e VER: b'25' ADR: b'01' CID1 (Type): b'46' RTN: b'C1' LENGTH: b'0000' - LCHKSUM: 48 - LENID: b'000' - LENID (int): 0 INFO: b'' CHKSUM: b'FD9A' Calc CHKSUM: FD9A BMS Version: -> Outgoing Data: b'~250146C20000FD99\r' <- Incoming data: b'~250146C20000FD99\r' SOI: 0x7e VER: b'25' ADR: b'01' CID1 (Type): b'46' RTN: b'C2' LENGTH: b'0000' - LCHKSUM: 48 - LENID: b'000' - LENID (int): 0 INFO: b'' CHKSUM: b'FD99' Calc CHKSUM: FD99 BMS Serial Number: Pack Serial Number: -> Outgoing Data: b'~25014642E002FFFD05\r' <- Incoming data: b'~25014642E002FFFD05\r' SOI: 0x7e VER: b'25' ADR: b'01' CID1 (Type): b'46' RTN: b'42' LENGTH: b'E002' - LCHKSUM: 69 - LENID: b'002' - LENID (int): 2 INFO: b'FF' CHKSUM: b'FD05' Calc CHKSUM: FD05 Error parsing BMS analog data: invalid literal for int() with base 16: b'' Error retrieving BMS analog data: Error parsing BMS analog data: invalid literal for int() with base 16: b'' Any idea what I sholuld do ?? Thanks Quote Link to comment Share on other sites More sharing options...
tertiuscpt Posted July 14, 2023 Author Share Posted July 14, 2023 On 2023/07/12 at 8:24 PM, IrcI said: HI, I have LifePO4 Batery system called "Yechuang" from China. This system is equiped with Pace BMS..I have tried to connect this BMS to home assistant, and In log i have found this: Connection Type: IP MQTT connected with result code 0 Connecting to BMS... trying to connect 10.0.0.221:8234 BMS socket connected -> Outgoing Data: b'~250146C10000FD9A\r' <- Incoming data: b'~250146C10000FD9A\r' SOI: 0x7e VER: b'25' ADR: b'01' CID1 (Type): b'46' RTN: b'C1' LENGTH: b'0000' - LCHKSUM: 48 - LENID: b'000' - LENID (int): 0 INFO: b'' CHKSUM: b'FD9A' Calc CHKSUM: FD9A BMS Version: -> Outgoing Data: b'~250146C20000FD99\r' <- Incoming data: b'~250146C20000FD99\r' SOI: 0x7e VER: b'25' ADR: b'01' CID1 (Type): b'46' RTN: b'C2' LENGTH: b'0000' - LCHKSUM: 48 - LENID: b'000' - LENID (int): 0 INFO: b'' CHKSUM: b'FD99' Calc CHKSUM: FD99 BMS Serial Number: Pack Serial Number: -> Outgoing Data: b'~25014642E002FFFD05\r' <- Incoming data: b'~25014642E002FFFD05\r' SOI: 0x7e VER: b'25' ADR: b'01' CID1 (Type): b'46' RTN: b'42' LENGTH: b'E002' - LCHKSUM: 69 - LENID: b'002' - LENID (int): 2 INFO: b'FF' CHKSUM: b'FD05' Calc CHKSUM: FD05 Error parsing BMS analog data: invalid literal for int() with base 16: b'' Error retrieving BMS analog data: Error parsing BMS analog data: invalid literal for int() with base 16: b'' Any idea what I sholuld do ?? Thanks Seems like your Rx and Tx lines are either shorted somewhere or for some other reason you are reading back the exact commands being sent out. What does your setup look like, and how is your IP to serial converter configured? Should be in TCP Server mode Quote Link to comment Share on other sites More sharing options...
IrcI Posted July 16, 2023 Share Posted July 16, 2023 HI, Thank you for your replay.I,m now on short holiday, I will be back on friday and I chack the wiring and send you my cofiguration. Quote Link to comment Share on other sites More sharing options...
IrcI Posted July 21, 2023 Share Posted July 21, 2023 Hi, You have right...I have had bad wiring...After fixing seems to work well. I can confirm that now i it work well with BMS PACE ver: P16S100A-21265-1.03. Batteries producer: Yechuang I have 3 Pack 15KWh each. Thank you for great work and support. Quote Link to comment Share on other sites More sharing options...
Feszi Posted October 2, 2023 Share Posted October 2, 2023 Hi I have 3x Leoch lfeli-48200tb. When paraller install, maximum charge current 20A/batterypack, This is not enought my install (3x5kw inverter). Therefore i change my batterypack dip switch standalone mod. My question is, is there any way to start the program 3 times or add 3 serial ports somehow? Thanks! Quote Link to comment Share on other sites More sharing options...
XBoxBro Posted December 6, 2023 Share Posted December 6, 2023 Sorry but I am struggeling with the basics. I do have a System from Tewaycell Tewaycell 48V 200Ah 10Kwh All-in-one Mobile ESS Built-in Hybrid Invert and they provided a RS232 to USB Cable with it. They also sent the PACEexTool but its completely in Chinese. Now i found your Home Assistant integration. Can you explain a bit more how i do get the basic connection? I think i need to install the USB driver for Linux first on the Homeassistant Raspberry. Is that possible? Then i have questions for the requirements: paho_mqtt==1.6.1 PyYAML==6.0.1 pyserial==3.5 I dont know how to get the reuirements. I have Mosquito MQTT and use it already for my OpenDTU and ESP32 Quote Link to comment Share on other sites More sharing options...
DocFog Posted January 16 Share Posted January 16 Hi, @XBoxBro Did you already fix your probs? I am strandet at same point as you I also have home assistant running with mosquito as mqtt server. I manged to add "BMS Pace Interface" but do not know who to get on. The protokoll shows up with this: Hello BMS Pace Starting up... Loading options.json Config: {"mqtt_host": "10.0.0.132", "mqtt_port": 1883, "mqtt_user": "mqtt-users", "mqtt_password": "mqtt", "mqtt_ha_discovery": true, "mqtt_ha_discovery_topic": "homeassistant", "mqtt_base_topic": "bmspace", "connection_type": "Serial", "bms_ip": "10.0.0.161", "bms_port": 5000, "bms_serial": "/dev/ttyUSB0", "scan_interval": 5, "debug_output": 0} Connection Type: Serial Traceback (most recent call last): File "/workdir/./bms.py", line 75, in <module> client.connect(config['mqtt_host'], config['mqtt_port'], 60) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 914, in connect return self.reconnect() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1044, in reconnect sock = self._create_socket_connection() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source) File "/usr/local/lib/python3.9/socket.py", line 844, in create_connection raise err File "/usr/local/lib/python3.9/socket.py", line 832, in create_connection sock.connect(sa) socket.timeout: timed out I don´t even know how to get "paho_mqtt" (if I can not use mosquito) M Quote Link to comment Share on other sites More sharing options...
XBoxBro Posted March 12 Share Posted March 12 Hi @DocFog Yes i did it! TODAY My setup: Batterysystem: https://tewaycell.com/products/tewaycell-48v-200ah-10kwh-all-in-one-mobile-ess-built-in-hybrid-inverter?variant=41313098858553 Rs232to Eth: https://www.waveshare.com/wiki/RS485_TO_WIFI/ETH Installed bmspace Addon- its really JUST install the addon. NO prerequisits needed! Configured: Configured the Waveshare (with VirCom_en.exe) as follows: Afterwards the Addon could connect and i directly retrieved: Quote Pack Serial Number:xxxxxxxxxxxxxxxxx Packs: 1 Pack 1, Total cells: 16 Pack 1, V Cell1: 3281 mV Pack 1, V Cell2: 3280 mV Pack 1, V Cell3: 3281 mV Pack 1, V Cell4: 3281 mV Pack 1, V Cell5: 3281 mV Pack 1, V Cell6: 3280 mV Pack 1, V Cell7: 3280 mV Pack 1, V Cell8: 3280 mV Pack 1, V Cell9: 3280 mV Pack 1, V Cell10: 3280 mV Pack 1, V Cell11: 3279 mV Pack 1, V Cell12: 3279 mV Pack 1, V Cell13: 3279 mV Pack 1, V Cell14: 3279 mV Pack 1, V Cell15: 3279 mV Pack 1, V Cell16: 3278 mV Pack 1, Cell Max Diff Volt Calc: 3 mV Pack 1, Total temperature sensors: 6 Pack 1, Temp1: 23.7 ℃ Pack 1, Temp2: 22.0 ℃ Pack 1, Temp3: 20.3 ℃ Pack 1, Temp4: 19.5 ℃ Pack 1, Temp5: 29.8 ℃ Pack 1, Temp6: 26.4 ℃ Pack 1, I Pack: -1.17 A Pack 1, V Pack: 52.477 V Pack 1, I Remaining Capacity: 73750 mAh Pack 1, I Full Capacity: 200000 mAh Pack 1, SOC: 36.88 % Pack 1, Cycles: 15 Pack 1, Design Capacity: 190000 mAh Pack 1, SOH: 105.26 % Script running.... Pack Remaining Capacity: 73750 mAh Pack Full Capacity: 200000 mAh Pack Design Capacity: 190000 mAh Pack SOC: 36.88 % Pack SOH: 105.26 % Packs for warnings: 1 Pack 1, warnings: Pack 1, balancing1: 00000000 Pack 1, balancing2: 00000000 Publishing HA Discovery topic... Many thanks for this Addon !!!!!! Quote Link to comment Share on other sites More sharing options...
4711Austria Posted March 16 Share Posted March 16 Hi I do also have the Waveshare RS485/Lan Adapter hanging on RS485, works fine on delivering data to my ioBroker Is it possible to get the data into HA parallel to ioBroker? THx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.