Sleeper85 / esphome-jk-bms-can

GNU General Public License v3.0
66 stars 19 forks source link

DEV: multi-BMS version with JK-PB* BMS connected via RS485 component #53

Open txubelaxu opened 1 month ago

txubelaxu commented 1 month ago

Some "by default" values are wrong for LiFePo4 batteries: image

txubelaxu commented 3 weeks ago

After last change, I see that esphome-jk-bms-can restarts periodically. But I think it is because a different reason. So there were 2 and 1 has been solved (I think).

cinusik commented 3 weeks ago

@txubelaxu Testing, testing... So far, so good ;) I had one restart after 12 minutes so I tried to change two parameters from:

bms_update_interval: '3s' # going below '3s' can cause problems
bms_combine_interval: '1s'

to

bms_update_interval: '5s' # going below '3s' can cause problems
bms_combine_interval: '2s'

and now 1 hour and 30 minutes without single issue.

EDIT: 3h30m - no issues 👍

txubelaxu commented 3 weeks ago

Hi @cinusik. With those settings here is restarting after 1 minute. I have 2 BMSs. It stops always at the same point:

[23:21:33][V][jk_rs485_sniffer:571]: ###############################Sequence found SIZE: 308
[23:21:33][D][jk_rs485_sniffer:627]: Frame received from SLAVE (type: 0x01, 309 bytes) 01 address
[23:21:33][D][jk_rs485_bms:112]: This BMS address is: 1  and address received 1 ==> WORKING (frame type:1)
[23:21:33][I][jk_rs485_bms:592]: Decoding settings  frame.... [ADDRESS: 01] 309 bytes received
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell smart sleep voltage': Received new state 3.500000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell smart sleep voltage': Sending state 3.50000 V with 3 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell undervoltage protection': Received new state 2.600000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell undervoltage protection': Sending state 2.60000 V with 3 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell undervoltage protection recovery': Received new state 2.650000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell undervoltage protection recovery': Sending state 2.65000 V with 3 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell overvoltage protection': Received new state 3.620000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell overvoltage protection': Sending state 3.62000 V with 3 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell overvoltage protection recovery': Received new state 3.448000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell overvoltage protection recovery': Sending state 3.44800 V with 3 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 balancing trigger voltage': Received new state 0.004000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 balancing trigger voltage': Sending state 0.00400 V with 3 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell soc100 voltage': Received new state 3.449000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell soc100 voltage': Sending state 3.44900 V with 3 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell soc0 voltage': Received new state 2.640000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell soc0 voltage': Sending state 2.64000 V with 3 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell request charge voltage': Received new state 3.450000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell request charge voltage': Sending state 3.45000 V with 3 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell request float voltage': Received new state 3.350000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell request float voltage': Sending state 3.35000 V with 3 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell power off voltage': Received new state 2.500000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell power off voltage': Sending state 2.50000 V with 3 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 max charging current': Received new state 50.000004
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 max charging current': Sending state 50.00000 A with 2 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 charging overcurrent protection delay': Received new state 3.000000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 charging overcurrent protection delay': Sending state 3.00000 s with 0 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 charging overcurrent protection recovery delay': Received new state 60.000000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 charging overcurrent protection recovery delay': Sending state 60.00000 s with 0 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 max discharging current': Received new state 10.000000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 max discharging current': Sending state 10.00000 A with 3 decimals of accuracy
[23:21:33][V][sensor:043]: 'esp32-s3 JK-BMS 1 discharging overcurrent protection delay': Received new state 300.000000
[23:21:33][D][sensor:094]: 'esp32-s3 JK-BMS 1 discharging overcurrent protection delay': Sending state 300.00000 s with 0 decimals of accuracy
[23:22:28][V][jk_rs485_sniffer:487]: free_heap 160.000000 kBytes [buffer: 308 bytes]
[23:22:28][V][jk_rs485_sniffer:571]: ###############################Sequence found SIZE: 308
[23:22:28][D][jk_rs485_sniffer:627]: Frame received from SLAVE (type: 0x01, 309 bytes) 01 address
[23:22:28][D][jk_rs485_bms:112]: This BMS address is: 1  and address received 1 ==> WORKING (frame type:1)
[23:22:28][I][jk_rs485_bms:592]: Decoding settings  frame.... [ADDRESS: 01] 309 bytes received
[23:22:28][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell smart sleep voltage': Received new state 3.500000
[23:22:28][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell smart sleep voltage': Sending state 3.50000 V with 3 decimals of accuracy
[23:22:28][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell undervoltage protection': Received new state 2.600000
[23:22:28][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell undervoltage protection': Sending state 2.60000 V with 3 decimals of accuracy
[23:22:28][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell undervoltage protection recovery': Received new state 2.650000
[23:22:28][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell undervoltage protection recovery': Sending state 2.65000 V with 3 decimals of accuracy
[23:22:28][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell overvoltage protection': Received new state 3.620000
[23:22:28][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell overvoltage protection': Sending state 3.62000 V with 3 decimals of accuracy
[23:22:28][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell overvoltage protection recovery': Received new state 3.448000
[23:22:28][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell overvoltage protection recovery': Sending state 3.44800 V with 3 decimals of accuracy
[23:22:28][V][sensor:043]: 'esp32-s3 JK-BMS 1 balancing trigger voltage': Received new state 0.004000
[23:22:28][D][sensor:094]: 'esp32-s3 JK-BMS 1 balancing trigger voltage': Sending state 0.00400 V with 3 decimals of accuracy
[23:22:28][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell soc100 voltage': Received new state 3.449000
[23:22:28][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell soc100 voltage': Sending state 3.44900 V with 3 decimals of accuracy
[23:22:28][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell soc0 voltage': Received new state 2.640000
[23:22:29][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell soc0 voltage': Sending state 2.64000 V with 3 decimals of accuracy
[23:22:29][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell request charge voltage': Received new state 3.450000
[23:22:29][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell request charge voltage': Sending state 3.45000 V with 3 decimals of accuracy
[23:22:29][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell request float voltage': Received new state 3.350000
[23:22:29][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell request float voltage': Sending state 3.35000 V with 3 decimals of accuracy
[23:22:29][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell power off voltage': Received new state 2.500000
[23:22:29][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell power off voltage': Sending state 2.50000 V with 3 decimals of accuracy
[23:22:29][V][sensor:043]: 'esp32-s3 JK-BMS 1 max charging current': Received new state 50.000004
[23:22:29][D][sensor:094]: 'esp32-s3 JK-BMS 1 max charging current': Sending state 50.00000 A with 2 decimals of accuracy
[23:22:29][V][sensor:043]: 'esp32-s3 JK-BMS 1 charging overcurrent protection delay': Received new state 3.000000
[23:22:29][D][sensor:094]: 'esp32-s3 JK-BMS 1 charging overcurrent protection delay': Sending state 3.00000 s with 0 decimals of accuracy
[23:22:29][V][sensor:043]: 'esp32-s3 JK-BMS 1 charging overcurrent protection recovery delay': Received new state 60.000000
[23:22:29][D][sensor:094]: 'esp32-s3 JK-BMS 1 charging overcurrent protection recovery delay': Sending state 60.00000 s with 0 decimals of accuracy
[23:22:29][V][sensor:043]: 'esp32-s3 JK-BMS 1 max discharging current': Received new state 10.000000
[23:22:29][D][sensor:094]: 'esp32-s3 JK-BMS 1 max discharging current': Sending state 10.00000 A with 3 decimals of accuracy
[23:22:29][V][sensor:043]: 'esp32-s3 JK-BMS 1 discharging overcurrent protection delay': Received new state 300.000000
[23:22:29][D][sensor:094]: 'esp32-s3 JK-BMS 1 discharging overcurrent protection delay': Sending state 300.00000 s with 0 decimals of accuracy
[23:23:24][V][jk_rs485_sniffer:487]: free_heap 160.000000 kBytes [buffer: 308 bytes]
[23:23:24][V][jk_rs485_sniffer:571]: ###############################Sequence found SIZE: 308
[23:23:24][D][jk_rs485_sniffer:627]: Frame received from SLAVE (type: 0x01, 309 bytes) 01 address
[23:23:24][D][jk_rs485_bms:112]: This BMS address is: 1  and address received 1 ==> WORKING (frame type:1)
[23:23:24][I][jk_rs485_bms:592]: Decoding settings  frame.... [ADDRESS: 01] 309 bytes received
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell smart sleep voltage': Received new state 3.500000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell smart sleep voltage': Sending state 3.50000 V with 3 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell undervoltage protection': Received new state 2.600000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell undervoltage protection': Sending state 2.60000 V with 3 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell undervoltage protection recovery': Received new state 2.650000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell undervoltage protection recovery': Sending state 2.65000 V with 3 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell overvoltage protection': Received new state 3.620000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell overvoltage protection': Sending state 3.62000 V with 3 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell overvoltage protection recovery': Received new state 3.448000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell overvoltage protection recovery': Sending state 3.44800 V with 3 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 balancing trigger voltage': Received new state 0.004000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 balancing trigger voltage': Sending state 0.00400 V with 3 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell soc100 voltage': Received new state 3.449000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell soc100 voltage': Sending state 3.44900 V with 3 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell soc0 voltage': Received new state 2.640000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell soc0 voltage': Sending state 2.64000 V with 3 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell request charge voltage': Received new state 3.450000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell request charge voltage': Sending state 3.45000 V with 3 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell request float voltage': Received new state 3.350000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell request float voltage': Sending state 3.35000 V with 3 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 cell power off voltage': Received new state 2.500000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 cell power off voltage': Sending state 2.50000 V with 3 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 max charging current': Received new state 50.000004
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 max charging current': Sending state 50.00000 A with 2 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 charging overcurrent protection delay': Received new state 3.000000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 charging overcurrent protection delay': Sending state 3.00000 s with 0 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 charging overcurrent protection recovery delay': Received new state 60.000000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 charging overcurrent protection recovery delay': Sending state 60.00000 s with 0 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 max discharging current': Received new state 10.000000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 max discharging current': Sending state 10.00000 A with 3 decimals of accuracy
[23:23:24][V][sensor:043]: 'esp32-s3 JK-BMS 1 discharging overcurrent protection delay': Received new state 300.000000
[23:23:24][D][sensor:094]: 'esp32-s3 JK-BMS 1 discharging overcurrent protection delay': Sending state 300.00000 s with 0 decimals of accuracy
cinusik commented 3 weeks ago

Hi @txubelaxu, I also have 2 BMSes and AtomS3. Over 7 hours without problems thanks to your fix. No idea why this is not working for you? I had restarts around 1 minute or less when I did not have ground wire connection. When I connected GND from JK BMS to RS485 converter GND than ESP became more stable working randomly like around 10 minutes, half hour, one our etc - until todays fix. Now is perfectly stable. Try to connect ground wire if you have not connected it yet.

txubelaxu commented 3 weeks ago

Testing new improvements and bug corrected

cinusik commented 3 weeks ago

Testing new improvements and bug corrected

Testing it also and what I found is that switches do not work. When I turn off charging using bluetooth phone app the change is not reflected in HA

txubelaxu commented 3 weeks ago

ups, sorry @cinusik. I changed settings_info (frame_type=1) to a frequency of 1/1h. I have changed to 1/5s

Could you test the code I have just uploaded, please?

I have verify here and it works now. It was a frequency setting. I think 1/5s is a good setting.

cinusik commented 3 weeks ago

@txubelaxu no problrem, confirmed, works as expected 🥇 Do you plan to make switches "life" instead of read only? like BLE version?

txubelaxu commented 3 weeks ago

Yes, that's the plan. I'll try.

Many thanks!!!

txubelaxu commented 3 weeks ago

OK, confirmed!! I have esphome-jk-bms-can working for image

Everything is showing quite stable.

cinusik commented 3 weeks ago

Confirmed. Just updated, as I saw that you made some performance improvements like 18 hours ago. Everything looks good. 👍

virus100b commented 2 weeks ago

image Looks good here to. But mine is not connected to CAN yet. I don't know if this makes any difference or not.

Sleeper85 commented 2 weeks ago

@txubelaxu

Are there any special compilation options to use to avoid problems?

Anything to modify on my side in the board.yaml?

txubelaxu commented 2 weeks ago

I think nothing special. I have not here the code now. I did corrected the code on my side (I renewed switches code) to avoid the restarts.

Only in "base": I changed the update interval of uptime sensor to 5s.

I use GPIO4 for talkpin on S3. If I use GPIO8 I have "flash" problems to upload the new version.

txubelaxu commented 2 weeks ago

image

cinusik commented 2 weeks ago

I use GPIO4 for talkpin on S3. If I use GPIO8 I have "flash" problems to upload the new version.

No problem with using GPIO8 on my AtomS3.

virus100b commented 1 week ago

Anyone else get this warning message?

Logger: homeassistant.components.sensor Source: helpers/entity_platform.py:764 integration: Sensor (documentation, issues) First occurred: 03:05:09 (1 occurrences) Last logged: 03:05:09

Platform esphome does not generate unique IDs. ID EC:DA:3B:BD:6D:38-sensor-smartbms_smart_bms_1_cell_uvpr_max already exists - ignoring sensor.smartbms_smart_bms_1_cell_uvpr_max