diy solar

diy solar

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

Hitting up M5 store for more projects. Is the Atom s3 lite still the overall recommended solution for both single and multi BMS?

Not necessarily, it depends on your configuration, the number of JK-PB* or JK-B* BMS. A single Atom S3 is limited to the number of GPIOs available.
 
What protocol or lithium battery setting you're using in your battery?
If there is a PYLON option, try switching to that.
Thank you. I'm using Pylon emulation. I've tried with Pylon + and Pylon 1.2, but only connects once, at the beginnings, after a reset.
 
Not necessarily, it depends on your configuration, the number of JK-PB* or JK-B* BMS. A single Atom S3 is limited to the number of GPIOs available.
Thanks. Planning on 3 BMS BLE (now B*BMS). Will move to PB in near future. Should I just do a ESP32 Devkit with?
 
Thanks. Planning on 3 BMS BLE (now B*BMS). Will move to PB in near future. Should I just do a ESP32 Devkit with?

There are a lot of things I haven't tested myself yet. I recently returned from my trip. 3 simultaneous BLE supervision are some things you can try with an ESP32, obviously an ESP32-S3 (Atom S3) is more powerful.

We need people to test so if you have an ESP32 and 3x JK-B* then don't hesitate to do the test and give us some feedback.
 
Thank you. I'm using Pylon emulation. I've tried with Pylon + and Pylon 1.2, but only connects once, at the beginnings, after a reset.
Can you record a video of the inverter display while connecting?
Does it shows correct/proper values momentarily before disconnecting ??
 
Ok. I thought it was a section already here that I was unable to find. Will mess with this over the weekend.

In the board.yaml file of your choice, you must replace this section.

YAML:
canbus:
  # CANBUS NODE 1
  - platform: esp32_can
    id: canbus_node1
    tx_pin: 5
    rx_pin: 6
    can_id: 1
    bit_rate: 500kbps

