diy solar

diy solar

YamBMS JK-BMS-CAN with new Cut-Off Charging Logic (open-source)

I have never ever managed to keep an ESPhome device connected to my network for longer than a couple of minutes. I don't know what the hell I'm doing wrong but apparently everyone else is doing it wrong too.
Just to make sure ... One thing that caught my attention.

In the YAML file do you have this ?
Code:
api:

If you have it and you did NOT add your ESPHome device to Home Assistant (Settings -> Devices and Services -> Add Integration -> Search for ESPHome -> Click-> Put the IP address / hostname -> Click Submit) then of course the ESPHome will automatically reboot.

1712650425142.png

1712650443594.png

If you did NOT add it to *Home Assistant* or if ESPHome cannot reach the device (e.g. DHCP IP address lease changed, DNS not working, Routing not working correctly, improper Network configuration, etc) then the ESPHome will reboot by itself by default every 15 minutes:

That's a feature, not a bug :) .

In the logs of the ESP32 device you should see something like
Code:
[D][api.connection:1201]: Home Assistant 2024.3.1 (192.168.4.10): Connected successfully

We have to take the issues one by one. It could also be wireless configuration as I saw several posts on GitHub / Home Assistant Forums.

But it could also be much simpler than that.

EDIT 1: I meant *Home Assistant* (not ESPHome) in the first part of the statement - fixed now.
 
Last edited:
The default behavior of the api: and wifi: components is a reboot every 15 minutes in the event of loss or no connection.

If you don't use Home Assistant the api: line must be configured like this to avoid reboots.

YAML:
api:
  reboot_timeout: 0s

Same for wifi:

YAML:
wifi:
  reboot_timeout: 0s
 
The default behavior of the api: and wifi: components is a reboot every 15 minutes in the event of loss or no connection.

If you don't use Home Assistant the api: line must be configured like this to avoid reboots.

YAML:
api:
  reboot_timeout: 0s

Same for wifi:

YAML:
wifi:
  reboot_timeout: 0s
That was my point :) . Maybe he simply didn't configure Home Assistant correctly, therefore the Home Assistant would not establish an API connection to the ESPHome and the ESPHome device would reboot (since it didn't receive any signal that Home Assistant is up), just like it's designed to do :).

He mentioned "a couple of minutes" which is not 15 minutes. But time perception, unless measured with a clock or logs, is sometimes deceiving.

At first I only used MQTT because I didn't even have Home Assistant. Then I discovered that Home Assistant was smart enough to automatically detect the esphome-jk-bms (originally using the syssi esphome-jk-bms software, but of course the same applies with yours) and latest I added also the API connection since now Home Assistant is set up :).

EDIT 1: @Sleeper85 When I was NOT using Home Assistant, I commented out the api: section entirely:
YAML:
#Disabled due to lack of Connection to Home Assistant
#api:
#

Are you saying that this is equivalent to:
YAML:
#Disabled due to lack of Connection to Home Assistant
api:
reboot_timeout: 0s

?
 
In the case below the API is not disabled (possibility of connecting the ESP32 to HA) but this prevents reboots every 15 minutes.
This is not equivalent to fully commenting api:

YAML:
api:
  reboot_timeout: 0s
 
Been running flawless for 48hours.

Thanks for all the assistance in this thread, Sleeper85 have done a tremendous work here.👏🤜

For the record my hardware is JK BMS B2A20S20P-Heat-CAN ( hw v11.XA / sw v11.43 ), Atom S3 Lite, CA-IS3050G connected to the XP6000 inverter.

Here where some of my struggles.

Using Windows I had issues flashing the wired version of this firmware over usb-c ( most of my usb-c cables turned out to NOT support data transfer, only power ), this would cause Atom S3 lite to disconnect and reconnect loopy style, I HAD to flash the wired firmware OTA ( never had any success getting BLE REALLY STABLE, but with the WIRED version it now works awesome! ).

Pay close attention to the instructions, even if you only miss a space or delete a space too much, can make ALL the difference.

Thank guys!
 
Been running flawless for 48hours.

Thanks for all the assistance in this thread, Sleeper85 have done a tremendous work here.👏🤜

For the record my hardware is JK BMS B2A20S20P-Heat-CAN ( hw v11.XA / sw v11.43 ), Atom S3 Lite, CA-IS3050G connected to the XP6000 inverter.

