• Have you tried out dark mode?! Scroll to the bottom of any page to find a sun or moon icon to turn dark mode on or off!

diy solar

diy solar

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

I think the best for your case would be to use the LilyGo T-Connect (ESP32-S3) board with 3x RS485 and 1x CAN like @rasterer did.

You need to specify 3x RS485 modules and 1x CAN module when ordering.
@MrPablo can help you as he has already ordered several boards.

Otherwise you can build your PCB with 2x RS485 + 1x CAN interfaces.

For the configuration it is not very complicated, when you have the material I can prepare the YAML adapted to your case.


View attachment 276340
@Sleeper85 What have to be done with my current board if it can
 
Last edited:
Hi,

I have Deye SG04LP3 10K (3-phase) and seems in my case it working exactly as you desribed your wish :)
I just made a test:

- enabled GpS and set it to 5000W
- enabled enforced charging
- current limit is set high enough

then inverter is limiting the total grid power to the set 5000W (yeah, approximately...)
It does not matter if I enable or disable ToU, enforce charging wins, GpS limit is obeyed.

perhaps you need a firmware update?
Thanks for the advice. Maybe it's a bug in the 1p inverter software since it works for you.
 
How do you guys recommend I configure YamBMS with an EG4 inverter used as a UPS (no solar)?

If I configure the inverter to always charge and YamBMS to disable float charging, then it'll do a full charge and then YamBMS will disable charging until the SOC or V drops below the Rebulk threshold. This works exactly how it's supposed to, so no complaints there, but I also don't want to leave my batteries at 100% charge all the time since they'll rarely be cycled. However, the inverter will self-consume ~50W from the batteries and the current is low enough that the BMS doesn't detect it, so the SOC will not be accurate. Ok so the batteries won't remain at full charge and I can use the YamBMS Rebulk Voltage setting to have it charge again when the voltage falls too low, but now I'm constantly cycling the batteries and wasting electricity.

The inverter will not self-consume once it reaches 90% SOC (the highest I can set this), so I can have the inverter set to charge based on SOC, say 87% start and stop charging at 93%, but then YamBMS doesn't enter the cut-off state and doesn't block the float charging (something I cannot disable on the inverter side).

