Skip to content
View in the app

A better way to browse. Learn more.

Power Forum - Renewable Energy Discussion

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Reading Battery Data into ESPhome

Featured Replies

Hi Guys

I found this Github collection for connecting up ESPHome with Battery BMS's that I thought some of you guys might find useful.

I have BSL batteries so I am just trying to work out how to enable comms on the RS485 port works, I think it has to be done using PBMS Tools, anyone know? 

 

It includes repositories for:  

 

esphome-jk-bms Public

ESPHome component to monitor and control a Jikong Battery Management System (JK-BMS) via UART-TTL or BLE

 

 

esphome-basen-bms Public

ESPHome component to monitor a Basen Battery Management System via BLE

 

 

esphome-ant-bms Public

ESPHome component to monitor and control a ANT-BMS via UART

 

ESPHome component to emulate a SMA/Victron compatible BMS via CAN bus

 

esphome-jbd-bms Public

ESPHome component to monitor and control a Xiaoxiang Battery Management System (JBD-BMS) via UART-TTL or BLE

 

ESPHome component to monitor a Tianpower Battery Management System via BLE

 

ESPHome component to monitor a Seplos Battery Management System (Seplos-BMS) via UART or RS485

 

ESPHome component to monitor and control a PACE Battery Management System (PACE-BMS) via RS485 (Modbus)

  • Author

Not sure which BMS the Sunsynk's use, maybe someone else can comment.

I seem to remember some of the models BMS's no being compatible so there may be models with different models of BMS

All the inverters using PBMS tools seem to use the Pace BMS's, PBMS sort of makes sense now, lol. 

 

Been looking for documentation on the Sunsynk battery modbus implementation but so far have only found the document for the inverters. Was hoping to use the rs-485 port but might make more sense to use the CAN bus instead as the batteries are already communicating via CAN with themselves and the inverter. Was thinking of connecting a USB CAN analyser to my laptop to record the communication between the inverter and the batteries. Might get some useful information to figure it out.

Edited by Gambit

From what i can see, the SS Inverter does not pull all the battery data from the BMS.
Looking at Solar Assistant, it uses the battery RS232 port to retrieve the battery data.
I don't have SA, just looking at the info - SA Battery Config
SA connect to the inverter via RS485 and a separate RS232 it communicates to the battery.

I found some battery comms in the SS protocol that i want to try and use to extract battery cell data.

Edited by Zodiac69

  • 2 months later...

So i went down the wrong rabbit hole, assuming that the Sunsynk Battery data was accessible via the RS485 Modbus as this would have been the preferred way.
After some interaction with Sunsynk, i was informed that they do not support communicating with the battery via the RS485 Modbus port,

Looking at Solar Assistant, they use RS232 to communicate with the battery, i then started looking for info on the protocol. I tested many BMS software programmes and finally found one that worked instantly -  PBms Tools V2.4
So my Sunsynk 10.65kW battery has a Pace BMS.
Now that i know what to look for i found the Protocol document. I also reached out to Sunsynk support, and they confirmed that it is Pace BMS by sending me the same protocol document.

Here is a post by Tertiush where he posts about a Python script he made to communicated with the Pace BMS.
Here is the link to his Github repository. 

If there is some clever ESPHome gurus that can implement this on ESPHome, then we can use the same ESP32 for RS485 to the inverter and RS232 to the batteries.

I captured some data between the software and my battery.

What i found was that he software just repeat these four (4) calls, over and over. I have attached some data but not my Serial No.

~250146C10000FD9A # Software Version
~25014600602850313653323030412D4132313038342D312E3035F57F
~250146C20000FD99 #SerialNumber
######
~25014642E00201FD30 #PackAnalogData
~25014600D07C0001100D230D220D230D220D240D230D1F0D260D220D210D240D160D230D220D230D22060B960B950B940B940BA20BC70000D21D4C640436B100604E2061E332
~25014644E00201FD2E #2WarnInfo
~25014600E04E000110000000000000000000000000000000000600000000000000000000802410000000000001EEC8

 

 