Here where some of my struggles.

Using Windows I had issues flashing the wired version of this firmware over usb-c ( most of my usb-c cables turned out to NOT support data transfer, only power ), this would cause Atom S3 lite to disconnect and reconnect loopy style, I HAD to flash the wired firmware OTA ( never had any success getting BLE REALLY STABLE, but with the WIRED version it now works awesome! ).

Pay close attention to the instructions, even if you only miss a space or delete a space too much, can make ALL the difference.

Thank guys!

Glad to hear that the Wire version works well with a JK-BMS SW version > 11.28 👌 ( @paulsteigel )

What framework do you use for Atom S3 Lite, ESP-IDF or Arduino?

What can name and protocol version did you choose?

What battery mode on the XP6000?

I am asking you these questions to add you to the list of compatible inverters.
 
Glad to hear that the Wire version works well with a JK-BMS SW version > 11.28 👌 ( @paulsteigel )

What framework do you use for Atom S3 Lite, ESP-IDF or Arduino?

What can name and protocol version did you choose?

What battery mode on the XP6000?

I am asking you these questions to add you to the list of compatible inverters.
Many thanks @Sleeper85 for your information.
I don't have 11.XA version (I thought XA and XW might be the same) so I am not quite sure, mine is 11.XW (11.42) and I tried both using Arduino, esp32, none of them worked! I revise also the reading command "4E 57 00 13 00 00 00 00 03 03 (frame source 02-gps and 03 - pc) 00 85 00 00 00 00 68 00 00 01 AB" but failed also, no response at all! Chatting with JK-BMS guy but he did not reply! For this non-working over wire, I have to use Bluetooth!
1712741616624.png
A friend of mine have this
1712741782577.png
It may worth a try then!
 
Last edited:
Many thanks @Sleeper85 for your information.
I don't have 11.XA version (I thought XA and XW might be the same) so I am not quite sure, mine is 11.XW (11.42) and I tried both using Arduino, esp32, none of them worked! I revise also the reading command "4E 57 00 13 00 00 00 00 03 03 (frame source 02-gps and 03 - pc) 00 85 00 00 00 00 68 00 00 01 AB" but failed also, no response at all! Chatting with JK-BMS guy but he did not reply! For this non-working over wire, I have to use Bluetooth!
View attachment 208338
A friend of mine have this
View attachment 208339
It may worth a try then!
I suggest you tag @syssi in a message on your GitHub issue:

He has helped many other people debug issues giving indications how to run commands etc.

The project by @Sleeper85 is leveraging the syssi code for JK BMS <---> ESP32 communication. The main part of @Sleeper85 code is to take it from that point on, and handle the ESP32 <---> Inverter Communication.
 
Glad to hear that the Wire version works well with a JK-BMS SW version > 11.28 👌 ( @paulsteigel )

What framework do you use for Atom S3 Lite, ESP-IDF or Arduino?

What can name and protocol version did you choose?

What battery mode on the XP6000?

I am asking you these questions to add you to the list of compatible inverters.
Amen to the great work by the guys....

so did you have to add the device to wireless first to get its IP b4 flashing OTA ?
 
Many thanks @Sleeper85 for your information.
I don't have 11.XA version (I thought XA and XW might be the same) so I am not quite sure, mine is 11.XW (11.42) and I tried both using Arduino, esp32, none of them worked! I revise also the reading command "4E 57 00 13 00 00 00 00 03 03 (frame source 02-gps and 03 - pc) 00 85 00 00 00 00 68 00 00 01 AB" but failed also, no response at all! Chatting with JK-BMS guy but he did not reply! For this non-working over wire, I have to use Bluetooth!
View attachment 208338
A friend of mine have this
View attachment 208339
It may worth a try then!
@Sleeper85
Should i expect the Jk versions posted to work with wire on these new versions of the scripts?

I intend to try it when i am back from holiday...
 
I suggest you tag @syssi in a message on your GitHub issue:

He has helped many other people debug issues giving indications how to run commands etc.