Any suggestions? One idea I have is I could use Home Assistant to automate this by:
- Set inverter to always charge
- Detect YamBMS going into the cut-off state in HA
- Have HA tell the inverter to go into discharge mode and then stop at 90% SOC (set off-grid EOD% to 50%, which will put it into full discharge mode, then set it back to 90% and it won't stop discharging until it hits 90%)
- Batteries should sit idle at 90% SOC without the inverter self-consuming.

I think I can also manipulate the inverter into not self-consuming by putting it into "AC First" mode (tested, could not without battery eco mode). I can also just disable auto charging on the inverter completely and rely on the YamBMS force charge settings. Anyway just looking for ideas that might not involve extra HA automation. I might also be guilty of way over thinking this.
 
Last edited:
I can't really stop this inverter from drawing .5-1A from the batteries at all times unless I enable battery eco mode, which did not work well when I tested cutting the AC input. The batteries will be cycling anyway so I've settled on:
  • Inverter: Charge by time 00:00 - 23:59, charge voltage 55.2V
  • YamBMS: 55.2V, disable float charging
So YamBMS will stay in the EOC / stop charging state until it falls below the Rebulk threshold from the inverter self-consuming, then YamBMS will switch to Bulk, then the inverter will start charging and do a full charge. The true SOC won't be known except by voltage, but it'll probably always be between 85-100%.
 
Last edited:
I’ve settled on setting the inverter to charge always, set the charge voltage in yambms to 54V, then use the rebulk voltage trigger to recharge when it gets low. Hopefully 54V is a good compromise for not leaving the batteries completely full 24/7 (and in a hot garage during the summer). My SOC won't be accurate, though, seems like I need to add a shunt to make it accurate. I think I might try to add the Victron Smartshunt to my setup.

54V is a good value to float your battery, but not higher because you can charge it to 100% by letting it float at this value.
 
Just noticing - I am on 1.5.4 now, and the SOC behavior feels weird. Today was dark clouds, no PV until 10am, at 10:09 73% SOC, pulling 2.5kw PV, but 1-2kw load, often less than 1kw charge current. At 10:30 it showed 75%, at 10:35 it hit 98%. This is how it is every day, but usually I dont pay much attention because on clear days I produce at 7am, by 9:30am it is pulling 10KW pv and it hits 98% SOC and charge drops to around 2~3kw, then 100% a couple hours of float later. But today, according to that math it topped up 5-6kw in 5 minutes while only taking a ~1kw charge.

My fresh LF280ks probably have less than 40 cycles, I imagine they are still ~300AH.
pb2a16s20p connected via RS485
No shunt since last discussion here how shunt is just so-so accurate as available AH varies based on current/temp/level.
 
Just noticing - I am on 1.5.4 now, and the SOC behavior feels weird. Today was dark clouds, no PV until 10am, at 10:09 73% SOC, pulling 2.5kw PV, but 1-2kw load, often less than 1kw charge current. At 10:30 it showed 75%, at 10:35 it hit 98%. This is how it is every day, but usually I dont pay much attention because on clear days I produce at 7am, by 9:30am it is pulling 10KW pv and it hits 98% SOC and charge drops to around 2~3kw, then 100% a couple hours of float later. But today, according to that math it topped up 5-6kw in 5 minutes while only taking a ~1kw charge.

My fresh LF280ks probably have less than 40 cycles, I imagine they are still ~300AH.
pb2a16s20p connected via RS485
No shunt since last discussion here how shunt is just so-so accurate as available AH varies based on current/temp/level.
You my have set your BMS parameters wrong. What is your 100% SOC, 0%SOC, RCV and RFV, Start balance voltages values and what firmware you have on your bms?
 
Just noticing - I am on 1.5.4 now, and the SOC behavior feels weird. Today was dark clouds, no PV until 10am, at 10:09 73% SOC, pulling 2.5kw PV, but 1-2kw load, often less than 1kw charge current. At 10:30 it showed 75%, at 10:35 it hit 98%. This is how it is every day, but usually I dont pay much attention because on clear days I produce at 7am, by 9:30am it is pulling 10KW pv and it hits 98% SOC and charge drops to around 2~3kw, then 100% a couple hours of float later. But today, according to that math it topped up 5-6kw in 5 minutes while only taking a ~1kw charge.

My fresh LF280ks probably have less than 40 cycles, I imagine they are still ~300AH.
pb2a16s20p connected via RS485
No shunt since last discussion here how shunt is just so-so accurate as available AH varies based on current/temp/level.

YamBMS corrects the SoC at each BMS level at the end of discharge only (detection of 0%, 2%) and at the general level at the end of charge max 98% during the Bulk phase.

To understand what happened to you, you should check what the real SoC of the BMS was at the time of the problem.

You must find the following sensors for each BMS:

  • Real BMS SoC: ${name} ${bms_name} battery capacity state of charge
  • Corrected BMS SoC: ${name} ${bms_name} Battery SoC

The sensor below is the combined general SoC of all BMS that will be sent on the CAN bus (the one that returns max 98% during the Bulk phase).

  • ${name} ${yambms_name} Battery SoC

With this information we can see where the problem comes from.
 
Is there any way to preserve YamBMS state when your esp32 restarts? Say I complete a charge, YamBMS is in the EOC / charge stop state, then I restart the esp32 and YamBMS returns to the bulk state, despite still being above the rebulk thresholds.
 
Is there any way to preserve YamBMS state when your esp32 restarts? Say I complete a charge, YamBMS is in the EOC / charge stop state, then I restart the esp32 and YamBMS returns to the bulk state, despite still being above the rebulk thresholds.
intention is to start from scratch after a RESET event.
Still if you want, you can enable restore_state for the charging status variable
 
What could be the reason for periodically losing some Yambms entity? After HA rebooting, they reappear, but after some time (a day or two), some sensors drop off again.
1739442736534.png
 
Got another question, any suggestions on how to adjust SOC? My inverter self-consumes about 0.6kWh per day from my batteries while idle, but the current draw is below the JBD BMS detection threshold. The result is the battery is constantly but slowly draining while the SOC remains at say 100%. I'm just wondering if there's a simple way I could compensate for this, eg subtract 5% from the SOC each day or like 0.2% each hour. I know the right way is to just add a Victron Smartshunt if I have to.
 
Got another question, any suggestions on how to adjust SOC? My inverter self-consumes about 0.6kWh per day from my batteries while idle, but the current draw is below the JBD BMS detection threshold. The result is the battery is constantly but slowly draining while the SOC remains at say 100%. I'm just wondering if there's a simple way I could compensate for this, eg subtract 5% from the SOC each day or like 0.2% each hour. I know the right way is to just add a Victron Smartshunt if I have to.
The right way is in fact the only way.
 
Got another question, any suggestions on how to adjust SOC? My inverter self-consumes about 0.6kWh per day from my batteries while idle, but the current draw is below the JBD BMS detection threshold. The result is the battery is constantly but slowly draining while the SOC remains at say 100%. I'm just wondering if there's a simple way I could compensate for this, eg subtract 5% from the SOC each day or like 0.2% each hour. I know the right way is to just add a Victron Smartshunt if I have to.

At the end of 2024 I developed a code that estimates the SoC of an LFP battery in increments of 5% based on the average cell voltage, temperature and current. I didn't publish it because it could still be improved, maybe it could suit you, I don't know...

The goal was to correct the SoC if there was too big a gap between the estimate and the SoC bms.
 
Got another question, any suggestions on how to adjust SOC? My inverter self-consumes about 0.6kWh per day from my batteries while idle, but the current draw is below the JBD BMS detection threshold. The result is the battery is constantly but slowly draining while the SOC remains at say 100%. I'm just wondering if there's a simple way I could compensate for this, eg subtract 5% from the SOC each day or like 0.2% each hour. I know the right way is to just add a Victron Smartshunt if I have to.
Add the shunt. Easy fix.
 
Got another question, any suggestions on how to adjust SOC? My inverter self-consumes about 0.6kWh per day from my batteries while idle, but the current draw is below the JBD BMS detection threshold. The result is the battery is constantly but slowly draining while the SOC remains at say 100%. I'm just wondering if there's a simple way I could compensate for this, eg subtract 5% from the SOC each day or like 0.2% each hour. I know the right way is to just add a Victron Smartshunt if I have to.
I have the same trouble with my Solis inverters and JK bms - even though it's shut off from discharge because of either Zero SOC, or a cell going below shut off threshold, it continues to draw current and several times one or two cells have gone to a near dangerous over discharged level. It's very frustrating that even though the JK has 'switched off', there continues to be a vampire drain on the battery. The only way I've solved this is by making a HomeAssistant automation that monitors the lowest cell and then switches it to grid charge for 20 mins to prevent it from going under safe voltage. Several times (before I made the automation) the JK would completely shut down the battery and no way of getting it back to life was possible from the inverter. Good job I had a power supply and ended up charging up directly on the battery terminals with that. I'm not sure how a Victron smart shunt would help this situation of vampire currents - the Victron would be able to track the current, but it still wouldn't stop the inverter from continuing to draw below the BMS's 'shut down'.
 
I'm not sure how a Victron smart shunt would help this situation of vampire currents - the Victron would be able to track the current, but it still wouldn't stop the inverter from continuing to draw below the BMS's 'shut down'.

I'm mitigating this by setting the inverter to charge 24/7, but YamBMS stays in the EOC/stop charging state so the inverter won't charge until YamBMS enters the Bulk state. Then the Rebulk voltage threshold on YamBMS will switch it to Bulk when the pack voltage gets low enough and then the inverter will do a full charge. Note I also have float charging disabled in YamBMS.

My BMS is also contactor based, though, so when it goes into protection mode I don't think it's possible for any current to flow at all.
 
Has anyone seen an issue where your inverter reports that charging is forbidden despite YamBMS being in the bulk state? I suspect this could be an issue on the inverter side (mine is an EG4 12000XP). I don't see anything relevant in the YamBMS debug logs and the inverter reports everything is well other than charging being forbidden. I haven't found any consistent way to reset it either.

In case it's relevant, CANBUS Inverter Heartbeat is 1200ms, and I think maybe turning the heartbeat monitoring on resets this condition. I'll have to test some more to verify that enabling the heartbeat monitoring resets it, but it could just be coincidence. EDIT: Looked at my data and it's too close to be coincidence, it started charging immediately when the switch was toggled.

Screenshot 2025-02-15 141234.pngScreenshot 2025-02-15 141348.pngScreenshot 2025-02-15 141531.png
 
Last edited:
Has anyone seen an issue where your inverter reports that charging is forbidden despite YamBMS being in the bulk state? I suspect this could be an issue on the inverter side (mine is an EG4 12000XP). I don't see anything relevant in the YamBMS debug logs and the inverter reports everything is well other than charging being forbidden. I haven't found any consistent way to reset it either.

In case it's relevant, CANBUS Inverter Heartbeat is 1200ms, and I think maybe turning the heartbeat on resets this condition. I'll have to test some more to verify that enabling the heartbeat resets it.

View attachment 278386View attachment 278388View attachment 278389
Yes, my 6k xp does that too, usually for a solid 5 minutes.
Sometimes it is longer and a reset of the esp is the solution to sync everything up.
 
Yes, my 6k xp does that too, usually for a solid 5 minutes.
Sometimes it is longer and a reset of the esp is the solution to sync everything up.
Are you using the LuxPower protocol as well? I've seen it sit like this for 12 hours, but restarting the esp32 doesn't immediately resolve it. Maybe it takes 5-10 minutes after resetting the esp32 and I'm getting too impatient and starting fiddling with things, eg I thought maybe enabling the heartbeat monitoring resolved it but I had also reset the esp32 10 minutes prior.

EDIT: Also mentioned above but I looked at my data and I'm positive that toggling the heartbeat monitoring switch cleared it, when I toggled the switch the inverter immediately started charging. If I have to I'll find a way to monitor the inverter charging status in HA and then toggle the heartbeat monitoring on and off if YamBMS is in the bulk state and the inverter shows charging is forbidden.
 
Last edited:
Are you using the LuxPower protocol as well? I've seen it sit like this for 12 hours, but restarting the esp32 doesn't immediately resolve it. Maybe it takes 5-10 minutes after resetting the esp32 and I'm getting too impatient and starting fiddling with things, eg I thought maybe enabling the heartbeat monitoring resolved it but I had also reset the esp32 10 minutes prior.

EDIT: Also mentioned above but I looked at my data and I'm positive that toggling the heartbeat monitoring switch cleared it, when I toggled the switch the inverter immediately started charging. If I have to I'll find a way to monitor the inverter charging status in HA and then toggle the heartbeat monitoring on and off if YamBMS is in the bulk state and the inverter shows charging is forbidden.
The heartbeat monitor shouldn't have anything to do with instructions to the inverter. It is simply looking at the acknowledgement packets I believe.

I have had success in the past by engaging the quick charge button . but that is probably a placebo. :)