PACE-BMS-RS232-communication-protocol-20180705.pdf

  • Author

Hi @Zodiac69

I found these repositories which speak to the Battery using ESPhome so no need to re-invent it :-) 

Depending on how your PACE BMS is setup you may be able to speak to it via the RJ45 RS485 port or otherwise the RS232 port, i think that this depends on the firmware on the BMS as it definitely works with some but not others. I could not find anywhere to switch it on with my BSL batteries. 

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

He has repositories for communications with a lot of other BMS's as well. 

 

 

  • 2 months later...

So i managed to get my 10.65kWh SS battery data into ESPHome... Sort of...

I setup my ESPHome as a Stream Server
I then installed BMSPase (Tertiush) Use the "dev" and set it for LAN
I now have all my battery data in HA.

One or two readings are not the same:
1. Battery Voltage is lower that what my SS Inverter show.
2. SoC does not make sense - 140% ???

I defentley have a PaceBMS as my BMS is read as - P16S200A-A21084-1.05

I am going to move to this one - PaceBMS direct to influx instead of mqtt

Here is the code for the ESP. I used an ESP32
This is after you have configured your ESP the way you want it to be.
 

external_components:
  - source: github://oxan/esphome-stream-server
 
# ##############################################################
# Battery RS232 UART Setup
# #############################################################
uart:
  id: bat_uart
  baud_rate: 9600
  tx_pin: GPIO17
  rx_pin: GPIO16
 
stream_server:
   uart_id: bat_uart
   port: 5000
   buffer_size: 512
 
binary_sensor:
  - platform: stream_server
    connected:
      name: Connected


On the Sunsynk 10.65kWh battery the RS232 port is an RJ45
Fron Solar assistant web, i found the pinout for Sunsynk.
 
image.png.fa80cd11631e6fa664a0a3e3f6c90bb8.png

 

Edited by Zodiac69

  • 3 weeks later...

I have successfully integrated my 2 BSL's into HA via MQTT & Tertius's Pace BMS Dev add-on & RS232 cable direct to HA server.

But every once in a while (month or so) the comms disappear, so I going to try the direct route and try @Zodiac69 streaming server approach. And later look into Influx.db method, as HA stats is limited to 7 days max, after that you get averaged results for long term data, so the detail gets lost. e.g. I'm interested in long term Cell Delta mV per pack.

  • 2 weeks later...

Hi Sidewinder

I would like to do the Influx method as well, but i am not sure how to, unless i try and do my own Pull request and do an Influx of my own.
I could not see where the files are stored under HA to modify then to use Influx instead of MQTT

  • 3 weeks later...

hello and good morning I am writing to you from Italy I found your forum and I am happy to have found someone on the other side of the world who was able to read the pmbs tolls data to mqtt. I have a 24 Volt hylink battery lifepo4 100ah. which I read from the USB cable using the software in question pbmstools…
I purchased esp8266 and rs232 to ttl converter but I can't get to the bottom of it…
I installed home assistant but I can't load the github project,
I hope someone on the forum can help me

I attach photos of my batteries for your comparison with project compatibility

Schermata 2024-08-17 alle 12.29.14.png

Schermata 2024-08-17 alle 12.18.57.png

@osenoir,

In HA, add MQTT & Tersiusb's dev (search for PACE BMS - Development)  integration and configure Mqtt (IP = IP of HA server, etc).

(Optional) Install MQTT Explorer on PC (hope you have Windows, else look for an App for your environment).

Connect your RS232 cable between Master Battery and HA server's USB port (PC's/servers don't have RS-232 ports anymore, so your cable would need to be USB to RJ11 connector on the battery side.

(Optional)Check  if battery data appears on MQTT explorer.

