diy solar

diy solar

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

Make sure you understand the differences between and the different aspects of networking:
- Routing
- Switching / Bridging
- NAT including OUTBOUND NAT
- Firewall (Input Rules, Forward Rules, Passthrough Rules, Output Rules, etc)

As well as Layer 2 vs Layer 3 stuff.

I myself have NOT gotten all of those sorted out.

Essentially unless you take good care of all of the above (plus others I'm sure) you risk sending some IP address to a subnet/interface that is NOT supposed to see them. Or you might be able to send traffic in one direction but not being able to get back the response (although that should be a bit better with statefull firewalls w.r.t. stateless firewall) because for instance one of the router rejected the request (or dropped the connection since it didn't know where it should go to).

In OPNSense this would trigger a default state rejection for instance as it doesn't make sense from a networking point of view to have that situation occur. But that was also one of the things I WAS doing.
- Routing
- Switching / Bridging
- NAT including OUTBOUND NAT
- Firewall (Input Rules, Forward Rules, Passthrough Rules, Output Rules, etc)

Apart from Passthrough Rules, Output Rules,

I thought I did - After all, I have been an Infrastructure Architect for over 9 years now after my Solution Architect roles... :unsure:
 
Also - a simple network question since we are on this topic

Router 1 - IP: 192.168.1.1 >>Device 1
Router 2 - PI: 192.168.0.1 >> Device 2

What is the best and most straightforward way to make both device talk to each other - I know its something to do with creating a static route between the 2 routers, but not really strongly looked into how.
will the static route config be just on ne router or on both?

thanks...

If router1 and router2 are the kind of router installed by your ISP you can't do much right.

If you want to discuss it, open a new topic because this type of discussion can quickly become long.
 
Well you can say it's "my problem", fair enough. It doesn't really help.

That being said, I am working on improving things. It just will NOT happen overnight.
I should investigate my problem because I believe it is a networking issue on a wireless extension I am having to run but I just don't have the time or inclination at the moment. I like copper connecting my things.
 
I should investigate my problem because I believe it is a networking issue on a wireless extension I am having to run but I just don't have the time or inclination at the moment. I like copper connecting my things.
I didn't try with this specific project but what about the WT32-ETH01 ? It's ESP32 NOT ESP32-S3 though ...

Or maybe LILYGO T-ETH-Lite ESP32-S3 ? -> https://www.cnx-software.com/2023/09/27/lilygo-t-eth-lite-esp32-s3-board-ethernet-poe/

There are some alternatives ... From M5stack I don't see a RJ45 / Ethernet base compatible with the ATOM Products.

You will anyway have some interface problem if you go ethernet (at least with M5Stack), because you will NOT be able to have Ethernet + UART + CANbus all at one. Only two of them I believe ... So either you get ethernet+canbus and have to rely on BLE (I'd say that's LESS reliable than WiFi), or you get wifi+canbus (but no ethernet), or wifi+ethernet, but then you do NOT get the main feature of the project ...
 
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:
Back
Top