Yes I used lux

Unplugging and re plugging the com cord seemed to work often.
 
The heartbeat monitor shouldn't have anything to do with instructions to the inverter. It is simply looking at the acknowledgement packets I believe.
I agree, but toggling that switch seems to have interrupted whatever is causing the issue. These data points are collected at 20s intervals, so you can see when I flipped the switch it started charging within about 20s, but it could possibly be when I disabled the heartbeat monitoring that it started charging.

EDIT: After being unable to replicate this again, I have to concede that this must have in fact been coincidence.

Screenshot 2025-02-15 171630.pngScreenshot 2025-02-15 171359.png
 
Last edited:
Has anyone seen an issue where your inverter reports that charging is forbidden despite YamBMS being in the bulk state?
This restriction may be independent of the BMS. It could occur due to inverter settings, for example, if the 'System Charge SOC Limit' is set lower than the current battery SOC, you'll see this 'forbidden' restriction in the web interface. This restriction will also appear if charging is disabled on the BMS. And after enabling it again, it takes about 10-12 minutes before the restriction disappears. This lag really annoys me in Lux.
 
This restriction may be independent of the BMS. It could occur due to inverter settings, for example, if the 'System Charge SOC Limit' is set lower than the current battery SOC, you'll see this 'forbidden' restriction in the web interface. This restriction will also appear if charging is disabled on the BMS. And after enabling it again, it takes about 10-12 minutes before the restriction disappears. This lag really annoys me in Lux.
Ahh yes, good point, If the bluetooth flakes out and yambms sends SOC of 2% the inverter will probably wait a while.
 

diy solar

diy solar
Back
Top