diy solar

diy solar

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

I use multimeter to do the work when charging at current above 2A on both voltage and current. Then set the calibrated value once only. The rest is to keep the charge prolonged to bring the battery voltage as high as 3.45*16 and as low as 3.2*16 while maintaining delta voltage be lower than 150mV by reducing charge/discharge current limit!
Maybe, the approach that I am pursuing is different from yours but it make SOC link as much as possible to cell voltage at 3.2 and 3.4 or 3.45 point.
Charging voltage applied at the inverter is: 3.45*16 or 3.5* 16 depending on case (quality of battery cell)
To give more evidence on this, please see the attached image
View attachment 206865
When min cell is above the set level of 3.2 but soc fall below the EOD level (20% set by user at inverter side to allow inverter to cut off. I made also an automation to sync Inverter EOD SOC with esphome via GuyBW's integration for Luxpower Inverter), ESP32 will report the EOD level + 1.
View attachment 206866
But this one have JK SOC still at 50% when min cell is already 3.2V (discharge current is only 3A). So it should be safe if we stop discharging when SOC is at this high!
Using this approach will leave us not busy with matter of SOC inaccuracy why can still do a little with control on voltage (even this is not quite accurate as well when cell voltage is not open circuit voltage - OCV)
When you calibrate voltage on the JK BMS you MUST do it a NO-LOAD: ZERO CURRENT. Open the breaker / disconnector / disable charge and discharge. Let them settle for a while. Then calibrate the voltage measuring with a trustworthy multimeter.
 
When you calibrate voltage on the JK BMS you MUST do it a NO-LOAD: ZERO CURRENT. Open the breaker / disconnector / disable charge and discharge. Let them settle for a while. Then calibrate the voltage measuring with a trustworthy multimeter.
Hi,
This is not for OCV or totally rest calibration. It is current calibration for JK to measure correctly! Both current and voltage are needed for Coulomb counting to work effectively. What I am focusing on is how to make JK work most effectively!
Best!
 
Hi,
This is not for OCV or totally rest calibration. It is current calibration for JK to measure correctly! Both current and voltage are needed for Coulomb counting to work effectively. What I am focusing on is how to make JK work most effectively!
Best!
Coulomb Counting is only Current. Coulomb = Current x Time [As] :) .

Voltage is more used to calculate Power (Voltage x Current) and determine end of Charge / Discharge (OVP / UVP).

EDIT 1: from your previous post, it rings familiar ... for a 16s LiFePo4 battery it stated I had 68% SOC / Capacity Left when the voltage was just 52.0 VDC ! In my case that was due to never bringing the cells high enough (voltage) and for long enough (time) so that they would effectively be fully charged and the SOC algorithm would correctly reset (same way as Victron Smartshunt: voltage > threshold e.g. 55.2 VDC, current < threshold e.g. 0.5% of Capacity Value in A, time > e.g. 10 minutes). Andy from Off Grid Garage made a great video about the Victron Smartshunt and how it works. I believe the JK BMS works in a very similar way (as the physics are the same).

 
Yesterday I was successful in getting the BLE version to work, but today the cable version is struggling for me.

My hardware = B2A20S20P-Heat-CAN, Atom S3 Lite on the CA-IS3050G.

can_tx_pin: GPIO5
can_rx_pin: GPIO6
tx_pin: GPIO1
rx_pin: GPIO2

All output I can see is more or less this, ( repeating )

00:37:26[D][esp32_ble_server:155]BLE Client connected
00:37:26[D][esp32_ble_server:164]BLE Client disconnected
00:37:30[D][esp-idf:000]E (185943) BT_HCI: CC evt: op=0x2022, status=0x2

Anyone :unsure: ?
 
Yesterday I was successful in getting the BLE version to work, but today the cable version is struggling for me.

My hardware = B2A20S20P-Heat-CAN, Atom S3 Lite on the CA-IS3050G.