The project by @Sleeper85 is leveraging the syssi code for JK BMS <---> ESP32 communication. The main part of @Sleeper85 code is to take it from that point on, and handle the ESP32 <---> Inverter Communication.
I talked to Syssi already on that and he did not response yet! Problem is on the BMS side, not him! I did a fork from his component and tested with uart reading command but nothing worked at all. JK seems to have problem with 11.XW version (for firmware later than 11.36 and 11.42 - I have those two in hand but none of them work on wire option) and they did not reveal the reason but saying that 11.42 XW does not support pulling data from GPS port using the known protocol!
I also used Arduino nano for quicker testing and no option work! JK has changed to firmware's communication on those versions!
 
Last edited:
I talked to Syssi already on that and he did not response yet! Problem is on the BMS side, not him! I did a fork from his component and tested with uart reading command but nothing worked at all. JK seems to have problem with 11.XW version (for firmware later than 11.36 and 11.42 - I have those two in hand but none of them work on wire option) and they did not reveal the reason but saying that 11.42 XW does not support pulling data from GPS port using the known protocol!
I also used Arduino nano for quicker testing and no option work! JK has changed to firmware's communication on those versions!
OK, sorry, I didn't know that. Did you talked to him directly or just made that GitHub Issue ? Maybe it slipped through so many other issues, that's why I thought you could have pinged him directly and maybe he could have helped diagnose the problem a bit better since he has quite a bit of experience doing reverse engineering of these things.

Does the JK BMS Reply at all to ANY command ? Or send ANY data out ? Or it's like the port is basically dead ?

Now you are making me a bit scared since I recently purchased 2 new JK BMS ...

Should be this one I ordered (WITHOUT Heat-CAN or HC suffix): https://eu.nkon.nl/jk-bms-b2a20s20p.html

EDIT 1: @paulsteigel did you have a look at https://github.com/syssi/esphome-jk-bms/issues/309#issuecomment-1513618297 ?
ESP32 seems to be working whereas ESP8266 not: https://github.com/syssi/esphome-jk-bms/issues/309#issuecomment-1532177991 and also later posts.

EDIT 2: not sure if it makes a difference (probably not) and assuming the syssi software supports it ... Trying with the RS485 interface using JK BMS RS485 Adapter ?

EDIT 3: What about the "double" RS485 Port described in the GitHub Issues above, did you try both ports and force the CAN/RS485 switch in the APP ?

EDIT 4: https://diysolarforum.com/threads/h...een-and-power-button.33267/page-8#post-535839
 
Last edited:
Glad to hear that the Wire version works well with a JK-BMS SW version > 11.28 👌 ( @paulsteigel )

What framework do you use for Atom S3 Lite, ESP-IDF or Arduino?

What can name and protocol version did you choose?

What battery mode on the XP6000?

I am asking you these questions to add you to the list of compatible inverters.

Used ESPHome Web to first flash my esp32 s3 to get OTA support. ( @chaosnature )

ESP-IDF framework, Li-Ion for the battery setting on the inverter, PYLON protocol, here is a copy of my yaml.

yaml file @ pastebin

Today I had my wifi down for a few hours & I even pulled the power on the Atom for a few seconds without any interuption on the inverter, everything resumed just fine.

the app for eg4's 6000xp does report the wrong number of batteries ( 3 in parallel ( just have a 1 x 16s )) other then that, smooth sailing. :)
 
Last edited:
Used ESPHome Web to first flash my esp32 s3 and have OTA support. ( @chaosnature )

ESP-IDF framework, Li-Ion for the battery setting on the inverter, PYLON protocol, here is a copy of my yaml.

yaml file @ pastebin

Today I had my wifi down for a few hours & I even pulled the power on the Atom for a few seconds without any interuption on the inverter, everything resumed just fine.

the app for eg4's 6000xp does report the wrong number of batteries ( 3 in parallel ( just have a 1 x 16s ) other then that, smooth sailing. :)
Are you sure you have ENABLED a setting on the inverter side, in case BMS (ESP32) communication stops ? It seems a bit weird that it didn't trip the inverter when you rebooted the Atom S3 Lite.

On Deye that is BMS-Err_Stop-

Otherwise in case of communication loss it will go full power (max voltage & max current) ...
 
Are you sure you have ENABLED a setting on the inverter side, in case BMS (ESP32) communication stops ? It seems a bit weird that it didn't trip the inverter when you rebooted the Atom S3 Lite.

On Deye that is BMS-Err_Stop-

Otherwise in case of communication loss it will go full power (max voltage & max current) ...

