Skip to content

Commit d8fae98

Browse files
committed
esp32-ble-battery_number_001.yaml example created and working
1 parent 59b0d26 commit d8fae98

File tree

2 files changed

+526
-0
lines changed

2 files changed

+526
-0
lines changed

README_uart_ble.md

+245
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
# esphome-jk-bms
2+
3+
![GitHub actions](https://github.com/syssi/esphome-jk-bms/actions/workflows/ci.yaml/badge.svg)
4+
![GitHub stars](https://img.shields.io/github/stars/syssi/esphome-jk-bms)
5+
![GitHub forks](https://img.shields.io/github/forks/syssi/esphome-jk-bms)
6+
![GitHub watchers](https://img.shields.io/github/watchers/syssi/esphome-jk-bms)
7+
[!["Buy Me A Coffee"](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://www.buymeacoffee.com/syssi)
8+
9+
ESPHome component to monitor a Jikong Battery Management System (JK-BMS) via UART-TTL or BLE
10+
11+
![Lovelace entities card](lovelace-entities-card.png "Lovelace entities card")
12+
13+
## Supported devices
14+
15+
All JK-BMS models with software version `>=6.0` are using the implemented protocol and should be supported.
16+
17+
* JK-BD4A8S4P, hw 11.xw, sw 11.24, using `JK02_32S` (reported by [@austin202220](https://github.com/syssi/esphome-jk-bms/issues/297))
18+
* JK-BD6A17S6P, hw 7.2, sw 7.1.0H
19+
* JK-BD6A17S8P, hw 9.x, sw 9.01G (reported by [@jonadis](https://github.com/syssi/esphome-jk-bms/issues/35#issuecomment-1035312712))
20+
* JK-BD6A20S10P, hw 10.XW, sw 10.07 (reported by [@adadrag](https://github.com/syssi/esphome-jk-bms/issues/123))
21+
* JK-BD6A20S12P, hw 11.XW, sw 11.281, using UART-TTL (reported by [@asiridissa](https://github.com/syssi/esphome-jk-bms/discussions/339))
22+
* JK-BD6A24S6P, hw 6.x, sw 6.10S (reported by [@ziporah](https://github.com/syssi/esphome-jk-bms/issues/41))
23+
* JK-BD6A24S10P, hw 8.x, sw 8.0.6G (reported by [@spoonwzd](https://github.com/syssi/esphome-jk-bms/issues/67#issuecomment-1093844076))
24+
* JK-BD6A24S10P, hw 10.xw, sw 10.09 (reported by [@PMPoulsen](https://github.com/syssi/esphome-jk-bms/discussions/261#discussioncomment-5091812))
25+
* JK-BD4A17S4P, hw 11.xw, sw 11.01 (reported by [@Condor-XYZ](https://github.com/syssi/esphome-jk-bms/issues/221))
26+
* JK-BD4A17S4P, hw 11.xw, sw 11.27, using `JK02_32S` and/or UART-TTL (reported by [@hemskgren](https://github.com/syssi/esphome-jk-bms/issues/359))
27+
* JK-B1A8S10P, hw 11.XW, sw 11.261, using `JK02_32S` (reported by [@Chickenbreast0](https://github.com/syssi/esphome-jk-bms/issues/346))
28+
* JK-B1A24S15P, hw 8.x, sw 8.1.0H (reported by [@killee](https://github.com/syssi/esphome-jk-bms/discussions/4))
29+
* JK-B1A20S15P, hw 8.x, sw 8.14U (reported by [@trippfam07](https://github.com/syssi/esphome-jk-bms/issues/31))
30+
* JK-B1A20S15P, hw 10.xw, sw 10.07 (reported by [@romeox44](https://github.com/syssi/esphome-jk-bms/discussions/125))
31+
* JK-B1A20S15P, hw 10.xw, sw 10.10, using `JK02_24S` (reported by [@austin202220](https://github.com/syssi/esphome-jk-bms/issues/297#issuecomment-1510685683))
32+
* JK-B1A20S15P, hw 11.xw, sw 11.26, using UART-TTL (reported by [@Tesla72PL](https://github.com/syssi/esphome-jk-bms/issues/309))
33+
* JK-B2A24S15P, hw 6.x, sw 6.1.3S (reported by [@miguel300477](https://github.com/syssi/esphome-jk-bms/issues/57))
34+
* JK-B2A24S15P, hw 8.x, sw 8.21W (reported by [@mariusvaida](https://github.com/syssi/esphome-jk-bms/issues/120))
35+
* JK-B2A24S15P, hw 10.xw, sw 10.07
36+
* JK-B2A24S15P, hw 10.xw, sw 10.08 (reported by [@meccip](https://github.com/syssi/esphome-jk-bms/discussions/175#discussioncomment-3687287))
37+
* JK-B2A24S150P, hw 10.xw, sw 10.10 (reported by [@nayias](https://github.com/syssi/esphome-jk-bms/discussions/257#discussioncomment-5062807))
38+
* JK-B2A24S20P, hw 8.x, sw 8.1.2H (reported by [@KlausLi](https://github.com/syssi/esphome-jk-bms/issues/15#issuecomment-961447064))
39+
* JK-B2A24S20P, hw 8.x, sw 8.20G (reported by [@rob-oravec](https://github.com/syssi/esphome-jk-bms/discussions/46))
40+
* JK-B2A24S20P, hw 10.X-W, sw 10.02 (reported by [@SeByDocKy](https://github.com/syssi/esphome-jk-bms/issues/37#issuecomment-1040569576))
41+
* JK-B2A24S20P, hw 10.XG, sw 10.07D30 (reported by [@TheSmartGerman](https://github.com/syssi/esphome-jk-bms/discussions/122))
42+
* JK-B2A24S20P, hw 10.XW, sw 10.07 (reported by [@amagr0](https://github.com/syssi/esphome-jk-bms/issues/124#issuecomment-1166366196))
43+
* JK-B2A8S20P, hw 9.x, sw 9.01M3, using `JK02_24S` (reported by [@EasilyBoredEngineer](https://github.com/syssi/esphome-jk-bms/discussions/110))
44+
* JK-B2A8S20P, hw 9.x, sw 9.08W (reported by [@vrabi-cv](https://github.com/syssi/esphome-jk-bms/discussions/144#discussioncomment-3285901))
45+
* JK-B2A8S20P, hw 11.XW, sw 11.17, using `JK02_32S` (reported by [@senfkorn](https://github.com/syssi/esphome-jk-bms/issues/147))
46+
* JK-B2A8S20P, hw 11.XW, sw 11.26, using `JK02_32S` (reported by [@riker65](https://github.com/syssi/esphome-jk-bms/issues/276))
47+
* JK-B2A20S20P, hw 10.XW, sw 10.09 (reported by [@markusgg84](https://github.com/syssi/esphome-jk-bms/discussions/173))
48+
* JK-B2A20S20P, hw 10.XW, sw 11.21h, using `JK02_32S` (reported by [@Salve87](https://github.com/syssi/esphome-jk-bms/issues/308#issuecomment-1505614325))
49+
* JK-B2A20S20P, hw 11.XW, sw 11.24H, using `JK02_32S` (reported by [@austin202220](https://github.com/syssi/esphome-jk-bms/discussions/232))
50+
* JK-B2A20S20P, hw 11.XW, sw 11.25H, using `JK02_32S` (reported by [@iovcharyk](https://github.com/syssi/esphome-jk-bms/issues/249))
51+
* JK-B5A24S, hw 8.x, sw 8.0.3M, using `JK04` (reported by [@JSladen](https://github.com/syssi/esphome-jk-bms/issues/213))
52+
* JK-B2A16S, hw 3.0, sw 3.3.0, using `JK04` (reported by [@magnetus26](https://github.com/syssi/esphome-jk-bms/discussions/48))
53+
* GW-24S4EB (NEEY/Heltec 4A Smart Active Balancer), hw HW-2.8.0, sw ZH-1.2.3 (reported by [@cristi2005](https://github.com/syssi/esphome-jk-bms/issues/109))
54+
* GW-24S4EB (NEEY 4A Smart Active Balancer 4th generation), hw HW-3.2.0, sw ZH-1.2.4 (reported by [@fabhund](https://github.com/syssi/esphome-jk-bms/issues/310))
55+
56+
## Untested devices
57+
58+
* JK-BD6A20S6P
59+
60+
## Requirements
61+
62+
* [ESPHome 2022.11.0 or higher](https://github.com/esphome/esphome/releases).
63+
* Generic ESP32 or ESP8266 board
64+
65+
## Schematics
66+
67+
<a href="https://raw.githubusercontent.com/syssi/esphome-jk-bms/main/images/circuit.jpg" target="_blank">
68+
<img src="https://raw.githubusercontent.com/syssi/esphome-jk-bms/main/images/circuit_thumbnail.jpg" width="50%">
69+
</a>
70+
71+
72+
```
73+
UART-TTL
74+
┌──────────┐ ┌─────────┐
75+
│ │<----- RX ----->│ │
76+
│ JK-BMS │<----- TX ----->│ ESP32/ │
77+
│ │<----- GND ---->│ ESP8266 │<-- 3.3V
78+
│ │ │ │<-- GND
79+
└──────────┘ └─────────┘
80+
81+
# UART-TTL socket (4 Pin, JST 1.25mm pitch)
82+
┌─── ─────── ────┐
83+
│ │
84+
│ O O O O │
85+
│GND RX TX VBAT│
86+
└────────────────┘
87+
│ │ │
88+
│ │ └─── GPIO17 (`rx_pin`)
89+
│ └─────── GPIO16 (`tx_pin`)
90+
└─────────── GND
91+
```
92+
93+
94+
The UART-TTL (labeled as `RS485`) socket of the BMS can be attached to any UART pins of the ESP. A hardware UART should be preferred because of the high baudrate (115200 baud). The connector is called 4 Pin JST with 1.25mm pitch.
95+
96+
## Installation
97+
98+
You can install this component with [ESPHome external components feature](https://esphome.io/components/external_components.html) like this:
99+
```yaml
100+
external_components:
101+
- source: github://syssi/esphome-jk-bms@main
102+
```
103+
104+
or just use the `esp32-example.yaml` as proof of concept:
105+
106+
```bash
107+
# Install esphome
108+
pip3 install esphome
109+
110+
# Clone this external component
111+
git clone https://github.com/syssi/esphome-jk-bms.git
112+
cd esphome-jk-bms
113+
114+
# Create a secrets.yaml containing some setup specific secrets
115+
cat > secrets.yaml <<EOF
116+
wifi_ssid: MY_WIFI_SSID
117+
wifi_password: MY_WIFI_PASSWORD
118+
119+
mqtt_host: MY_MQTT_HOST
120+
mqtt_username: MY_MQTT_USERNAME
121+
mqtt_password: MY_MQTT_PASSWORD
122+
EOF
123+
124+
# Validate the configuration, create a binary, upload it, and start logs
125+
# If you use a esp8266 run the esp8266-examle.yaml
126+
esphome run esp32-example.yaml
127+
128+
```
129+
130+
## Example response all sensors enabled
131+
132+
```
133+
[sensor:127]: 'jk-bms cell voltage 1': Sending state 4.12500 V with 3 decimals of accuracy
134+
[sensor:127]: 'jk-bms cell voltage 2': Sending state 4.12500 V with 3 decimals of accuracy
135+
[sensor:127]: 'jk-bms cell voltage 3': Sending state 4.12800 V with 3 decimals of accuracy
136+
[sensor:127]: 'jk-bms cell voltage 4': Sending state 4.12400 V with 3 decimals of accuracy
137+
[sensor:127]: 'jk-bms cell voltage 5': Sending state 4.12500 V with 3 decimals of accuracy
138+
[sensor:127]: 'jk-bms cell voltage 6': Sending state 4.12800 V with 3 decimals of accuracy
139+
[sensor:127]: 'jk-bms cell voltage 7': Sending state 4.12400 V with 3 decimals of accuracy
140+
[sensor:127]: 'jk-bms cell voltage 8': Sending state 4.12300 V with 3 decimals of accuracy
141+
[sensor:127]: 'jk-bms cell voltage 9': Sending state 4.12800 V with 3 decimals of accuracy
142+
[sensor:127]: 'jk-bms cell voltage 10': Sending state 4.12800 V with 3 decimals of accuracy
143+
[sensor:127]: 'jk-bms cell voltage 11': Sending state 4.12800 V with 3 decimals of accuracy
144+
[sensor:127]: 'jk-bms cell voltage 12': Sending state 4.13100 V with 3 decimals of accuracy
145+
[sensor:127]: 'jk-bms cell voltage 13': Sending state 4.12400 V with 3 decimals of accuracy
146+
[sensor:127]: 'jk-bms power tube temperature': Sending state 24.00000 °C with 0 decimals of accuracy
147+
[sensor:127]: 'jk-bms temperature sensor 1': Sending state 22.00000 °C with 0 decimals of accuracy
148+
[sensor:127]: 'jk-bms temperature sensor 2': Sending state 22.00000 °C with 0 decimals of accuracy
149+
[sensor:127]: 'jk-bms total voltage': Sending state 53.64000 V with 2 decimals of accuracy
150+
[sensor:127]: 'jk-bms current': Sending state -0.00000 A with 2 decimals of accuracy
151+
[sensor:127]: 'jk-bms capacity remaining': Sending state 99.00000 % with 0 decimals of accuracy
152+
[sensor:127]: 'jk-bms temperature sensors': Sending state 2.00000 with 0 decimals of accuracy
153+
[sensor:127]: 'jk-bms charging cycles': Sending state 0.00000 with 0 decimals of accuracy
154+
[sensor:127]: 'jk-bms total charging cycle capacity': Sending state 0.00000 with 0 decimals of accuracy
155+
[sensor:127]: 'jk-bms battery strings': Sending state 13.00000 with 0 decimals of accuracy
156+
[sensor:127]: 'jk-bms errors bitmask': Sending state 0.00000 with 0 decimals of accuracy
157+
[text_sensor:015]: 'jk-bms errors': Sending state ''
158+
[sensor:127]: 'jk-bms operation mode bitmask': Sending state 0.00000 with 0 decimals of accuracy
159+
[text_sensor:015]: 'jk-bms operation mode': Sending state ''
160+
[sensor:127]: 'jk-bms total voltage overvoltage protection': Sending state 5.46000 V with 3 decimals of accuracy
161+
[sensor:127]: 'jk-bms total voltage undervoltage protection': Sending state 3.77000 V with 3 decimals of accuracy
162+
[sensor:127]: 'jk-bms cell voltage overvoltage protection': Sending state 4.20000 V with 3 decimals of accuracy
163+
[sensor:127]: 'jk-bms cell voltage overvoltage recovery': Sending state 4.10000 V with 3 decimals of accuracy
164+
[sensor:127]: 'jk-bms cell voltage overvoltage delay': Sending state 5.00000 s with 0 decimals of accuracy
165+
[sensor:127]: 'jk-bms cell voltage undervoltage protection': Sending state 2.90000 V with 3 decimals of accuracy
166+
[sensor:127]: 'jk-bms cell voltage undervoltage recovery': Sending state 3.20000 V with 3 decimals of accuracy
167+
[sensor:127]: 'jk-bms cell voltage undervoltage delay': Sending state 5.00000 s with 0 decimals of accuracy
168+
[sensor:127]: 'jk-bms cell pressure difference protection': Sending state 0.30000 V with 3 decimals of accuracy
169+
[sensor:127]: 'jk-bms discharging overcurrent protection': Sending state 60.00000 A with 0 decimals of accuracy
170+
[sensor:127]: 'jk-bms discharging overcurrent delay': Sending state 300.00000 s with 0 decimals of accuracy
171+
[sensor:127]: 'jk-bms charging overcurrent protection': Sending state 25.00000 A with 0 decimals of accuracy
172+
[sensor:127]: 'jk-bms charging overcurrent delay': Sending state 30.00000 s with 0 decimals of accuracy
173+
[sensor:127]: 'jk-bms balance starting voltage': Sending state 3.30000 V with 3 decimals of accuracy
174+
[sensor:127]: 'jk-bms balance opening pressure difference': Sending state 0.01000 V with 3 decimals of accuracy
175+
[switch:045]: 'jk-bms balancing': Sending state ON
176+
[sensor:127]: 'jk-bms power tube temperature protection': Sending state 90.00000 °C with 0 decimals of accuracy
177+
[sensor:127]: 'jk-bms power tube temperature recovery': Sending state 70.00000 °C with 0 decimals of accuracy
178+
[sensor:127]: 'jk-bms temperature sensor temperature protection': Sending state 100.00000 °C with 0 decimals of accuracy
179+
[sensor:127]: 'jk-bms temperature sensor temperature recovery': Sending state 100.00000 °C with 0 decimals of accuracy
180+
[sensor:127]: 'jk-bms temperature sensor temperature difference protection': Sending state 20.00000 °C with 0 decimals of accuracy
181+
[sensor:127]: 'jk-bms charging high temperature protection': Sending state 70.00000 °C with 0 decimals of accuracy
182+
[sensor:127]: 'jk-bms discharging high temperature protection': Sending state 70.00000 °C with 0 decimals of accuracy
183+
[sensor:127]: 'jk-bms charging low temperature protection': Sending state -20.00000 °C with 0 decimals of accuracy
184+
[sensor:127]: 'jk-bms charging low temperature recovery': Sending state -10.00000 °C with 0 decimals of accuracy
185+
[sensor:127]: 'jk-bms discharging low temperature protection': Sending state -20.00000 °C with 0 decimals of accuracy
186+
[sensor:127]: 'jk-bms discharging low temperature recovery': Sending state -10.00000 °C with 0 decimals of accuracy
187+
[switch:045]: 'jk-bms charging': Sending state OFF
188+
[switch:045]: 'jk-bms discharging': Sending state OFF
189+
[sensor:127]: 'jk-bms current calibration': Sending state 0.72500 A with 3 decimals of accuracy
190+
[sensor:127]: 'jk-bms device address': Sending state 1.00000 with 0 decimals of accuracy
191+
[text_sensor:015]: 'jk-bms battery type': Sending state 'Ternary Lithium'
192+
[sensor:127]: 'jk-bms sleep wait time': Sending state 10.00000 s with 0 decimals of accuracy
193+
[sensor:127]: 'jk-bms alarm low volume': Sending state 20.00000 with 0 decimals of accuracy
194+
[text_sensor:015]: 'jk-bms password': Sending state '123456'
195+
[switch:045]: 'jk-bms dedicated charger': Sending state OFF
196+
[text_sensor:015]: 'jk-bms device type': Sending state 'Input Us'
197+
[sensor:127]: 'jk-bms total runtime': Sending state 0.00000 h with 0 decimals of accuracy
198+
[text_sensor:015]: 'jk-bms software version': Sending state 'H7.X__S7.1.0H__'
199+
[sensor:127]: 'jk-bms actual_battery_capacity': Sending state 186.00000 Ah with 0 decimals of accuracy
200+
[text_sensor:015]: 'jk-bms manufacturer': Sending state 'BT3072020120000200521001'
201+
[sensor:127]: 'jk-bms protocol version': Sending state 1.00000 with 0 decimals of accuracy
202+
```
203+
204+
## Known issues
205+
206+
* The battery type sensor is pretty useless because the BMS reports always the same value (`Ternary Lithium`). Regardless of which battery type was set / parameter set was loaded via the android app. ([#9][i9])
207+
* ESP32: Adding all supported sensors can lead to a stack overflow / boot loop. This can be solved by increasing the stack size. ([#63][i63])
208+
209+
[i9]: https://github.com/syssi/esphome-jk-bms/issues/9
210+
[i63]: https://github.com/syssi/esphome-jk-bms/issues/63
211+
212+
## Goodies
213+
214+
A user of this project ([@dr3amr](https://github.com/dr3amr)) shared some [Home Assistant Lovelace UI cards for a beautiful dashboard here](https://github.com/syssi/esphome-jk-bms/discussions/230).
215+
216+
![Custom Lovelace UI cards](images/lovelace-cards-contribution.jpg "Home Assistant Lovelace UI cards")
217+
218+
## Debugging
219+
220+
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:
221+
222+
```
223+
logger:
224+
level: DEBUG
225+
226+
uart:
227+
id: uart_0
228+
baud_rate: 115200
229+
rx_buffer_size: 384
230+
tx_pin: GPIO14
231+
rx_pin: GPIO4
232+
debug:
233+
direction: BOTH
234+
```
235+
236+
## References
237+
238+
* https://secondlifestorage.com/index.php?threads/jk-b1a24s-jk-b2a24s-active-balancer.9591/
239+
* https://github.com/jblance/jkbms
240+
* https://github.com/jblance/mpp-solar/issues/112
241+
* https://github.com/jblance/mpp-solar/blob/master/mppsolar/protocols/jk232.py
242+
* https://github.com/jblance/mpp-solar/blob/master/mppsolar/protocols/jk485.py
243+
* https://github.com/sshoecraft/jktool
244+
* https://github.com/Louisvdw/dbus-serialbattery/blob/master/etc/dbus-serialbattery/jkbms.py
245+
* https://blog.ja-ke.tech/2020/02/07/ltt-power-bms-chinese-protocol.html

0 commit comments

Comments
 (0)