can_tx_pin: GPIO5
can_rx_pin: GPIO6
tx_pin: GPIO1
rx_pin: GPIO2

All output I can see is more or less this, ( repeating )

00:37:26[D][esp32_ble_server:155]BLE Client connected
00:37:26[D][esp32_ble_server:164]BLE Client disconnected
00:37:30[D][esp-idf:000]E (185943) BT_HCI: CC evt: op=0x2022, status=0x2

Anyone :unsure: ?
So you are using one ESP32 for each connection or trying to combine into 1?
In case you are using 1: you need to be sure that the wire connection is made to a JK with firmware version is earlier than 11.28. Later than this, you will have to upgrade firmware to Version 15 (as told by JK engineer).
 
Yesterday I was successful in getting the BLE version to work, but today the cable version is struggling for me.

My hardware = B2A20S20P-Heat-CAN, Atom S3 Lite on the CA-IS3050G.

can_tx_pin: GPIO5
can_rx_pin: GPIO6
tx_pin: GPIO1
rx_pin: GPIO2

All output I can see is more or less this, ( repeating )

00:37:26[D][esp32_ble_server:155]BLE Client connected
00:37:26[D][esp32_ble_server:164]BLE Client disconnected
00:37:30[D][esp-idf:000]E (185943) BT_HCI: CC evt: op=0x2022, status=0x2

Anyone :unsure: ?
Are you sure tx/rx is not reversed? Did you connect the GND wire on the jk bms port to somewhere in your esp32?
 
So you are using one ESP32 for each connection or trying to combine into 1?
In case you are using 1: you need to be sure that the wire connection is made to a JK with firmware version is earlier than 11.28. Later than this, you will have to upgrade firmware to Version 15 (as told by JK engineer).

Ooh, well then that's probably it.

the BMS seems to have hardware version V11.XA and software version V11.43. Boooh.
 
So you are using one ESP32 for each connection or trying to combine into 1?
In case you are using 1: you need to be sure that the wire connection is made to a JK with firmware version is earlier than 11.28. Later than this, you will have to upgrade firmware to Version 15 (as told by JK engineer).
Would you mind pointing me in the right direction on how I can move forward in updating the firmware to v15?
 
Would you mind pointing me in the right direction on how I can move forward in updating the firmware to v15?
You can check here, he made details guidance and resource included then!
The guy from JK-BMS (engineer informed me that it needs to update to V15 but he provided no further information). I have tested this yet. Better using https://github.com/syssi/esphome-jk-bms/blob/main/esp32-ble-example-multiple-devices.yaml
This allow the ble to poll several BMS using a single ESP, I tested and it worked!
 
Last edited:
A bit side topic but ... How do you manage to get OTA working ?