With a few things like this (I'll let you choose your GPIOs):

YAML:
spi:
  - id: spi0_bus
    mosi_pin: 11
    miso_pin: 12
    clk_pin: 13

canbus:
  - platform: mcp2515
    spi_id: spi0_bus
    id: canbus_node1
    cs_pin: 21
    can_id: 1
    bit_rate: 500kbps
 
In the board.yaml file of your choice, you must replace this section.

YAML:
canbus:
  # CANBUS NODE 1
  - platform: esp32_can
    id: canbus_node1
    tx_pin: 5
    rx_pin: 6
    can_id: 1
    bit_rate: 500kbps

With a few things like this (I'll let you choose your GPIOs):

YAML:
spi:
  - id: spi0_bus
    mosi_pin: 11
    miso_pin: 12
    clk_pin: 13

canbus:
  - platform: mcp2515
    spi_id: spi0_bus
    id: canbus_node1
    cs_pin: 21
    can_id: 1
    bit_rate: 500kbps
Thank you. Awesome, may give this a try again using BT with standard ESP DevKit and MCP.
 
Hi Guys,

I have 2 questions.

1. How do you stop the charge without stopping discharge....Currently, when the Charge switch is toggled off it also stop the discharge, i require this function.

2. I have been away for some time now since the last time I helped test the Multi-BMS release...what have i missed?
was the version I tested discontinued or developed upon.?

I can see Shunt's conversation in the mix....
 
Hi Guys,

I have 2 questions.

1. How do you stop the charge without stopping discharge....Currently, when the Charge switch is toggled off it also stop the discharge, i require this function.

2. I have been away for some time now since the last time I helped test the Multi-BMS release...what have i missed?
was the version I tested discontinued or developed upon.?

I can see Shunt's conversation in the mix....

@cinusik

The latest version (which I will publish this evening or this weekend) allows you to cut off the charge or discharge without decombining the BMS.

The shunts are not yet integrated.
 
What protocol or lithium battery setting you're using in your battery?
If there is a PYLON option, try switching to that.I have a DIY battery, and my inverter is a Turbo Energy (DEYE or SUNSYNK like). I do not know if the problem could be because the number of cells of my battery (is a 14S battery, instead a 15S).
 
1. How do you stop the charge without stopping discharge....Currently, when the Charge switch is toggled off it also stop the discharge, i require this function.
Physically, this requires BMS charge MOS to be OFF while BMS Discharge MOS to be ON.

Currently, the state of the CAN charging switch is coupled with BMS Charge MOS. Which basically means stopping charging turns off the BMS Charge MOS that in turn is likely sending a ALARM state that is shutting down everything.
I was wrong in my explanation.

This is the exact line coupling these two.
Code:
                      // +-----------------------------------------------+
                      // | Charge ON : BMS and CAN charging switch is ON |
                      // +-----------------------------------------------+
                      else if ((id(bms_switch_charging).state) & (id(can_switch_charging).state)) {

And can_id: 0x35C

Also Reminder/Warning: Exercise caution and proceed carefully.
Create a separate template switch for BMS charge MOS and turn OFF charging from there. Not the CAN Charge switch. And don't turn off MOS at too high of a current.

The code that I use on my own system has both decoupled.
 
Last edited:
Physically, this requires BMS charge MOS to be OFF while BMS Discharge MOS to be ON.

Currently, the state of the CAN charging switch is coupled with BMS Charge MOS. Which basically means stopping charging turns off the BMS Charge MOS that in turn is likely sending a ALARM state that is shutting down everything.

This is the exact line coupling these two.
Code:
                      // +-----------------------------------------------+
                      // | Charge ON : BMS and CAN charging switch is ON |
                      // +-----------------------------------------------+
                      else if ((id(bms_switch_charging).state) & (id(can_switch_charging).state)) {


Also Reminder/Warning: Exercise caution and proceed carefully.
Create a separate template switch for BMS charge MOS and turn OFF charging from there. Not the CAN Charge switch. And don't turn off MOS at too high of a current.

The code that I use on my own system has both decoupled.
This makes sense as my 40 amp breaker switch used to trip off when i set it in my automation to switch off during an activity.

so how exactly can I archive this?
I have 2 strings a(solis) and b(sofar)
As I do not have a way of integrating the second string (b) into HA to control charging via the Modbus command, I wanted to set it to charge manually 24/7 and the first string (a Solis) that I have an automation charging setup for, when it starts to charge it should stop the second string from discharging and when the Solis is not charging; set the second string to discharging.

I know based on your decoupling explanation I can archive this...but I just don't know how.
what do i change in the current code config.?

regards
 
In the board.yaml file of your choice, you must replace this section.

YAML:
canbus:
  # CANBUS NODE 1
  - platform: esp32_can
    id: canbus_node1
    tx_pin: 5
    rx_pin: 6
    can_id: 1
    bit_rate: 500kbps

With a few things like this (I'll let you choose your GPIOs):

YAML:
spi:
  - id: spi0_bus
    mosi_pin: 11
    miso_pin: 12
    clk_pin: 13

canbus:
  - platform: mcp2515
    spi_id: spi0_bus
    id: canbus_node1
    cs_pin: 21
    can_id: 1
    bit_rate: 500kbps
Having a lot of pin conflicts compiling the code, using this as my guide for my specific ESP. Pin 2 and 18 specifically are problematic. Will attempt again this evening.
 

Attachments

  • Image.jpeg
    Image.jpeg
    71.5 KB · Views: 3
Having a lot of pin conflicts compiling the code, using this as my guide for my specific ESP. Pin 2 and 18 specifically are problematic. Will attempt again this evening.

I am testing a classic ESP32 and 2 BMS (uart + ble) at home. I will release new code reducing loop time this weekend. I advise you to wait for the new version before testing 3x BMS BLE with ESP32.

But in the meantime you can already prepare your code for the MCP2515 with a single BMS.

Do not take gpio 1, 2 and 3.

You can take 21, 22, 23 for spi and gpio 4 for cs_pin. To test.
 
@gracarpes
I do not know if the problem could be because the number of cells of my battery (is a 14S battery, instead a 15S).
You said you're using a 14S battery.

Note that some of the charging parameters in the code depend on values reported by the BMS. Primarily max. cell voltage.

can you describe more of your 14S setup, cell type (Li-ion/LFP) and what charging values you're using in the YAML?
 
This makes sense as my 40 amp breaker switch used to trip off when i set it in my automation to switch off during an activity.

so how exactly can I archive this?
I have 2 strings a(solis) and b(sofar)
As I do not have a way of integrating the second string (b) into HA to control charging via the Modbus command, I wanted to set it to charge manually 24/7 and the first string (a Solis) that I have an automation charging setup for, when it starts to charge it should stop the second string from discharging and when the Solis is not charging; set the second string to discharging.

I know based on your decoupling explanation I can archive this...but I just don't know how.
what do i change in the current code config.?

regards
Sorry, I probably got it wrong. Have edited my post to reflect this.

However, there are exactly two locations in code where this is coupled:
can_id: 0x35C
data: !lambda |-
uint8_t can_mesg[2];
can_mesg[0] = 0x00;
can_mesg[1] = 0x00;

// Bit 7 : Charge enable
if ((id(bms_switch_charging).state) & (id(can_switch_charging).state))
can_mesg[0] = 0x80;

and the above mentioned charging logic loop.
This is as simple as removing id(bms_switch_charging).state from both the if statements.

Regarding charging Manually using HA.
I want to know how exactly you've set-up these two strings together?
If they're battery banks connected together in parallel accessed from a common busbar, they will follow the exact same voltage. Which is the same as saying they will charge and discharge together as one unit.
 
@cinusik

The latest version (which I will publish this evening or this weekend) allows you to cut off the charge or discharge without decombining the BMS.

The shunts are not yet integrated.
That will be great as for now if you turn off charging or discharging on one battery decombining is happening immediately.
But when I turn off charging on my both batteries that is causing ESP loosing HA connection and CAN connection - this also will be reworked or this is intentional?

I will release new code reducing loop time this weekend.
Will you do this optimisation also in development tree for RS485 or it is just for BLE version?
 
I am testing a classic ESP32 and 2 BMS (uart + ble) at home. I will release new code reducing loop time this weekend. I advise you to wait for the new version before testing 3x BMS BLE with ESP32.

But in the meantime you can already prepare your code for the MCP2515 with a single BMS.

Do not take gpio 1, 2 and 3.

You can take 21, 22, 23 for spi and gpio 4 for cs_pin. To test.
Got past the PIN error during esphome config, think I've got it right. Now I'm having issues with .platformio during RUN. I'm compiling/running on MacOS, wonder if that has something to do with the errors. I've had similar issues in the past but not his many. The path is correct for the local install for .platformio

Code:
ModuleNotFoundError: No module named 'pkg_resources':
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/platformio/builder/main.py", line 173:
    env.SConscript("$BUILD_SCRIPT")
  File "/Users/adminuser/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 612:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/Users/adminuser/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 279:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/Users/adminuser/.platformio/platforms/espressif32/builder/main.py", line 312:
    target_elf = env.BuildProgram()
  File "/Users/adminuser/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Util/envs.py", line 251:
    return self.method(*nargs, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/platformio/builder/tools/piobuild.py", line 61:
    env.ProcessProgramDeps()
  File "/Users/adminuser/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Util/envs.py", line 251:
    return self.method(*nargs, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/platformio/builder/tools/piobuild.py", line 121:
    env.BuildFrameworks(env.get("PIOFRAMEWORK"))
  File "/Users/adminuser/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Util/envs.py", line 251:
    return self.method(*nargs, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/platformio/builder/tools/piobuild.py", line 347:
    SConscript(env.GetFrameworkScript(name), exports="env")
  File "/Users/adminuser/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 676:
    return method(*args, **kw)
  File "/Users/adminuser/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 612:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/Users/adminuser/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 279:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/Users/adminuser/.platformio/platforms/espressif32/builder/frameworks/espidf.py", line 29:
    import pkg_resources
 
That will be great as for now if you turn off charging or discharging on one battery decombining is happening immediately.
But when I turn off charging on my both batteries that is causing ESP loosing HA connection and CAN connection - this also will be reworked or this is intentional?

The CAN bus connection will not be stopped while a BMS is combined. You can turn off the charging or discharging but if you stop both then the BMS will be decombined.

Will you do this optimisation also in development tree for RS485 or it is just for BLE version?

For all BMS yaml.
 
Got past the PIN error during esphome config, think I've got it right. Now I'm having issues with .platformio during RUN. I'm compiling/running on MacOS, wonder if that has something to do with the errors. I've had similar issues in the past but not his many. The path is correct for the local install for .platformio

It looks like you are missing the "pkg_resources" module.

Code:
ModuleNotFoundError: No module named 'pkg_resources':
 
Sorry, I probably got it wrong. Have edited my post to reflect this.

However, there are exactly two locations in code where this is coupled:
can_id: 0x35C
data: !lambda |-
uint8_t can_mesg[2];
can_mesg[0] = 0x00;
can_mesg[1] = 0x00;

// Bit 7 : Charge enable
if ((id(bms_switch_charging).state) & (id(can_switch_charging).state))
can_mesg[0] = 0x80;

and the above mentioned charging logic loop.
This is as simple as removing id(bms_switch_charging).state from both the if statements.

Regarding charging Manually using HA.
I want to know how exactly you've set-up these two strings together?
If they're battery banks connected together in parallel accessed from a common busbar, they will follow the exact same voltage. Which is the same as saying they will charge and discharge together as one unit.
Thanks for your response

The strings are independent -
Solis x 2 Batteries in one Busbar (ESP32 Atom Lite with Display)
Sofar x 2 Batteries in one Busbar (ESP32 Atom Lite )

If it's going to be too complex, I might just wait for the new release as @Sleeper85 said earlier he is decoupling them in the next release.

Regards
 

diy solar

diy solar
Back
Top