I pulled the Atom power only 3,4 seconds & inverter kept powering my loads ( a few seconds might not be long enough to trigger communication loss but in past, on atom disconnect, the inverter throws a sad smiley face on the display, and stop power output ) .

Never did change any inverter bms error settings.
 
Last edited:
OK, sorry, I didn't know that. Did you talked to him directly or just made that GitHub Issue ? Maybe it slipped through so many other issues, that's why I thought you could have pinged him directly and maybe he could have helped diagnose the problem a bit better since he has quite a bit of experience doing reverse engineering of these things.

Does the JK BMS Reply at all to ANY command ? Or send ANY data out ? Or it's like the port is basically dead ?

Now you are making me a bit scared since I recently purchased 2 new JK BMS ...

Should be this one I ordered (WITHOUT Heat-CAN or HC suffix): https://eu.nkon.nl/jk-bms-b2a20s20p.html

EDIT 1: @paulsteigel did you have a look at https://github.com/syssi/esphome-jk-bms/issues/309#issuecomment-1513618297 ?
ESP32 seems to be working whereas ESP8266 not: https://github.com/syssi/esphome-jk-bms/issues/309#issuecomment-1532177991 and also later posts.

EDIT 2: not sure if it makes a difference (probably not) and assuming the syssi software supports it ... Trying with the RS485 interface using JK BMS RS485 Adapter ?

EDIT 3: What about the "double" RS485 Port described in the GitHub Issues above, did you try both ports and force the CAN/RS485 switch in the APP ?

EDIT 4: https://diysolarforum.com/threads/h...een-and-power-button.33267/page-8#post-535839
I will try another talk to him via discussion! It's weird that a friend of mine has done the reading successfully over hardware serial on esp8266 D1 promini but not on esphome. He did not use SoftwareSerial (of course esp8266 has problem with SoftwareSerial). Esp32-esphome use softwareserial too. I did try to day using arduino but it failed! I will build another Firmware in Arduino IDE to check for whatever message sent back by the JK-BMS in coming days (I gave up working on arduino and now have to be back with it). I have some programing skills and I did try all what you said. my JKBMS is brand new one!
Thanks!
Ngoc
 
This is normal, the PYLON protocol counts one pack per 5kWh of battery.
Pylon or Pylon+?

Are you telling me I will habe problems hitting 100 kwh 🤣?

IIRC when I was going through the rs485 registries for the Deye I also remember battery 1, battery 2,...

But then again in case of multiple batteries the inverter shouldn't really care... The Esp32 master can just send one average/min/max summary for one equivalent battery
 
Pylon or Pylon+?

Are you telling me I will habe problems hitting 100 kwh 🤣?

IIRC when I was going through the rs485 registries for the Deye I also remember battery 1, battery 2,...

But then again in case of multiple batteries the inverter shouldn't really care... The Esp32 master can just send one average/min/max summary for one equivalent battery

PYLON and PYLON+ I don't really know what impact this information can have on the inverter. This makes me think that I could change this in the multi-bms version.

How many packs do you have?
 
PYLON and PYLON+ I don't really know what impact this information can have on the inverter. This makes me think that I could change this in the multi-bms version.

How many packs do you have?
Right now 2 packs. 2 new being built. Space for 8 or maybe 10 in the garage.

Why should there be a limit?

Bms master should just give a high level overview to the inverter.

Or are you thinking about bms master internal CAN/RS485 registries to store the data to process?
 
Right now 2 packs. 2 new being built. Space for 8 or maybe 10 in the garage.

Why should there be a limit?

Bms master should just give a high level overview to the inverter.

Or are you thinking about bms master internal CAN/RS485 registries to store the data to process?

There should be no limit for a multi-bms bms Master Slaves version. (still needs to be developed).

I ask the question because if you wish you could test the multi-bms version (2x JK-BMS BLE) on the same Atom S3.

The first tests could begin in a few days.
 
There should be no limit for a multi-bms bms Master Slaves version. (still needs to be developed).

I ask the question because if you wish you could test the multi-bms version (2x JK-BMS BLE) on the same Atom S3.

The first tests could begin in a few days.
Wow, that's MUCH faster than I expected.

But how exactly do you want me to test on the same Atom S3 Lite ? I don't have a wired connection ...
 

diy solar

diy solar
Back
Top