esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 36 forks source link

BMS Daly EspHome DEV #3086

Closed Didou30 closed 1 year ago

Didou30 commented 2 years ago

The problem

Ajout des tensions des cellule de 1 à 16 ne fonctionne pas, il ne remonte que la Température

Which version of ESPHome has the issue?

V 2022.2.5-dev

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2022.2.9

What platform are you using?

ESP8266

Board

Wemos D1 mini

Component causing the issue

Daly BMS

Example YAML snippet

esphome:
  name: bmsdaly

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "057e5e176a11c4f5ac1cab965ff9bf6c"

wifi:
  ssid: !secret ssid
  password: !secret mp_wifi

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Bmsdaly Fallback Hotspot"
    password: "MzJE8fEg3jGy"

captive_portal:

uart:
  tx_pin: GPIO15
  rx_pin: GPIO13
  baud_rate: 9600

switch:
  - platform: restart
    name: "bms_daly_restart"

daly_bms:
  update_interval: 20s

sensor:
  - platform: daly_bms
    voltage:
      name: "Battery Voltage"
    current:
      name: "Battery Current"
    battery_level:
      name: "Battery Level"
    max_cell_voltage:
      name: "Max Cell Voltage"
    max_cell_voltage_number:
      name: "Max Cell Voltage Number"
    min_cell_voltage:
      name: "Min Cell Voltage"
    min_cell_voltage_number:
      name: "Min Cell Voltage Number"
    max_temperature:
      name: "Max Temperature"
    max_temperature_probe_number:
      name: "Max Temperature Probe Number"
    min_temperature:
      name: "Min Temperature"
    min_temperature_probe_number:
      name: "Min Temperature Probe Number"
    remaining_capacity:
      name: "Remaining Capacity"
      filters:
      - lambda: return x * 0.04;
    cells_number:
      name: "Cells Number"
    temperature_1:
      name: "Temperature 1"
    temperature_2:
      name: "Temperature 2"

 # - plateform: template
      #name: "Capacité en KW"
      #remaining_capacity*0.04

#intensité du signal wifi
  - platform: wifi_signal
    name: "WiFi puissance_BMS_Daly"
    update_interval: 60s

text_sensor:
  - platform: daly_bms
    status:
      name: "BMS Status"

binary_sensor:
  - platform: daly_bms
    charging_mos_enabled:
      name: "Charging MOS"
    discharging_mos_enabled:
      name: "Discharging MOS"

Anything in the logs that might be useful for us?

INFO Reading configuration /config/esphome/bmsdaly.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing bmsdaly (board: esp01_1m; framework: arduino; platform: platformio/espressif8266 @ 3.2.0)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|-- <ESPAsyncWebServer-esphome> 2.1.0
|   |-- <ESPAsyncTCP-esphome> 1.2.3
|   |-- <Hash> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <DNSServer> 1.1.1
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
Compiling /data/bmsdaly/.pioenvs/bmsdaly/src/esphome/components/debug/debug_component.cpp.o
Compiling /data/bmsdaly/.pioenvs/bmsdaly/src/main.cpp.o
Linking /data/bmsdaly/.pioenvs/bmsdaly/firmware.elf
RAM:   [====      ]  41.6% (used 34092 bytes from 81920 bytes)
Flash: [====      ]  42.0% (used 430573 bytes from 1023984 bytes)
Building /data/bmsdaly/.pioenvs/bmsdaly/firmware.bin
esp8266_copy_factory_bin(["/data/bmsdaly/.pioenvs/bmsdaly/firmware.bin"], ["/data/bmsdaly/.pioenvs/bmsdaly/firmware.elf"])
========================= [SUCCESS] Took 20.19 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of bmsdaly.local
INFO  -> 192.168.1.28
INFO Uploading /data/bmsdaly/.pioenvs/bmsdaly/firmware.bin (434720 bytes)
INFO Compressed to 299534 bytes
Uploading: [============================================================] 100% Done...