I tried several approaches and none works so far :(

a. Using esphome run XXX.yaml -> This results in timeout failure during upload or similar other messages.
GitHub Issues and Home Assistant Forums seem to point to a Network Issue.
I am running this off a Rock 5B using hostapd and an Alfa AWUS1900 USB-Wifi Adapter (RTL8814AU).

b. Running esphome dashboard in a Podman Container (similar to Docker) doesn't really work.
I cannot do anything since autodiscovery doesn't work. If I add devices manually, there really isn't a "Firmware Upload" button or something similar.

c. Running esphome integration for Home Assistant I can see entities etc, but I cannot upload a new firmware.

d. Web Server does NOT support OTA on esp-idf framework (only on Arduino) according to documentation.
We are using esp-idf framework here ...
 
Last edited:
A bit side topic but ... How do you manage to get OTA working ?

OTA would only work after I had the Atom connected to my Wifi & assign the ( in my case ) jk-bms-can.local ( I edited hosts file ) to the ip of the wifi connected atom ( 192.168.x.x ).

esphome assisted me in flashing a firmware that would successfully connect to my wifi in the first place.

https://web.esphome.io/?dashboard_install
 
OTA would only work after I had the Atom connected to my Wifi & assign the ( in my case ) jk-bms-can.local ( I edited hosts file ) to the ip of the wifi connected atom ( 192.168.x.x ).

esphome assisted me in flashing a firmware that would successfully connect to my wifi in the first place.

https://web.esphome.io/?dashboard_install
I have my own DNS Server running so the DNS Record is correctly resolving to the IP Address (Static Lease on the DHCP Server) of the ESP32.

The problem is that the upload never goes past 10%. Sometimes it fails at 4%. Sometimes it gives up just after starting the upload process.

I also tries to restart the ESP32 in Safe Mode prior to OTA. Nothing :rolleyes: . The only thing that wants to work is a reliable USB cable :rolleyes:.
 
I have my own DNS Server running so the DNS Record is correctly resolving to the IP Address (Static Lease on the DHCP Server) of the ESP32.

The problem is that the upload never goes past 10%. Sometimes it fails at 4%. Sometimes it gives up just after starting the upload process.

I also tries to restart the ESP32 in Safe Mode prior to OTA. Nothing :rolleyes: . The only thing that wants to work is a reliable USB cable :rolleyes:.

Can you post your ota config and if using BLE Version also the on_boot part please
 
I have my own DNS Server running so the DNS Record is correctly resolving to the IP Address (Static Lease on the DHCP Server) of the ESP32.

The problem is that the upload never goes past 10%. Sometimes it fails at 4%. Sometimes it gives up just after starting the upload process.

I also tries to restart the ESP32 in Safe Mode prior to OTA. Nothing :rolleyes: . The only thing that wants to work is a reliable USB cable :rolleyes:.

Try to ping the atom and look for potential time outs, or perhaps install esphome on a different computer, and try with a host file ( but yes DNS resolve should be equally good ). Many moving parts here. 😵‍💫
 
Wonder if part of my problem is related to my BMS being a CAN/heat model, and maybe had the RS485 deactivated? Or was assigned different GPIO's as such?

Has anyone been able to get cable working with HW v11.XA / SW v11.43?
 
Wonder if part of my problem is related to my BMS being a CAN/heat model, and maybe had the RS485 deactivated? Or was assigned different GPIO's as such?

Has anyone been able to get cable working with HW v11.XA / SW v11.43?
No 11.43 will not response to request data command as I have mentioned (my version 11.36, 11.42 does not work on wired connection anymore, the "4E:57:00:13:00:00:00:00:06:02:00:00:00:00:00:00:68:00:00:01:28" command does not work! I have not upgraded to V15 as guided by JK-BMS guy as I have not seen any guidance on that and not sure the V15 is supported the upgrading from V11. The only way that seems possible is to use Bluetooth for multiple BMS (my previous pose has the link but I have not tried yet)
 
Try to ping the atom and look for potential time outs, or perhaps install esphome on a different computer, and try with a host file ( but yes DNS resolve should be equally good ). Many moving parts here. 😵‍💫
Tried on several computers. Ping works. Host file tried previously to no avail...
 
A bit side topic but ... How do you manage to get OTA working ?

I tried several approaches and none works so far :(

a. Using esphome run XXX.yaml -> This results in timeout failure during upload or similar other messages.
GitHub Issues and Home Assistant Forums seem to point to a Network Issue.
I am running this off a Rock 5B using hostapd and an Alpha AWUS1900 USB-Wifi Adapter (RTL8814AU).

b. Running esphome dashboard in a Podman Container (similar to Docker) doesn't really work.
I cannot do anything since autodiscovery doesn't work. If I add devices manually, there really isn't a "Firmware Upload" button or something similar.

c. Running esphome integration for Home Assistant I can see entities etc, but I cannot upload a new firmware.

Make sure your code uses the ota declaration in the main yaml like so.
Code:
logger:
  level: ERROR

ota:

then run these commands one after the other in the terminal.
Code:
esphome compile .\jk-hybrid-can.yaml

esphome upload .\esp32_hybrid_jk-bms-can.yaml --device 192.168.1.113

substitute Local IP and filename as usual.
d. Web Server does NOT support OTA on esp-idf framework (only on Arduino) according to documentation.
We are using esp-idf framework here ...
This is different with the main OTA capability mentioned earlier.
with esp-idf, the web-server will not allow uploading OTA binaries. That's all.
 
Can you post your ota config and if using BLE Version also the on_boot part please

I have the problem on several (all) projects.

===================================================================

For my modified @Sleeper85 code.

The ota part:
YAML:
ota:
  safe_mode: true
  version: 1
  password: !secret ota_password
  on_begin:
    then:
      - lambda: id(enable_bluetooth_connection).turn_off();
      - logger.log: "BLE shutdown for flashing"

The on_boot part is stock @Sleeper85:
YAML:
esphome:
  name: ${name}
  platformio_options:
    board_build.flash_mode: dio
    build_flags:
      - -DCONFIG_ARDUINO_LOOP_STACK_SIZE=32768
  comment: ${device_description}
  project:
    name: !secret project_name
    version: !secret project_version
  on_boot:
    then:
      - switch.turn_on: can_switch_charging
      - switch.turn_on: can_switch_discharging
      - switch.turn_on: can_switch_float
      - switch.turn_on: can_switch_auto_charge_current
      - switch.turn_on: can_switch_auto_discharge_current
      - switch.turn_on: can_switch_auto_charge_voltage

Full YAML file: https://github.com/luckylinux/jk-bm...main/esphome-jk-bms-can/esp32-ble-1.17.5.yaml
Secrets (example) file: https://github.com/luckylinux/jk-bms-build-helpers/blob/main/secrets.sh.example

===================================================================

For my forked esphome-for-deye which I adapted (work in progress) in a more modular approach and supporting many more RS485 registers (also off-grid ones) compared to the original.

The ota part:
YAML:
ota:
  safe_mode: true
  version: 1
  password: !secret ota_password

BLE is not used (but maybe still turned on ?). Unsure ...


Full YAML file: https://github.com/luckylinux/esphome-for-deye/blob/main/esphome-config-common.yaml
Secrets (example) file: https://github.com/luckylinux/esphome-for-deye/blob/main/secrets.sh.example


===================================================================

Now that i upgraded ESPHome using pip, another thing could be to try "version: 2" in the "ota" section.
From what is written on ESPHome OTA component, the version 2 should be more stable (previously the "version" declaration was not supported, so I assume it was using "version 1").

Anyway, it would NOT let me upgrade the ESP32 devices using the default OTA "version: 2", so I had to use "version: 1" for the (unsuccessfull) upgrade.

Now I could in theory switch to "version: 2" though ...
 
Make sure your code uses the ota declaration in the main yaml like so.
Code:
logger:
  level: ERROR

ota:

then run these commands one after the other in the terminal.
Code:
esphome compile .\jk-hybrid-can.yaml

esphome upload .\esp32_hybrid_jk-bms-can.yaml --device 192.168.1.113

substitute Local IP and filename as usual.

This is different with the main OTA capability mentioned earlier.
with esp-idf, the web-server will not allow uploading OTA binaries. That's all.
I have

Code:
logger:
  hardware_uart: USB_SERIAL_JTAG
#  level: DEBUG # For Debugging only
  level: INFO # For Production
 
  ota:
  safe_mode: true
  version: 1
  password: !secret ota_password
  on_begin:
    then:
      - lambda: id(enable_bluetooth_connection).turn_off();
      - logger.log: "BLE shutdown for flashing"

And I simply do
Code:
esphome run ./esp32-ble-1.17.5.yaml

Why would it me propose ota flashing if that command isn't supposed to handle it ?
 

diy solar

diy solar
Back
Top