Once you have started the MQTT server under HA, you will see it should report "1 device and 93* entities" Note *= I have 2 batteries, so there seems to be 5 entities for the combined battery pack, e.g. SOC etc. (So 1 battery should show 44 entities. You can now scroll to the bottom of the list and these to your dashboard, a la HA.

My HA server is an Orange Pi running linux, but I'm sure this should work with whatever HA server you are running.

PS. No need for the ESP32 for now. As mentioned in future I would like to store the Battery data into a proper DB, but that's for another day/month?

Edited by Sidewinder

Hi @osenoir,

No, Windows does not play a role, other that it could be the PC that you access your HA server with via browser. Or access your battery directly using the PBMS software, which you have done.

So the MQTT & Pace BMS add-on must be installed on your HA server, and Battery cable plugged to the HA server.

Don't worry, I also struggled in the beginning, gave up after a while (years ago), but now it seems HA has matured quite a lot, and is easier to use for beginners like me😃

  • 3 weeks later...

good day all, newbie here

I have a question , how do I change this setting to pick up the pack quantity as it's stuck on one and not able to change ( i have 10 stacked) , i can change to the individual pages sure  have tried with the password still not able to modify this value , or is it suppose to work like this , one at a time, not planning on changing anything just to monitor as the system bms doesn't show individual cell values only pack values
image.thumb.png.d004529ae541414de5ed1174bfc60f09.png

 

  • 4 months later...

Does anyone know what the max buffer size is you can set for an ESP32 device?  I'm having a problem with the data streaming in it looks like.  I have 4 batteries and battery 3 and 4 give consistent data but 1 and 2 will drop out a lot.  I suspect it has to do with the buffer setting or something but need some advise as I'm a bit in the dark to what the max is.

captive_portal:

# Enable Bluetooth Proxy Components
esp32_ble_tracker:
  scan_parameters:
    interval: 320ms
    window: 120ms
    duration: 60s
    active: true

# Battery RS232 UART Setup
uart:
  id: bat_uart
  baud_rate: 9600
  tx_pin: GPIO17
  rx_pin: GPIO16
 
stream_server:
   uart_id: bat_uart
   port: 5000
   buffer_size: 4096
 
binary_sensor:
  - platform: stream_server
    connected:
      name: Connected

output:
  - platform: gpio
    pin: GPIO2
    id: blue_led

light:
  - platform: binary
    name: "Blue LED"
    output: blue_led

The error in the logs letting me to believe this is related to the buffer size is this:

(Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0): Client unable to keep up with pending messages. Reached 4096 pending messages. The system's load is too high or an integration is misbehaving; Last message was: b'{"type":"event","event":{"event_type":"state_changed","data":{"entity_id":"sensor.generic_lithium_pack_188_cell_25_voltage","old_state":{"entity_id":"sensor.generic_lithium_pack_188_cell_25_voltage","state":"unknown","attributes":{"unit_of_measurement":"mV","friendly_name":"Generic Lithium Pack 188 Cell 25 Voltage"},"last_changed":"2025-01-14T16:49:08.141897+00:00","last_reported":"2025-01-14T16:49:08.141897+00:00","last_updated":"2025-01-14T16:49:08.141897+00:00","context":{"id":"01JHJVG31D55FWPCF1REJ4Y44W","parent_id":null,"user_id":null}},"new_state":{"entity_id":"sensor.generic_lithium_pack_188_cell_25_voltage","state":"unavailable","attributes":{"unit_of_measurement":"mV","friendly_name":"Generic Lithium Pack 188 Cell 25 Voltage"},"last_changed":"2025-01-14T18:15:22.234455+00:00","last_reported":"2025-01-14T18:15:22.234455+00:00","last_updated":"2025-01-14T18:15:22.234455+00:00","context":{"id":"01JHK0DZVTJCM9P5TCYW6Z7XXM","parent_id":null,"user_id":null}}},"origin":"LOCAL","time_fired":"2025-01-14T18:15:22.234455+00:00","context":{"id":"01JHK0DZVTJCM9P5TCYW6Z7XXM","parent_id":null,"user_id":null}},"id":49}'

Can I bump it to 8192 or is 4096 the limit?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.