INFO Waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from bmsdaly.local using esphome API
INFO Successfully connected to bmsdaly.local
[11:26:44][I][app:102]: ESPHome version 2022.3.0-dev compiled on Feb 23 2022, 11:26:03
[11:26:44][C][wifi:491]: WiFi:
[11:26:44][C][wifi:353]:   Local MAC: 40:91:51:4F:8F:9E
[11:26:44][C][wifi:354]:   SSID: 'Livebox-596E'[redacted]
[11:26:44][C][wifi:355]:   IP Address: 192.168.1.28
[11:26:44][C][wifi:356]:   BSSID: E8:1B:69:02:59:6E[redacted]
[11:26:44][C][wifi:358]:   Hostname: 'bmsdaly'
[11:26:44][C][wifi:360]:   Signal strength: -51 dB ▂▄▆█
[11:26:44][C][wifi:364]:   Channel: 1
[11:26:44][C][wifi:365]:   Subnet: 255.255.255.0
[11:26:44][C][wifi:366]:   Gateway: 192.168.1.1
[11:26:44][C][wifi:367]:   DNS1: 192.168.1.1
[11:26:44][C][wifi:368]:   DNS2: 0.0.0.0
[11:26:44][C][logger:233]: Logger:
[11:26:44][C][logger:234]:   Level: DEBUG
[11:26:44][C][logger:235]:   Log Baud Rate: 115200
[11:26:44][C][logger:236]:   Hardware UART: UART0
[11:26:44][C][uart.arduino_esp8266:102]: UART Bus:
[11:26:44][C][uart.arduino_esp8266:103]:   TX Pin: GPIO15
[11:26:44][C][uart.arduino_esp8266:104]:   RX Pin: GPIO13
[11:26:44][C][uart.arduino_esp8266:106]:   RX Buffer Size: 256
[11:26:44][C][uart.arduino_esp8266:108]:   Baud Rate: 9600 baud
[11:26:44][C][uart.arduino_esp8266:109]:   Data Bits: 8
[11:26:44][C][uart.arduino_esp8266:110]:   Parity: NONE
[11:26:44][C][uart.arduino_esp8266:111]:   Stop bits: 1
[11:26:44][C][uart.arduino_esp8266:115]:   Using software serial
[11:26:44][C][restart:022]: Restart Switch 'bms_daly_restart'
[11:26:44][C][restart:022]:   Icon: 'mdi:restart'
[11:26:44][C][daly_bms:025]: Daly BMS:
[11:26:44][C][captive_portal:088]: Captive Portal:
[11:26:44][C][mdns:084]: mDNS:
[11:26:44][C][mdns:085]:   Hostname: bmsdaly
[11:26:44][C][ota:085]: Over-The-Air Updates:
[11:26:44][C][ota:086]:   Address: bmsdaly.local:8266
[11:26:44][C][ota:089]:   Using Password.
[11:26:44][C][api:138]: API Server:
[11:26:44][C][api:139]:   Address: bmsdaly.local:6053
[11:26:44][C][api:143]:   Using noise encryption: NO
[11:26:44][C][wifi_signal.sensor:009]: WiFi Signal 'WiFi puissance_BMS_Daly'
[11:26:44][C][wifi_signal.sensor:009]:   Device Class: 'signal_strength'
[11:26:44][C][wifi_signal.sensor:009]:   State Class: 'measurement'
[11:26:44][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dBm'
[11:26:44][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[11:26:44][C][debug:049]: Debug component:
[11:26:44][C][debug:051]:   Device info 'Device Info'
[11:26:44][C][debug:054]:   Free space on heap 'Heap Free'
[11:26:44][C][debug:054]:     State Class: ''
[11:26:44][C][debug:054]:     Unit of Measurement: 'B'
[11:26:44][C][debug:054]:     Accuracy Decimals: 0
[11:26:44][C][debug:054]:     Icon: 'mdi:counter'
[11:26:44][C][debug:055]:   Largest free heap block 'Heap Max Block'
[11:26:44][C][debug:055]:     State Class: ''
[11:26:44][C][debug:055]:     Unit of Measurement: 'B'
[11:26:44][C][debug:055]:     Accuracy Decimals: 0
[11:26:44][C][debug:055]:     Icon: 'mdi:counter'
[11:26:44][C][debug:057]:   Heap fragmentation 'Heap Fragmentation'
[11:26:44][C][debug:057]:     State Class: ''
[11:26:44][C][debug:057]:     Unit of Measurement: '%'
[11:26:44][C][debug:057]:     Accuracy Decimals: 1
[11:26:44][C][debug:057]:     Icon: 'mdi:counter'
[11:26:44][D][debug:061]: ESPHome version 2022.3.0-dev
[11:26:44][D][debug:065]: Free Heap Size: 25440 bytes
[11:26:44][D][debug:093]: Flash Chip: Size=1024kB Speed=40MHz Mode=DOUT
[11:26:44][D][debug:250]: Chip ID: 0x004F8F9E
[11:26:44][D][debug:251]: SDK Version: 2.2.2-dev(38a443e)
[11:26:44][D][debug:252]: Core Version: 3.0.2
[11:26:44][D][debug:253]: Boot Version=31 Mode=1
[11:26:44][D][debug:254]: CPU Frequency: 80
[11:26:44][D][debug:255]: Flash Chip ID=0x00164020
[11:26:44][D][debug:256]: Reset Reason: Software/System restart
[11:26:44][D][debug:257]: Reset Info: Software/System restart
[11:26:45][D][text_sensor:067]: 'Device Info': Sending state '2022.3.0-dev|Flash: 1024kB Speed:40MHz Mode:DOUT|Chip: 0x004f8f9e|SDK: 2.2.2-dev(38a443e)|Core: 3.0.2|Boot: 31|Mode: 1|CPU: 80|Flash: 0x00164020|Reset: Software/System restart|Software/System restart'
[11:26:48][D][sensor:124]: 'Heap Free': Sending state 27992.00000 B with 0 decimals of accuracy
[11:26:48][D][sensor:124]: 'Heap Max Block': Sending state 23576.00000 B with 0 decimals of accuracy
[11:26:48][D][sensor:124]: 'Heap Fragmentation': Sending state 6.00000 % with 1 decimals of accuracy
[11:26:48][D][sensor:124]: 'Loop Time': Sending state 165.00000 ms with 0 decimals of accuracy
[11:26:48][D][sensor:124]: 'Temperature 1': Sending state 13.00000 °C with 0 decimals of accuracy
[11:26:48][D][sensor:124]: 'Temperature 2': Sending state -40.00000 °C with 0 decimals of accuracy
[11:26:53][D][sensor:124]: 'Heap Free': Sending state 28832.00000 B with 0 decimals of accuracy
[11:26:53][D][sensor:124]: 'Heap Max Block': Sending state 24376.00000 B with 0 decimals of accuracy
[11:26:53][D][sensor:124]: 'Heap Fragmentation': Sending state 6.00000 % with 1 decimals of accuracy
[11:26:53][D][sensor:124]: 'Loop Time': Sending state 124.00000 ms with 0 decimals of accuracy
[11:26:58][D][sensor:124]: 'Heap Free': Sending state 28520.00000 B with 0 decimals of accuracy
[11:26:58][D][sensor:124]: 'Heap Max Block': Sending state 24376.00000 B with 0 decimals of accuracy
[11:26:58][D][sensor:124]: 'Heap Fragmentation': Sending state 5.00000 % with 1 decimals of accuracy
[11:26:58][D][sensor:124]: 'Loop Time': Sending state 36.00000 ms with 0 decimals of accuracy
[11:27:03][D][sensor:124]: 'Heap Free': Sending state 28952.00000 B with 0 decimals of accuracy
[11:27:03][D][sensor:124]: 'Heap Max Block': Sending state 24376.00000 B with 0 decimals of accuracy
[11:27:03][D][sensor:124]: 'Heap Fragmentation': Sending state 6.00000 % with 1 decimals of accuracy
[11:27:03][D][sensor:124]: 'Loop Time': Sending state 35.00000 ms with 0 decimals of accuracy

Additional information

Fonctionne avec la version Esphome avec Daly BMS:

NFO Reading configuration /config/esphome/bmsdaly.yaml... INFO Starting log output from bmsdaly.local using esphome API INFO Successfully connected to bmsdaly.local [21:01:36][I][app:102]: ESPHome version 2022.2.4 compiled on Feb 23 2022, 11:29:20

[21:01:36][C][wifi:353]: Local MAC: 40:91:51:4F:8F:9E [21:01:36][C][wifi:354]: SSID: 'Livebox-596E'[redacted] [21:01:36][C][wifi:355]: IP Address: 192.168.1.28 [21:01:36][C][wifi:356]: BSSID: E8:1B:69:02:59:6E[redacted]

[21:01:36][C][wifi:360]: Signal strength: -54 dB ▂▄▆█ [21:01:36][C][wifi:364]: Channel: 1 [21:01:36][C][wifi:365]: Subnet: 255.255.255.0 [21:01:36][C][wifi:366]: Gateway: 192.168.1.1 [21:01:36][C][wifi:367]: DNS1: 192.168.1.1 [21:01:36][C][wifi:368]: DNS2: 0.0.0.0

[21:01:36][C][logger:234]: Level: DEBUG [21:01:36][C][logger:235]: Log Baud Rate: 115200 [21:01:36][C][logger:236]: Hardware UART: UART0 [21:01:36][C][uart.arduino_esp8266:102]: UART Bus: [21:01:36][C][uart.arduino_esp8266:103]: TX Pin: GPIO15 [21:01:36][C][uart.arduino_esp8266:104]: RX Pin: GPIO13 [21:01:36][C][uart.arduino_esp8266:106]: RX Buffer Size: 256 [21:01:36][C][uart.arduino_esp8266:108]: Baud Rate: 9600 baud [21:01:36][C][uart.arduino_esp8266:109]: Data Bits: 8 [21:01:36][C][uart.arduino_esp8266:110]: Parity: NONE [21:01:36][C][uart.arduino_esp8266:111]: Stop bits: 1 [21:01:36][C][uart.arduino_esp8266:115]: Using software serial [21:01:36][C][restart:022]: Restart Switch 'bms_daly_restart'

[21:01:36][C][daly_bms:024]: Daly BMS: [21:01:36][C][captive_portal:144]: Captive Portal:

[21:01:36][C][mdns:085]: Hostname: bmsdaly [21:01:36][C][ota:085]: Over-The-Air Updates: [21:01:36][C][ota:086]: Address: bmsdaly.local:8266 [21:01:36][C][ota:089]: Using Password. [21:01:36][C][api:138]: API Server: [21:01:36][C][api:139]: Address: bmsdaly.local:6053 [21:01:36][C][api:143]: Using noise encryption: NO [21:01:36][C][wifi_signal.sensor:009]: WiFi Signal 'WiFi puissance_BMS_Daly' [21:01:36][C][wifi_signal.sensor:009]: Device Class: 'signal_strength' [21:01:36][C][wifi_signal.sensor:009]: State Class: 'measurement' [21:01:36][C][wifi_signal.sensor:009]: Unit of Measurement: 'dBm' [21:01:36][C][wifi_signal.sensor:009]: Accuracy Decimals: 0 [21:01:43][D][sensor:124]: 'Max Cell Voltage': Sending state 3.32200 V with 2 decimals of accuracy [21:01:43][D][sensor:124]: 'Max Cell Voltage Number': Sending state 13.00000 with 0 decimals of accuracy [21:01:43][D][sensor:124]: 'Min Cell Voltage': Sending state 3.31500 V with 2 decimals of accuracy [21:01:43][D][sensor:124]: 'Min Cell Voltage Number': Sending state 1.00000 with 0 decimals of accuracy [21:01:43][D][sensor:124]: 'Max Temperature': Sending state 13.00000 °C with 0 decimals of accuracy [21:01:43][D][sensor:124]: 'Max Temperature Probe Number': Sending state 1.00000 with 0 decimals of accuracy [21:01:43][D][sensor:124]: 'Min Temperature': Sending state 13.00000 °C with 0 decimals of accuracy [21:01:43][D][sensor:124]: 'Min Temperature Probe Number': Sending state 1.00000 with 0 decimals of accuracy [21:01:43][D][text_sensor:067]: 'BMS Status': Sending state 'Discharging' [21:01:43][D][sensor:124]: 'Remaining Capacity': Sending state 6.93360 Ah with 2 decimals of accuracy [21:01:43][D][sensor:124]: 'Cells Number': Sending state 16.00000 with 0 decimals of accuracy [21:01:43][D][sensor:124]: 'Temperature 1': Sending state 13.00000 °C with 0 decimals of accuracy [21:01:43][D][sensor:124]: 'Temperature 2': Sending state -40.00000 °C with 0 decimals of accuracy [21:01:47][D][sensor:124]: 'WiFi puissance_BMS_Daly': Sending state -56.00000 dBm with 0 decimals of accuracy

Didou30 commented 2 years ago

le code testé en Esphome V 2022.2.5-dev esphome: name: bmsdaly

esp8266: board: esp01_1m

Enable logging

logger:

Enable Home Assistant API

api:

ota: password: "057e5e176a11c4f5ac1cab965ff9bf6c"

wifi: ssid: !secret ssid password: !secret mp_wifi

Enable fallback hotspot (captive portal) in case wifi connection fails

ap: ssid: "Bmsdaly Fallback Hotspot" password: "MzJE8fEg3jGy"

captive_portal:

uart: tx_pin: GPIO15 rx_pin: GPIO13 baud_rate: 9600

switch:

daly_bms: update_interval: 20s

sensor:

intensité du signal wifi

text_sensor:

binary_sensor:

Didou30 commented 2 years ago

Anythink for help?

probot-esphome[bot] commented 2 years ago

Hey there @s1lvi0, mind taking a look at this issue as it has been labeled with an integration (daly_bms) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

matthias882 commented 2 years ago

I have the same problem. But after some hours of testing I can say more the reasons. In daly_bms.cpp

void DalyBmsComponent::update() { this->requestdata(DALY_REQUEST_BATTERY_LEVEL); this->requestdata(DALY_REQUEST_MIN_MAX_VOLTAGE); this->requestdata(DALY_REQUEST_MIN_MAX_TEMPERATURE); this->requestdata(DALY_REQUEST_MOS); this->requestdata(DALY_REQUEST_STATUS); this->requestdata(DALY_REQUEST_CELL_VOLTAGE); this->requestdata(DALY_REQUEST_TEMPERATURE);

the update sends several requests to the bms. [18:25:33][D][uart_debug:114]: >>> A5:80:90:08:00:00:00:00:00:00:00:00:BD:A5:80:91:08:00:00:00:00:00:00:00:00:BE:A5:80:92:08:00:00:00:00:00:00:00:00:BF:A5:80:93:08:00:00:00:00:00:00:00:00:C0:A5:80:94:08:00:00:00:00:00:00:00:00:C1:A5:80:95:08:00:00:00:00:00:00:00:00:C2:A5:80:96:08:00:00:00:00:00:00:00:00:C3

After this request you get al lot of bytes back to the serial interface, but not all requested bytes. Is seems like the data-package is cut on start and on the end. First package ist complete on Start (A501...) [18:25:34][D][uart_debug:114]: <<< A5:01:95:08:01:0D:0F:0D:0C:0D:0C:C0:52:A5:01:95:08:02:0D:18:0D:16:0D:19:C0:73:A5:01:95:08:03:0D:15:0D:14:0D:0C:C0:62:A5:01:95:08:04:0D:15:0D:19:0D:0B:C0:67:A5:01:95:08:05:0D:15:0D:11:0D:12:C0:67:A5:01:95:08:06:0D:11:00:00:00:00:C0:27:A5:01:95:08:07:00:00:00:00:00:00:C0:0A:A5:01:95:08:08:00:00:00:00:00:00:C0:0B:A5:01:95:08:09:00:00:00:00:00:00:C0:0C:A5:01:95:08:0A:00:00:00:00:00:00:C0:0D:A5:01:95:08:0B:00:00:00:00:00:00:C0:0E:A5:01:96:08:01:37:00:00:00:00:00:C0:3C:0B:86:74:08:2B:12:DD:2D:19:D1:21:48:FD:90:A1:40:21:48:5B:69:84:80:EE:00:60:C0:52:00:00:00:02:C0:15:05:43:D4:D4:A8:4E

next pakages are cut on start and on End. [18:25:54][D][uart_debug:114]: <<< FD:A5:01:95:08:02:0D:18:0D:16:0D:19:C0:73:A5:01:95:08:03:0D:15:0D:14:0D:0C:C0:62:A5:01:95:08:04:0D:15:0D:19:0D:0A:C0:66:A5:01:95:08:05:0D:15:0D:11:0D:12:C0:67:A5:01:95:08:06:0D:11:00:00:00:00:C0:27:A5:01:95:08:07:00:00:00:00:00:00:C0:0A:A5:01:95:08:08:00:00:00:00:00:00:C0:0B:A5:01:95:08:09:00:00:00:00:00:00:C0:0C:A5:01:95:08:0A:00:00:00:00:00:00:C0:0D:A5:01:95:08:0B:00:00:00:00:00:00:C0:0E:A5:01:96:08:01:37:00:00:00:00:00:C0:3C:41:09:02:54:04:FF:0B:86:94:A8:08:F4:2D:0C:53:20:21:6C:5A:32:A0:40:80:B0:66:65:88:80:00:15:D2:95:0C:0C

If you comment out some request-lines in DalyBmsComponent::update() it works fine. With more than 2 requests per update it beginns to stuck.

If you execute only one request at time, the answers are decoded and published correct.

I tried to rise the UART rx-buffer from 256 to 2048 bytes with no success.

Is it possible to split the requests over several Updates? Only one Request per Update works fast and fine. Next Update next request an so on...

codewise-nicolas commented 2 years ago

Me 2...not all values were populating from my bms. Specially temp and battery current.

Thanks to the insights from @matthias882, I added rx_buffer_size: 512 To my UART line and I seem to be receiving all values properly now.

I dont know if that will work in all situations or if its even the right value (who knows if im loosing a few extra bits near the end), but unlike @matthias882 that said it didnt help him (possibly he is on esp8266 which uses soft uart?), it did for me. Im on an ESP32, I only have 8 cells, 1 temp sensor.

Digging further into the daly_bms.cpp update() function its clear that Temp is one of the last requested items, so it makes sense that a buffer of 256 (default) could possibly be loosing the bits related to the last few requested data.

Ive briefly looked thru @matthias882 pull request for a state machine change and overall it looks good. I will see about trying it later. Let me know if there is any way I can help with this issue.