JBD via BLE only working after first firmware flash, not connecting to BMS after ESP32 restart or wifi loss #24
Replies: 3 comments 12 replies
-
Also, from time to time I get these errors on compiling/uploading firmware: [C][api:143]: Using noise encryption: NO abort() was called at PC 0x400f5544 on core 0 Backtrace:0x40083725:0x3ffbe9bc |<-CORRUPTED ELF file SHA256: 0000000000000000 Rebooting... |
Beta Was this translation helpful? Give feedback.
-
The JBD component should try to connect to the BMS periodically. If the log output stops something bad is happening. Could you remove the improv component and hardcoded the WiFi credentials just for testing? I would like to rule out the improv component is the root cause. Some more ideas:
|
Beta Was this translation helpful? Give feedback.
-
I can confirm that the setup works well now, after running it for several hours.
Hope this helps others that had similar issues. |
Beta Was this translation helpful? Give feedback.
-
Hi @syssi , I think I need your help again!
I was able to run successfully yesterday the JBD EspHome component on an ESP32 WROOM, connecting to various JBD boards via BLE (5 battery packs):
JBD-SP04S020A-L4S-80A-B-U
JBD-SP10S009-L8S-100A-B
All went fine for about a day.
After restarting the router I noticed ESP32 did not reconnect so I did a reset for each board . After that reset the boards stopped working and never connected to the BMS via BLE.
I flashed again all boards with default firmware, then with the EspHome firmware. After flash, I noticed the board connects OK via BLE to BMS and starts sending data. However, after I restart the board (RST or Power Off), I can see it only connects to Wifi, then never connects to BMS via BLE.
I don't know why this is happening. I tried flashing several times, different ESP32 boards, same behaviour.
I have attached the log & config files.
Any help will be greatly appreciated.
STEP 1 - Build / upload firmware (did a clean before):
Linking .pioenvs/jbd-bms-ble/bootloader.elf
Building .pioenvs/jbd-bms-ble/bootloader.bin
Creating esp32 image...
Successfully created esp32 image.
Linking .pioenvs/jbd-bms-ble/firmware.elf
RAM: [== ] 16.9% (used 55432 bytes from 327680 bytes)
Flash: [======== ] 75.4% (used 1383789 bytes from 1835008 bytes)
Building .pioenvs/jbd-bms-ble/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs/jbd-bms-ble/firmware.bin"], [".pioenvs/jbd-bms-ble/firmware.elf"])
Wrote 0x163400 bytes to file /home/dcristian/esphome/esphome-jbd-bms/.esphome/build/jbd-bms-ble/.pioenvs/jbd-bms-ble/firmware-factory.bin, ready to flash to offset 0x0
============================================= [SUCCESS] Took 30.08 seconds =============================================
INFO Successfully compiled program.
INFO Connecting to 192.168.0.74
INFO Uploading .esphome/build/jbd-bms-ble/.pioenvs/jbd-bms-ble/firmware.bin (1389568 bytes)
Uploading: [============================================================] 100% Done...
INFO Waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.0.74 using esphome API
INFO Successfully connected to 192.168.0.74
[23:05:55][V][mqtt.idf:073]: Event dispatched from event loop event_id=3
[23:05:55][V][mqtt.idf:093]: MQTT_EVENT_SUBSCRIBED, msg_id=24403
[23:05:55][I][app:102]: ESPHome version 2022.12.3 compiled on Jan 24 2023, 23:05:00
[23:05:55][I][app:104]: Project syssi.esphome-jbd-bms version 1.3.0
[23:05:55][C][wifi:504]: WiFi:
[23:05:55][C][wifi:362]: Local MAC: EC:62:60:9D:57:2C
[23:05:55][C][wifi:363]: SSID: 'iot'
[23:05:55][C][wifi:364]: IP Address: 192.168.0.74
[23:05:55][C][wifi:366]: BSSID: C4:6E:1F:87:D7:6C
[23:05:55][C][wifi:367]: Hostname: 'jbd-bms-ble'
[23:05:55][C][wifi:369]: Signal strength: -69 dB ▂▄▆█
[23:05:55][V][wifi:371]: Priority: 0.0
[23:05:55][C][wifi:373]: Channel: 11
[23:05:55][C][wifi:374]: Subnet: 255.255.255.0
[23:05:55][C][wifi:375]: Gateway: 192.168.0.1
[23:05:55][C][wifi:376]: DNS1: 0.0.0.0
[23:05:55][C][wifi:377]: DNS2: 0.0.0.0
[23:05:55][V][mqtt.idf:073]: Event dispatched from event loop event_id=3
[23:05:55][V][mqtt.idf:093]: MQTT_EVENT_SUBSCRIBED, msg_id=37194
[23:05:55][C][logger:293]: Logger:
[23:05:55][C][logger:294]: Level: VERY_VERBOSE
[23:05:55][C][logger:295]: Log Baud Rate: 115200
[23:05:55][C][logger:296]: Hardware UART: UART0
[23:05:55][C][logger:298]: Level for 'scheduler': DEBUG
[23:05:55][C][logger:298]: Level for 'component': DEBUG
[23:05:55][C][logger:298]: Level for 'esp32_ble_tracker': DEBUG
[23:05:55][C][logger:298]: Level for 'sensor': DEBUG
...
[23:05:57][C][esp32_ble_tracker:870]: BLE Tracker:
[23:05:57][C][esp32_ble_tracker:871]: Scan Duration: 300 s
[23:05:57][C][esp32_ble_tracker:872]: Scan Interval: 320.0 ms
[23:05:57][C][esp32_ble_tracker:873]: Scan Window: 30.0 ms
[23:05:57][C][esp32_ble_tracker:874]: Scan Type: ACTIVE
[23:05:57][C][esp32_ble_tracker:875]: Continuous Scanning: True
[23:05:57][C][ble_client:027]: BLE Client:
[23:05:57][C][ble_client:028]: Address: A4:C1:38:EC:1B:B0
[23:05:57][C][mdns:103]: mDNS:
[23:05:57][C][mdns:104]: Hostname: jbd-bms-ble
[23:05:57][V][mdns:105]: Services:
[23:05:57][V][mdns:107]: - _esphomelib, _tcp, 6053
[23:05:57][V][mdns:109]: TXT: version = 2022.12.3
[23:05:57][V][mdns:109]: TXT: mac = ec62609d572c
[23:05:57][V][mdns:109]: TXT: platform = ESP32
[23:05:57][V][mdns:109]: TXT: board = wemos_d1_mini32
[23:05:57][V][mdns:109]: TXT: network = wifi
[23:05:57][V][mdns:109]: TXT: project_name = syssi.esphome-jbd-bms
[23:05:57][C][api:138]: API Server:
[23:05:57][C][api:139]: Address: 192.168.0.74:6053
[23:05:57][C][api:143]: Using noise encryption: NO
[23:05:57][C][mqtt:065]: MQTT:
[23:05:57][C][mqtt:067]: Server Address: 192.168.0.12:1883 (192.168.0.12)
[23:05:57][C][mqtt:068]: Username: 'xxx'
[23:05:57][C][mqtt:069]: Client ID: 'jbd-bms-ble-ec62609d572c'
[23:05:57][C][mqtt:071]: Discovery prefix: 'homeassistant'
[23:05:57][C][mqtt:072]: Discovery retain: YES
[23:05:57][C][mqtt:074]: Topic Prefix: 'esphome/A4:C1:38:EC:1B:B0'
[23:05:57][C][mqtt:076]: Log Topic: 'esphome/A4:C1:38:EC:1B:B0/debug'
[23:05:57][C][mqtt:079]: Availability: 'esphome/A4:C1:38:EC:1B:B0/status'
[23:05:57][C][mqtt.binary_sensor:022]: MQTT Binary Sensor 'jbd-bms-ble charging':
[23:05:57][C][mqtt.binary_sensor:023]: State Topic: 'esphome/A4:C1:38:EC:1B:B0/binary_sensor/jbd-bms-ble_charging/state'
...
[23:06:04][W][jbd_bms_ble:172]: [A4:C1:38:EC:1B:B0] Not connected
[23:06:10][VV][api.service:470]: on_ping_request: PingRequest {}
[23:06:10][VV][api.service:043]: send_ping_response: PingResponse {}
[23:06:14][W][jbd_bms_ble:172]: [A4:C1:38:EC:1B:B0] Not connected
[23:06:24][W][jbd_bms_ble:172]: [A4:C1:38:EC:1B:B0] Not connected
[23:06:25][VV][api.service:470]: on_ping_request: PingRequest {}
[23:06:25][VV][api.service:043]: send_ping_response: PingResponse {}
[23:06:34][W][jbd_bms_ble:172]: [A4:C1:38:EC:1B:B0] Not connected
[23:06:36][D][esp32_ble_client:048]: [0] [A4:C1:38:EC:1B:B0] Found device
[23:06:36][D][esp32_ble_tracker:216]: Pausing scan to make connection...
[23:06:36][I][esp32_ble_client:064]: [0] [A4:C1:38:EC:1B:B0] 0x00 Attempting BLE connection
[23:06:36][V][esp32_ble_client:111]: [0] [A4:C1:38:EC:1B:B0] gattc_event_handler: event=40 gattc_if=3
[23:06:36][V][esp32_ble_client:111]: [0] [A4:C1:38:EC:1B:B0] gattc_event_handler: event=2 gattc_if=3
[23:06:36][V][esp32_ble_client:126]: [0] [A4:C1:38:EC:1B:B0] ESP_GATTC_OPEN_EVT
...
[23:06:37][I][jbd_bms_ble:091]: Request device info
[23:06:37][VV][jbd_bms_ble:434]: Send command: DD.A5.05.00.FF.FB.77 (7)
[23:06:37][D][esp32_ble_tracker:327]: Starting scan...
[23:06:37][V][esp32_ble_client:111]: [0] [A4:C1:38:EC:1B:B0] gattc_event_handler: event=9 gattc_if=3
[23:06:37][V][esp32_ble_client:111]: [0] [A4:C1:38:EC:1B:B0] gattc_event_handler: event=4 gattc_if=3
[23:06:40][VV][api.service:470]: on_ping_request: PingRequest {}
[23:06:40][VV][api.service:043]: send_ping_response: PingResponse {}
[23:06:44][VV][jbd_bms_ble:434]: Send command: DD.A5.03.00.FF.FD.77 (7)
[23:06:44][V][esp32_ble_client:111]: [0] [A4:C1:38:EC:1B:B0] gattc_event_handler: event=4 gattc_if=3
[23:06:45][V][esp32_ble_client:111]: [0] [A4:C1:38:EC:1B:B0] gattc_event_handler: event=10 gattc_if=3
[23:06:45][VV][jbd_bms_ble:101]: Notification received: DD.03.00.1D.05.51.00.00.1D.31.27.10.00.02.2A.E2.00.00.00.00 (20)
[23:06:45][V][esp32_ble_client:111]: [0] [A4:C1:38:EC:1B:B0] gattc_event_handler: event=10 gattc_if=3
[23:06:45][VV][jbd_bms_ble:101]: Notification received: 00.00.20.4B.03.04.03.0B.96.0B.97.0B.91.FB.A6.77 (16)
[23:06:45][VV][jbd_bms_ble:251]: Hardware info frame (29 bytes):
[23:06:45][VV][jbd_bms_ble:252]: 05.51.00.00.1D.31.27.10.00.02.2A.E2.00.00.00.00.00.00.20.4B.03.04.03.0B.96.0B.97.0B.91 (29)
[23:06:45][D][jbd_bms_ble:272]: Hardware info:
[23:06:45][D][jbd_bms_ble:273]: Device model:
[23:06:45][D][sensor:127]: 'jbd-bms-ble total voltage': Sending state 13.61000 V with 2 decimals of accuracy
[23:06:45][V][mqtt:415]: Publish(topic='esphome/A4:C1:38:EC:1B:B0/sensor/jbd-bms-ble_total_voltage/state' payload='13.61' retain=1)
It connects to BMS BLE and starts sending data, ALL OK so far.
STEP 2 - RST the board (or reconnect to same / different power source)
LOG FROM esphome run ...yaml command below:
INFO 192.168.0.74: Error while reading incoming messages: Error while reading data: [Errno 104] Connection reset by peer
INFO 192.168.0.74: Ping Failed: Error while reading data: [Errno 104] Connection reset by peer
INFO Disconnected from ESPHome API for 192.168.0.74
WARNING Disconnected from API
INFO Successfully connected to 192.168.0.74
INFO 192.168.0.74: Error while reading incoming messages: Error while reading data: [Errno 104] Connection reset by peer
INFO 192.168.0.74: Ping Failed: Error while reading data: [Errno 104] Connection reset by peer
INFO Disconnected from ESPHome API for 192.168.0.74
WARNING Disconnected from API
INFO Successfully connected to 192.168.0.74
[23:13:01][I][ota:113]: Boot seems successful, resetting boot loop counter.
[23:13:01][D][esp32.preferences:113]: Saving 1 preferences to flash...
[23:13:01][D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
Complete silence, not connecting to BMS BLE.
Also logs from web.esphome.io terminal (with board connected via USB). Sending data ok, then reset, then nothing.
[D][sensor:127]: 'jbd-bms-ble min voltage cell': Sending state 2.00000 with 0 decimals of accuracy
[V][mqtt:415]: Publish(topic='esphome/A4:C1:38:EC:1B:B0/sensor/jbd-bms-ble_min_voltage_cell/state' payload='2' retain=1)
[D][sensor:127]: 'jbd-bms-ble delta cell voltage': Sending state 0.02300 V with 4 decimals of accuracy
[V][mqtt:415]: Publish(topic='esphome/A4:C1:38:EC:1B:B0/sensor/jbd-bms-ble_delta_cell_voltage/state' payload='0.0230' retain=1)
[D][sensor:127]: 'jbd-bms-ble average cell voltage': Sending state 3.40275 V with 4 decimals of accuracy
[V][mqtt:415]: Publish(topic='esphome/A4:C1:38:EC:1B:B0/sensor/jbd-bms-ble_average_cell_voltage/state' payload='3.4028' retain=1)
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
[I][logger:258]: Log initialized
[C][ota:469]: There have been 1 suspected unsuccessful boot attempts.
[D][esp32.preferences:113]: Saving 1 preferences to flash...
[D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[C][esp32_ble:026]: Setting up BLE...
[D][esp32_ble:040]: BLE setup complete
[D][esp32_ble_server:033]: Setting up BLE Server...
[D][esp32_ble_server:070]: BLE server setup successfully
[C][wifi:037]: Setting up WiFi...
[C][wifi:038]: Local MAC: EC:62:60:9D:57:2C
[D][wifi:048]: Loaded saved wifi settings: iot
[D][wifi:386]: Starting scan...
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:201]: Setting Improv to start
[D][esp32_improv.component:076]: Service started!
[D][wifi:401]: Found networks:
[I][wifi:445]: - 'iot' [redacted]▂▄▆█
[D][wifi:446]: Channel: 11
[D][wifi:447]: RSSI: -58 dB
[D][wifi:450]: - [redacted] [redacted]▂▄▆█
[D][wifi:450]: - [redacted] [redacted]▂▄▆█
[D][wifi:450]: - [redacted] [redacted]▂▄▆█
[D][wifi:450]: - [redacted] [redacted]▂▄▆█
[D][wifi:450]: - [redacted] [redacted]▂▄▆█
[D][wifi:450]: - [redacted] [redacted]▂▄▆█
[D][wifi:450]: - [redacted] [redacted]▂▄▆█
[D][wifi:450]: - [redacted] [redacted]▂▄▆█
[D][wifi:450]: - [redacted] [redacted]▂▄▆█
[D][wifi:450]: - [redacted] [redacted]▂▄▆█
[D][wifi:450]: - [redacted] [redacted]▂▄▆█
[D][wifi:450]: - [redacted] [redacted]▂▄▆█
[I][wifi:257]: WiFi Connecting to 'iot'...
[I][wifi:518]: WiFi Connected!
[C][wifi:362]: Local MAC: EC:62:60:9D:57:2C
[C][wifi:363]: SSID: [redacted]
[C][wifi:364]: IP Address: 192.168.0.74
[C][wifi:366]: BSSID: [redacted]
[C][wifi:367]: Hostname: 'esphome-web-9d572c'
[C][wifi:369]: Signal strength: -71 dB ▂▄▆█
[C][wifi:373]: Channel: 11
[C][wifi:374]: Subnet: 255.255.255.0
[C][wifi:375]: Gateway: 192.168.0.1
[C][wifi:376]: DNS1: 192.168.0.1
[C][wifi:377]: DNS2: 0.0.0.0
[D][wifi:527]: Disabling AP...
[C][web_server:092]: Setting up web server...
[C][ota:093]: Over-The-Air Updates:
[C][ota:094]: Address: esphome-web.local:3232
[C][api:025]: Setting up Home Assistant API server...
[I][app:062]: setup() finished successfully!
[I][app:102]: ESPHome version 2022.12.6 compiled on Jan 24 2023, 02:29:12
[I][app:104]: Project esphome.web version 1.0
[C][wifi:504]: WiFi:
[C][wifi:362]: Local MAC: EC:62:60:9D:57:2C
[C][wifi:363]: SSID: [redacted]
[C][wifi:364]: IP Address: 192.168.0.74
[C][wifi:366]: BSSID: [redacted]
[C][wifi:367]: Hostname: 'esphome-web-9d572c'
[C][wifi:369]: Signal strength: -63 dB ▂▄▆█
[C][wifi:373]: Channel: 11
[C][wifi:374]: Subnet: 255.255.255.0
[C][wifi:375]: Gateway: 192.168.0.1
[C][wifi:376]: DNS1: 192.168.0.1
[C][wifi:377]: DNS2: 0.0.0.0
[C][logger:293]: Logger:
[C][logger:294]: Level: DEBUG
[C][logger:295]: Log Baud Rate: 115200
[C][logger:296]: Hardware UART: UART0
[C][esp32_ble:206]: ESP32 BLE:
[C][esp32_ble_server:160]: ESP32 BLE Server:
[C][esp32_improv.component:215]: ESP32 Improv:
[C][esp32_improv.component:217]: Status Indicator: 'NO'
[C][captive_portal:088]: Captive Portal:
[C][web_server:125]: Web Server:
[C][web_server:126]: Address: esphome-web.local:80
[C][mdns:103]: mDNS:
[C][mdns:104]: Hostname: esphome-web-9d572c
[C][ota:093]: Over-The-Air Updates:
[C][ota:094]: Address: esphome-web.local:3232
[C][api:138]: API Server:
[C][api:139]: Address: esphome-web.local:6053
[C][api:143]: Using noise encryption: NO
[C][improv_serial:032]: Improv Serial:
AND it hangs here, nothing happens after.
esp32-ble-example_1b_b0.zip
esp32-ble-example-debug_1b_b0.zip
Beta Was this translation helpful? Give feedback.
All reactions