syssi / esphome-jk-bms

ESPHome component to monitor and control a Jikong Battery Management System (JK-BMS) via UART-TTL or BLE
Apache License 2.0
405 stars 134 forks source link

Issue with weird readings from bluetooth on JKB2A20S20P #385

Closed lycaki closed 8 months ago

lycaki commented 8 months ago

Hi,

I wonder if anyone can help - my ESP32 home and Home Assistant have been working perfectly on my bluetooth link to my JKB2A20S20P (via my ESP32 )- and then collecting that info into Home Assistant. It's been running for about a year, some time outs and usually ESP issues but nothing a simple restart wouldn't fix.

I don't know what happened, something broke - I thought it might be the ESP32 so I replaced it, still the same readings. I get perfect readings on bluetooth with the BMS app (so I know the BMS device is sending out ok readings)

When I connect the ESP Home - it connects to the bluetooth and the readings are spurious for example here's some of my logs (ignore the names, I never bothered to rename them but it all works fine) - Cell voltages appear to be reading but total voltage, temperature etc but others are just either zero or some weird number like this 'capacity remaining': Sending state 14286.84863 Ah' (max Ah normally is 272 so that number should be anything below that.)

here's a brief log capture from the ESP

Like I say, everything was working perfectly a couple of days ago, rebooted the ESP and then this ... replaced and still the same.

Any ideas what's broken and where - I've rebuilt the code and now updated Home Assistant as I was a few versions out of date - no difference, still the same.

