Skip to content

ESPHome component to monitor a Xiaoxiang Battery Management System (JBD-BMS) via UART

License

Notifications You must be signed in to change notification settings

Bretthansenpc/esphome-jbd-bms

 
 

Repository files navigation

esphome-jbd-bms

GitHub actions GitHub stars GitHub forks GitHub watchers "Buy Me A Coffee"

ESPHome component to monitor a JBD-BMS via UART

Supported devices

  • JBD-SP04S034 200A 4S V1.3 (JBD-SP04S034-L4S-200A-B-U)
  • JBD-SP04S020 120A 4S (JBD-SP04S020-L4S-120A-B-U-K, reported by @Bretthansenpc)

Untested devices

Untested but probably supported devices:

  • JBD-SP04S028 60/80/100/120/150A 4S
  • JBD-SP15S020 30/40/60A 15S
  • JBD-SP04S020 4S
  • JBD-SP04S005 4S 150A
  • JBD-SP05S002 4S 80A
  • JBD-SP15S001 14S 60A

Requirements

Schematics

                RS485-TTL
┌──────────┐                ┌─────────┐
│          │<----- RX ----->│         │
│ JBD-BMS  │<----- TX ----->│ ESP32/  │
│          │<----- GND ---->│ ESP8266 │<-- 3.3V
│          │                │         │<-- GND
└──────────┘                └─────────┘



│                JBD-BMS                   │
│                                          │
│                          UART   Balancer │
└─────────────────────────[oooo]──[ooooo]──┘
                            │││
                            │││      (ESP32)
                            │││
                            ││└─ GND (GND)
                            │└── RXD (GPIO4)
                            └─── TXD (GPIO5)

Connector 4 Pin, JST PA 2.0mm pitch

Installation

You can install this component with ESPHome external components feature like this:

external_components:
  - source: github://syssi/esphome-jbd-bms@main

or just use the esp32-example.yaml as proof of concept:

# Install esphome
pip3 install esphome

# Clone this external component
git clone https://github.com/syssi/esphome-jbd-bms.git
cd esphome-jbd-bms

# Create a secrets.yaml containing some setup specific secrets
cat > secrets.yaml <<EOF
wifi_ssid: MY_WIFI_SSID
wifi_password: MY_WIFI_PASSWORD

mqtt_host: MY_MQTT_HOST
mqtt_username: MY_MQTT_USERNAME
mqtt_password: MY_MQTT_PASSWORD
EOF

# Validate the configuration, create a binary, upload it, and start logs
# If you use a esp8266 run the esp8266-examle.yaml
esphome run esp32-example.yaml

Example response all sensors enabled

[D][uart_debug:114]: >>> DD:A5:03:00:FF:FD:77
[D][uart_debug:114]: <<< DD:03:00:1D:06:0B:00:00:01:ED:01:F4:00:00:2C:7C:00:00:00:00:10:00:80:63:02:04:03:0B:A0:0B:9D:0B:98:FA:55:77
[D][sensor:124]: 'jbd-bms-uart total voltage': Sending state 15.47000 V with 2 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart current': Sending state 0.00000 A with 1 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart power': Sending state 0.00000 W with 1 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart capacity remaining': Sending state 4.93000 Ah with 2 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart nominal capacity': Sending state 5.00000 Ah with 2 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart charging cycles': Sending state 0.00000  with 0 decimals of accuracy
[I][jbd_bms:243]:   Date of manufacture: 2022.3.28
[D][sensor:124]: 'jbd-bms-uart balancer status bitmask': Sending state 0.00000  with 0 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart errors bitmask': Sending state 4096.00000  with 0 decimals of accuracy
[D][text_sensor:067]: 'jbd-bms-uart errors': Sending state 'Mosfet Software Lock'
[D][sensor:124]: 'jbd-bms-uart software version': Sending state 8.00000  with 1 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart state of charge': Sending state 99.00000 % with 0 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart operation status bitmask': Sending state 2.00000  with 0 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart battery strings': Sending state 4.00000  with 0 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart temperature 1': Sending state 24.50000 °C with 1 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart temperature 2': Sending state 24.20000 °C with 1 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart temperature 3': Sending state 23.70000 °C with 1 decimals of accuracy
[D][uart_debug:114]: >>> DD:A5:04:00:FF:FC:77
[D][uart_debug:114]: <<< DD:04:00:08:0F:23:0F:1C:0F:12:0F:1D:FF:4E:77
[D][sensor:124]: 'jbd-bms-uart cell voltage 1': Sending state 3.87500 V with 3 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart cell voltage 2': Sending state 3.86800 V with 3 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart cell voltage 3': Sending state 3.85800 V with 3 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart cell voltage 4': Sending state 3.86900 V with 3 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart min cell voltage': Sending state 3.85800 V with 3 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart max cell voltage': Sending state 3.87500 V with 3 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart max voltage cell': Sending state 1.00000  with 0 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart min voltage cell': Sending state 3.00000  with 0 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart delta cell voltage': Sending state 0.01700 V with 4 decimals of accuracy
[D][sensor:124]: 'jbd-bms-uart average cell voltage': Sending state 3.86750 V with 4 decimals of accuracy

Protocol

See Jiabaida.communication.protocol.pdf

Known issues

  • If the BMS doesn't respond to an ESP8266 using hardware serial (GPIO1/GPIO3) please try to use software serial (f.e. GPIO4/GPIO5). There are no problems known if you use one of the three hardware supported serial interfaces of an ESP32.

Debugging

If this component doesn't work out of the box for your device please update your configuration to enable the debug output of the UART component and increase the log level to the see outgoing and incoming serial traffic:

logger:
  level: DEBUG

uart:
  id: uart0
  baud_rate: 19200
  rx_buffer_size: 384
  tx_pin: GPIO14
  rx_pin: GPIO4
  debug:
    direction: BOTH

References

About

ESPHome component to monitor a Xiaoxiang Battery Management System (JBD-BMS) via UART

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 52.6%
  • C++ 47.1%
  • Shell 0.3%