diy solar

diy solar

New Battery Heater controller - Home Assistant and ESPhome

Jazzmonger

Hacker at heart
Joined
Apr 29, 2022
Messages
157
Location
Wilder, Idaho
Some of us live in very cold climates and LifePO4 batteries don't do well below freezing. In fact, you can destroy your batteries by charging them when they're near 0 C. We have too much $ invested in our packs to not take good care of them.

I bought these heaters and they work great:

There are 4 of them producing a total of 45wx4= 180 watts at full power. 180/120=1.5 Amps

Now Im writing a control system that lets me fine tune the stable battery temp. I currently have an automation controlling them but there are a couple problems with this approach.
1) if home assistant server goes down, all bets are off
2) the heaters are either on or off, no in between.
1673714527075-png.129592

you can see the temps go from freezing to optimal, but the peak and valley are when home assistant crashed or unavailable and is unable to control the on/off switch.

To solve this, I ordered a smart controllable dimmer:
1673890302655.png
These dimmers don't work well for LEDS, but for controlling resistive loads like pad heaters should work fine.

The best way to control them is with an ESP. My go to for simple projects is a D1 Mini ESP8266.
1673890772617.png


The ESPHome code Im starting with is:

Code:
- platform: ac_dimmer
    id: dimmer1
    gate_pin: GPIO13
    zero_cross_pin:
      number: GPIO12
      mode:
        input: true
      inverted: yes
light:
  - platform: monochromatic
    output: dimmer1
    name: Solar Battery Heater Controller

This works great and I have a halogen light hooked to the outlet and it dims nicely.

1673891207516.png

Adding a PID controller to the heater will complete this.
"PID controllers are good at modulating an output signal to get a sensor reading to a specified setpoint. For example, it can be used to modulate the power of a heating unit to get the temperature to a user-specified setpoint."
The PID controller component in ESPHome is a very complete implementation and even includes an auto tune feature!


This should take my temp graph and turn it into something like this over time, ultimately creating a completely stable, single temperature to maintain the batteries at using the least energy to do so.

1673891537288.png
all the pieces are in place, now I just need to finish the code.
I find it amazing that all this stuff is available and easy to implement. I'll be posting this full project on my Github once Im done.


More soon!
 
Last edited:
Nice work and nice fun project in general!

Do you have any ideas on how you're going to tackle the 1st issue?

"1) if home assistant server goes down, all bets are off)

Like maybe a third party watchdog device? Perhaps a BMV-712 or SmartShunt with a temp probe and alerts set up.

Or just some other Linux box like an RPi or a rooted NAS with a daemon running which can log into the Home Assistant and check the code is still running? Maybe email when outage occurs.

Or perhaps a 'limp mode' where when heater pad control fails a relay goes open (where an NC contact goes closed) and some fixed resistor circuit powers the heaters at some medium default level so they can't get too cold.

Or if you think the Home Assistant isn't too stable for too many days on end, make a cron job on it to reboot itself once everyday in the middle of the night, or every once in awhile.

I guess there could be lots of ways to handle it, but I like the idea of having some 3rd party temp monitor like a Venus OS on another RPi with a temp monitor, and alerts set up so if the Home Assistant has an issue, you can get an alert when temp reaches some wider threshold, but still within limits...

I guess you also most likely have BMS low temp cutoffs as well for an ultimate failsafe...
 
Nice work and nice fun project in general!

Do you have any ideas on how you're going to tackle the 1st issue?

Already thought of that! local control is the way to go. I'll put a thermocouple between the batteries and test that as a secondary option.
I also consdidered hacking the rs485 messages with the esp to listen directly to the bms. this is totally doable, but I'll tackle this next winter when all my other projects are done and I have tons of time to stare at hex messages all day!
"1) if home assistant server goes down, all bets are off)

Like maybe a third party watchdog device? Perhaps a BMV-712 or SmartShunt with a temp probe and alerts set up.

Or just some other Linux box like an RPi or a rooted NAS with a daemon running which can log into the Home Assistant and check the code is still running? Maybe email when outage occurs.