0:51:27][I][jk_bms_ble:467]: Cell info frame (version 2, 300 bytes) received [10:51:27][D][sensor:094]: '${name} cell voltage 1': Sending state 3.31700 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 2': Sending state 3.31700 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 3': Sending state 3.31500 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 4': Sending state 3.31700 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 5': Sending state 3.31100 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 6': Sending state 3.31500 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 7': Sending state 3.31300 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 8': Sending state 3.31500 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 9': Sending state 3.31500 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 10': Sending state 3.31700 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 11': Sending state 3.31800 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 12': Sending state 3.31800 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 13': Sending state 3.31700 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 14': Sending state 3.31500 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 15': Sending state 3.31400 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} cell voltage 16': Sending state 3.31100 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} min cell voltage': Sending state 3.31100 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} max cell voltage': Sending state 3.31800 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} average cell voltage': Sending state 0.00000 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} delta cell voltage': Sending state 0.00000 V with 3 decimals of accuracy [10:51:27][D][sensor:094]: '${name} max voltage cell': Sending state 1.00000 with 0 decimals of accuracy [10:51:27][D][sensor:094]: '${name} min voltage cell': Sending state 1.00000 with 0 decimals of accuracy [10:51:27][D][jk_bms_ble:557]: Unknown112: 0x00 0x00 [10:51:27][D][jk_bms_ble:562]: Wire resistance warning bitmask: 0x00 0x00 0x00 0x00 [10:51:27][D][sensor:094]: '${name} total voltage': Sending state 0.00000 V with 2 decimals of accuracy [10:51:27][D][sensor:094]: '${name} current': Sending state 0.00000 A with 2 decimals of accuracy [10:51:27][D][sensor:094]: '${name} power': Sending state 0.00000 W with 2 decimals of accuracy [10:51:27][D][sensor:094]: '${name} charging power': Sending state 0.00000 W with 2 decimals of accuracy [10:51:27][D][sensor:094]: '${name} discharging power': Sending state 0.00000 W with 2 decimals of accuracy [10:51:27][D][sensor:094]: '${name} temperature sensor 1': Sending state 0.00000 °C with 1 decimals of accuracy [10:51:27][D][sensor:094]: '${name} temperature sensor 2': Sending state 0.00000 °C with 1 decimals of accuracy [10:51:27][D][sensor:094]: '${name} power tube temperature': Sending state 0.00000 °C with 1 decimals of accuracy [10:51:27][D][sensor:094]: '${name} errors bitmask': Sending state 0.00000 with 0 decimals of accuracy [10:51:27][D][sensor:094]: '${name} balancing current': Sending state 0.00000 A with 2 decimals of accuracy [10:51:27][D][sensor:094]: '${name} state of charge': Sending state 0.00000 % with 0 decimals of accuracy [10:51:27][D][sensor:094]: '${name} capacity remaining': Sending state 14286.84863 Ah with 0 decimals of accuracy [10:51:27][D][sensor:094]: '${name} total battery capacity setting': Sending state 0.00000 Ah with 0 decimals of accuracy [10:51:27][D][sensor:094]: '${name} charging cycles': Sending state 53038.00000 with 0 decimals of accuracy [10:51:27][D][sensor:094]: '${name} total charging cycle capacity': Sending state 308.41501 Ah with 3 decimals of accuracy [10:51:28][D][jk_bms_ble:647]: Unknown158: 0x49 0xE9 (always 0x64 0x00?) [10:51:28][D][jk_bms_ble:650]: Unknown160: 0xFF 0xFF (always 0xC5 0x09?) [10:51:28][D][sensor:094]: '${name} total runtime': Sending state 8913059.00000 s with 0 decimals of accuracy [10:51:28][D][jk_bms_ble:663]: Unknown168: 00.00.A8.F8.02.55.80.88.03.00.80.26.04.00.3E.00.00.00.C6.96.04.01.64.00.00.00.D0.7A.6F.01.01.01.00.00.00.00.00.00.00.00.00.00.00.00.00.00 (46) [10:51:28][D][jk_bms_ble:677]: Unknown189: 0x01 0x64 [10:51:28][D][jk_bms_ble:681]: Unknown192: 0x00 [10:51:28][D][jk_bms_ble:683]: Unknown193: 0x00 0xD0 (0x00 0x8D) [10:51:28][D][jk_bms_ble:685]: Unknown195: 0x7A 0x6F (0x21 0x40) [10:51:28][W][component:214]: Component esp32_ble took a long time for an operation (0.46 s). [10:51:28][W][component:215]: Components should block for at most 20-30ms. [10:51:37][I][jk_bms_ble:467]: Cell info frame (version 2, 300 bytes) received [10:51:37][D][sensor:094]: '${name} cell voltage 1': Sending state 3.31400 V with 3 decimals of accuracy [10:51:37][D][sensor:094]: '${name} cell voltage 2': Sending state 3.31400 V with 3 decimals of accuracy [10:51:37][D][sensor:094]: '${name} cell voltage 3': Sending state 3.31700 V with 3 decimals of accuracy [10:51:37][D][sensor:094]: '${name} cell voltage 4': Sending state 3.31800 V with 3 decimals of accuracy [10:51:37][D][sensor:094]: '${name} cell voltage 5': Sending state 3.31800 V with 3 decimals of accuracy [10:51:37][D][sensor:094]: '${name} cell voltage 6': Sending state 3.31700 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} cell voltage 7': Sending state 3.31500 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} cell voltage 8': Sending state 3.31400 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} cell voltage 9': Sending state 3.31300 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} cell voltage 10': Sending state 3.30300 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} cell voltage 11': Sending state 3.31400 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} cell voltage 12': Sending state 3.31700 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} cell voltage 13': Sending state 3.31500 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} cell voltage 14': Sending state 3.31300 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} cell voltage 15': Sending state 3.31300 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} cell voltage 16': Sending state 3.31300 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} min cell voltage': Sending state 3.30300 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} max cell voltage': Sending state 3.31800 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} average cell voltage': Sending state 0.00000 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} delta cell voltage': Sending state 0.00000 V with 3 decimals of accuracy [10:51:38][D][sensor:094]: '${name} max voltage cell': Sending state 1.00000 with 0 decimals of accuracy [10:51:38][D][sensor:094]: '${name} min voltage cell': Sending state 1.00000 with 0 decimals of accuracy [10:51:38][D][jk_bms_ble:557]: Unknown112: 0x00 0x00 [10:51:38][D][jk_bms_ble:562]: Wire resistance warning bitmask: 0x00 0x00 0x00 0x00 [10:51:38][D][sensor:094]: '${name} total voltage': Sending state 0.00000 V with 2 decimals of accuracy [10:51:38][D][sensor:094]: '${name} current': Sending state 0.00000 A with 2 decimals of accuracy [10:51:38][D][sensor:094]: '${name} power': Sending state 0.00000 W with 2 decimals of accuracy [10:51:38][D][sensor:094]: '${name} charging power': Sending state 0.00000 W with 2 decimals of accuracy [10:51:38][D][sensor:094]: '${name} discharging power': Sending state 0.00000 W with 2 decimals of accuracy [10:51:38][D][sensor:094]: '${name} temperature sensor 1': Sending state 0.00000 °C with 1 decimals of accuracy [10:51:38][D][sensor:094]: '${name} temperature sensor 2': Sending state 0.00000 °C with 1 decimals of accuracy [10:51:38][D][sensor:094]: '${name} power tube temperature': Sending state 0.00000 °C with 1 decimals of accuracy [10:51:38][D][sensor:094]: '${name} errors bitmask': Sending state 0.00000 with 0 decimals of accuracy [10:51:38][D][sensor:094]: '${name} balancing current': Sending state 0.00000 A with 2 decimals of accuracy [10:51:38][D][sensor:094]: '${name} state of charge': Sending state 0.00000 % with 0 decimals of accuracy [10:51:38][D][sensor:094]: '${name} capacity remaining': Sending state 14286.84863 Ah with 0 decimals of accuracy [10:51:38][D][sensor:094]: '${name} total battery capacity setting': Sending state 0.00000 Ah with 0 decimals of accuracy [10:51:48][I][jk_bms_ble:467]: Cell info frame (version 2, 300 bytes) received [10:51:48][D][sensor:094]: '${name} cell voltage 1': Sending state 3.31500 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 2': Sending state 3.31200 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 3': Sending state 3.31300 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 4': Sending state 3.31500 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 5': Sending state 3.31500 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 6': Sending state 3.31700 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 7': Sending state 3.31700 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 8': Sending state 3.31700 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 9': Sending state 3.31500 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 10': Sending state 3.30800 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 11': Sending state 3.31700 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 12': Sending state 3.31700 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 13': Sending state 3.31800 V with 3 decimals of accuracy [10:51:48][D][sensor:094]: '${name} cell voltage 14': Sending state 3.31800 V with 3 decimals of accuracy [10:51:49][D][sensor:094]: '${name} cell voltage 15': Sending state 3.31700 V with 3 decimals of accuracy [10:51:58][I][jk_bms_ble:467]: Cell info frame (version 2, 300 bytes) received [10:51:58][D][sensor:094]: '${name} cell voltage 1': Sending state 3.31700 V with 3 decimals of accuracy [10:51:58][D][sensor:094]: '${name} cell voltage 2': Sending state 3.31500 V with 3 decimals of accuracy [10:51:58][D][sensor:094]: '${name} cell voltage 3': Sending state 3.31500 V with 3 decimals of accuracy [10:51:58][D][sensor:094]: '${name} cell voltage 4': Sending state 3.31500 V with 3 decimals of accuracy [10:51:58][D][sensor:094]: '${name} cell voltage 5': Sending state 3.31800 V with 3 decimals of accuracy [10:51:58][D][sensor:094]: '${name} cell voltage 6': Sending state 3.31700 V with 3 decimals of accuracy [10:51:58][D][sensor:094]: '${name} cell voltage 7': Sending state 3.31700 V with 3 decimals of accuracy [10:51:58][D][sensor:094]: '${name} cell voltage 8': Sending state 3.31500 V with 3 decimals of accuracy [10:51:58][D][sensor:094]: '${name} cell voltage 9': Sending state 3.31500 V with 3 decimals of accuracy [10:51:58][D][sensor:094]: '${name} cell voltage 13': Sending state 3.31700 V with 3 decimals of accuracy [10:51:58][D][sensor:094]: '${name} current': Sending state 0.00000 A with 2 decimals of accuracy [10:51:58][D][sensor:094]: '${name} capacity remaining': Sending state 14286.84863 Ah with 0 decimals of accuracy [10:51:58][D][sensor:094]: '${name} total battery capacity setting': Sending state 0.00000 Ah with 0 decimals of accuracy [10:51:59][D][sensor:094]: '${name} charging cycles': Sending state 53047.00000 with 0 decimals of accuracy [10:51:59][D][sensor:094]: '${name} total charging cycle capacity': Sending state 285.65601 Ah with 3 decimals of accuracy [10:51:59][D][jk_bms_ble:647]: Unknown158: 0xF7 0xEA (always 0x64 0x00?) [10:51:59][D][jk_bms_ble:650]: Unknown160: 0xFF 0xFF (always 0xC5 0x09?) [10:51:59][D][sensor:094]: '${name} total runtime': Sending state 8913059.00000 s with 0 decimals of accuracy [10:51:59][D][jk_bms_ble:663]: Unknown168: 00.00.83.F8.02.55.4F.88.03.00.80.26.04.00.3E.00.00.00.F7.96.04.01.64.00.00.00.EF.7A.6F.01.01.01.00.00.00.00.00.00.00.00.00.00.00.00.00.00 (46) [10:51:59][D][jk_bms_ble:677]: Unknown189: 0x01 0x64 [10:51:59][D][jk_bms_ble:681]: Unknown192: 0x00 [10:51:59][D][jk_bms_ble:683]: Unknown193: 0x00 0xEF (0x00 0x8D) [10:51:59][D][jk_bms_ble:685]: Unknown195: 0x7A 0x6F (0x21 0x40) [10:51:59][W][component:214]: Component esp32_ble took a long time for an operation (0.43 s).

lycaki commented 8 months ago

I was just reading through a few issues - discovered that this part had changed (didn't realise)

'I assume you are using the wrong protocol_version (JK02 vs JK02_32S).' from @syssi https://github.com/syssi/esphome-jk-bms/discussions/329#discussioncomment-5926542

Updated and all works (love it when a plan comes together) - hopefully if anyone else has this.

Thanks for this