Or perhaps a 'limp mode' where when heater pad control fails a relay goes open (where an NC contact goes closed) and some fixed resistor circuit powers the heaters at some medium default level so they can't get too cold.

Or if you think the Home Assistant isn't too stable for too many days on end, make a cron job on it to reboot itself once everyday in the middle of the night, or every once in awhile.

its pretty darn stable. Mostly, but like all other computers. its prone to issues from time to time.
and I have a cron job set up to restart every night at midnight.

I guess there could be lots of ways to handle it, but I like the idea of having some 3rd party temp monitor like a Venus OS on another RPi with a temp monitor, and alerts set up so if the Home Assistant has an issue, you can get an alert when temp reaches some wider threshold, but still within limits...

I guess you also most likely have BMS low temp cutoffs as well for an ultimate failsafe...
 
I finished this project and am quite pleased with the result. I keep the battery at around 65 degrees which is optimal. And using the least power to do so. I use 2 different temp sensors, one from the BMS via Solar Assistant, the secondary is a local Dallas sensor probe tied to the ESP32 (I'm playing with ESP32s now). The default sensor used is from the BMS, but if Solar Assistant or home assistant goes down, the the local probe takes over, even if home assistant goes down. All is controlled locally within the ESP32 using ESPHome and sends data back to Home Assistant so I can create pretty graphs like this!

The only bummer is that it's spring now (actually I'm seriously happy about that) so I don't get to see it in action when it's below zero outside, But I'm ready for next year now!


1679744894247.jpeg

Bms temp is the one to watch. Keeping a hulk of 1000 lbs of batteries at a constant temp is tricky, but the PID controller does an amazingly good job and within +/- 2 degree C! You can't ask for better than that.

Additional info regarding the PID controller is here

Anyone interested in the design can respond here and I'll post my configs and hardware. Thus was a fun project and I learned a LOT about batteries and PID controllers.

Jeff
 
Last edited:
Man I'm almost retired and would love to be able to do what you do. I learned solid state electronics and later PLC programming but hacking like you're doing is way over my head ATM. I was thinking of something simpler like a programmable Watlow temp controller I used n the 90's. Simple, relay or triac output to control low watt heating or relays for high current heating elements. Back then they were not much over $100 but very simple, reliable and versatile. May have to insert a voltage sensing relay to detect charging voltage present to prevent pack drain. Your solution however seems dirt cheap compared to what I know how to do!
 
I finished this project and am quite pleased with the result. I keep the battery at around 65 degrees which is optimal. And using the least power to do so. I use 2 different temp sensors,one from the BMS via Solar Assistant, one is a Dallas sensor probe tied to the ESP32. The default is the BMS, but if Solar Assistant goes down, the the probe takes over, even if home assistant goes down. All is controlled locally within the ESP32 using ESPHome and sends data back to Home Assistant so I can create pretty graphs like this!

The only bummer is that it's spring now (actually I'm seriously happy about that) so I don't get to see it in action when it's below zero outside, But I'm ready for next year now!


View attachment 141202

Bms temp is the one to watch. Keeping a hulk of 1000 lbs of batteries at a constant temp is tricky, but the PID controller does an amazingly good job and within +/- 1 degree C! You can't ask for better than that.

Additional info regarding the PID controller is here

Anyone interested in the design can respond here and I'll post my configs and hardware. Thus was a fun project and I learned a LOT about batteries and PID controllers.

Jeff
Hi @Jazzmonger
would you please share your ESPHome config.
Thanks!
 
Last edited:
Thermistor, transistor and relay, job done or you could be fancy and use a 741 op amp

Of course, but that's safe, and boring and what we did when we were kids... ?

@gamcock13
Granted, Home assistant is a bit of a steep learning curve, but being retired affords lots of time to figure this stuff out! I'm not a trained programmer, but logic skills (or PLC skills) get you most of what's needed. Start off small and build from there. It's an amazingly flexible platform and fun to interact with the community, both on Discord and the forums. There's TONS of help out there.

Jeff
 
Last edited:
Back
Top