I am researching a new project that I hope to work on this summer. I don’t know electronics very well but have friends who do. I want a temperature sensor in my hobby farm to report the min and max temps every day to HA so that I can track the GDD (growing degree days) and how bad the weather really is. I anticipate using an ESP32 with a temp sensor and a directional antenna. This will be several hundred feet from my house so I will have to use a battery for power. I was planning to use a LiFePo4 due to cold winter weather (usually 0F each winter, sometimes -10F). My question is can a DC converter manage the battery voltage properly? I have read that when it is fully charged the battery can supply 3.6v, which will damage/fry the ESP32. So, the DC converter must adjust the voltage to 3.3v. But, the battery nominally generates 3.2v, so the converter would then have to boost the voltage. Can a single DC converter do both tasks? Or do I need 2 converters and route the power based on the battery voltage? If I need 2, how to set it up (just high level suggestions please). Or some other scheme? I also plan to use a ‘fuel guage’ circuit and send the temp data and battery status to HA.
There are a heap of boards for sale on the web for this purpose - some ridiculously cheap. Google “power supply and charging board for ESP32”.
Here’s the first one that popped up in my search. Not sure I would recommend it but there are plenty out there. Some support solar charging.
Where did you read that?
The datasheet for most 3V3 devices (esp32 included) lists 3V6 as the maximum.
This might help:
You are also going to need some way of charging the cell like a small solar panel. The cell could be buried below the ground. It will be a problem charging the cell at those temperatures. I use a mechanical thermostat to prevent charging when below freezing.
Leave out the converters, they destroy your battery life.
Like neel-m wrote, at 3.6V you are still within specs of Esp.
And it doesn’t get fried even if you go to 3.65V, which is common charge voltage.
But there are two things you need to be aware: You have to reduce the charge current if you go below 0’C. And somehow you need to manage the over discharge protection. Either with battery protection circuit or taking care of the level manually. Esp will turn off before you reach that level ~2.5V, but your circuit might keep on drawing some current, so you can’t just “forget” it for days.
Dont forget to monitor the cell voltage with adc pin and probably a voltage divider to protect that pin. Pick your Esp32 carefully so its not using power to run unnecessary bits.
Thank you for the helpful info. I am a bit embarrassed to say that the comment about 3.6 v damaging an ESP32 came from an AI summary of googling ESP32 power requirements. I should have read the actual datasheet! I don’t think that charging a LiFePo4 battery below freezing will cause it to explode, but it will either kill it or shorten the life. I live in New England and we can be below freezing for weeks at a time, so solar charging isn’t a cost effective option, though I did seriously consider it. My plan is to use 2 batteries and swap them as needed. Then charge the tired battery in the house. I want to setup the battery compartment so the 2 are in parallel and I can add the second before taking out the first so that existing data is preserved. Or is there some memory in the ESP32 that is preserved during power loss? Yes, I would need to add circuitry to prevent a sudden current rush from the new battery to the ‘tired’ one. That is why I will include the ‘fuel guage’ circuit and include the batter status in the temp update message. @Spiro I don’t understand what you mean about monitoring the adc pin and using the voltage divider. Like I said, I am not an electronics expert. I have some basic knowledge and am learning fast. I have more ESP32 projects in mind also.
To see how full the cell is you measure it’s voltage using an analogue to digital pin on the ESP. The pins that can be used may be able to take up to 3V (3.6V would be pushing it a bit far) If you use a voltage divider (basically 2 resistors, but your friends will know this) you can reduce that voltage to the point where you can read it from the adc pin without damage. Even with deep sleep used the cell will not last long unless perhaps you are only waking it up once a day to take a temperature reading.
depends on the cell. I bet this one would last longer than most people need.
Anytime you are doing something battery powered you REALLY have to manage your power consumption and many esp32 boards are really bad at that.
That is not good idea, if you need more battery life, buy beefier battery.
Prefer protected one.
Get 500ft of outdoor rated CAT5 (for $50) and run the esp32 on PoE. Cheap, easy and it will always work! No batteries or solar required.
100 feet of cat5 laying on the surface of a farm environment may not last very long exposed to the elements. It would also be difficult to bury it deep enough in a field to be protected from ploughing and heavy machinary like a tractor going over it. Going deeper or heavier protection will drive up the price.
I run a outdoor temp sensor that wakes every 5 mins on an ESP12F with an 80mm solar panel at a much higher latittude (54 degrees) than New England and it can run year round. Temp here rarely goes below -5C so don’t have to protect the 400mAh cell inside as much as you would need at -27C.
Until it doesn’t.
I have got wirings damaged from frost, rodents, lawn mower etc. But wireless is poor lunch for mice…
So far everyone has been focusing on the battery, which is probably because that is the question you asked.
Several hundred feet and Wi-Fi is going to be challenging. You did not specify the terrain, nor the foliage, not any obstructions, which could make it even worse.
I would (and did for my project) start with how are you going to get the communication to work reliably over that distance. I have my well a few hundred feet from the house. Standard Wi-Fi would be extremely challenging at that distance. Lora is my current plan. I took a USB battery bank and my node to the location to see how reliable the connection would be. Lora looks like it will work just fine just about anywhere on my property, which is mostly wooded.
So, with the communication plan sorted. I can focus on the power and other things. Note that esphome does not currently support Lora and the state of Lora is currently not easy. For power, I am going old school, 12V SLA, solar panel, charge controller. I started down that path, since I had planned on using a commercial sensor that requires 12V and this seemed the easy way to get it.
At the barnyard, I have 6V SLA batteries powering some feeders. I have extra batteries and swap them out when they get low. There is no monitoring needed and the last a long time.
For your system get a battery that will meet your power budget for long enough that it is not too painful to just change the battery. Your system should be designed to recover from a power failure, so you just need to swap batteries. You probably don’t need to make it more complicated.
But, start with how you are going to get communications to work over that distance first. It will likely be the challenge that will determine success or not.
Thank you everyone for the comments and suggestions. I have learned quite a bit and have many new ideas to investigate.
I am currently (still !) working on an ESP32 for my partners small (2m x 2m) hobby Orchid greenhouse in the back yard of our apartment block. We are renting and it is not feasible to run power or Ethernet out to the greenhouse.
Most of my attention has been on my power module - a 6600mAh Li-Po plus “DFRobot Solar Power Manager 5V” plus 5V solar panel. In bench testing I found that the power “Manager” board does not manage anything - not even reporting the battery voltage ! I’m at Sydney Australia (so no sub-zero temperature complications) but I do anticipate bad weather lasting several days which could run the battery flat. They obviously think it’s OK for our projects to just die because the battery ran flat without any warning.
power
So many considerations, especially if you use LiFePo4 batteries which are not commonly supported, and your sub-zero temperatures.
-
Do not connect a battery directly to the ESP32’s 3.3V. Fortunately yes, there are plenty of DC/DC buck/boost breakout boards which will boost when battery is below 3.3v and reduce when the battery voltage is higher.
-
If you want to leave the battery in place and charge it there (probably from solar panel) then Adafruit bq25185 USB / DC / Solar Lithium Ion/Polymer charger is one of the few that claims to support LiFePo4 batteries - and be very careful that your charger matches your battery’s chemistry.
-
Most newer ESP32 boards have USB-C connectors, and the LDO circuitry to supply steady 3.3V to both the ESP chip and external sensors. There are more easy options to supply your ESP32 with 5V power … but the trade-off is that it will be slightly less efficient boosting to 5V then reducing 5V to 3.3V.
- If you want to swap 5V batteries … yesterday I came across Adafruit LM66200 Ideal Dual Diodes Breakout which “provides seamless hot-swap between 2 5V power sources while avoiding back-powering”. If you’re wanting similar but a bit less soldering, then Pi-Hut sell the 5V USB-C Dual Supply - Dual Ideal Diodes with 2 USB-C sockets for connecting your batteries, and 1 USB-C out to your ESP32 … or for old school they have some with 2 micro-USB inputs and a double USB-A socket output.
-
I understand your valid reasons for swapping LiFePo4 batteries, but that will probably eliminate off-the-shelf solutions. However I note the Adafruit LM66200 Ideal Dual Diodes Breakout states “Input voltage range: 1.6 V to 5.5 V”, so it looks like it would do the job for your battery voltage range, albeit with you having to wire up your own connectors to allow the batteries to be easily connected/disconnected.
-
You will definitely want to monitor your battery’s voltage, and this can be done with 2 resistors as others have said … but my soldering is terrible and so I found plenty of power/battery monitors like INA228 (I tried an LC709203, but was not impressed with the battery %age it produced).
To reduce the power required I also implemented deep_sleep - which actually powers the ESP32 off and reboots it later - leading to other complications (like needing a latching relay for the low voltage scenario).
wi-fi communications
I definitely agree with Neel’s recommendation that you first check the wireless communication at your location. Most ESP32’s have a tiny ceramic aerial or a slightly larger PCB aerial. For your distance you may need something better, such as an external directional wi-fi aerial, or to go with a different communication standard. Some ESP32 modules/boards have a u.FL connector for attaching an external aerial.
Home automation is a wonderful subject providing so many rabbit-holes to get lost down Have fun and good luck !
May I know reason for that?
Esp32 has operating voltage range that matches perfectly with Lifepo4 cell voltage from 100% to 0 capacity.
Do you call it slightly less efficient when you loose at least half of the battery capacity in unnecessary conversions (~20% on boost and again 35% on down conversion).
@donburch888 ‘Home automation is a wonderful subject providing so many rabbit-holes to get lost down Have fun and good luck !’ You have that right! The more you learn and think about a project the more ‘opportunities’ you find. For example, just yesterday I realized that maybe Home Assistant could update my master spreadsheet. So the question (maybe not for this forum) is: can HA edit a Libre Office Calc spreadsheet? I am also planning an ESP32 based irrigation controller. It would be helpful if HA could put both pieces of data into the spreadsheet.
Yes, I realize that Wifi range is critical, but I don’t know how to determine sufficient connection strength without the actual device. I am planning to use a ESP32 connected to an external unidirectional antenna. If that doesn’t work I may have to use some kind of extender or repeater. Of course, that will be powered by a battery also - more challenges. An ESP32 can work in both AP and point-to-point mode simultaneously, so that might be an answer.
Again, a big Thank You for all of the comments and suggestions! They have really helped.
Do you have some to suggest?
I haven’t selected one yet, but googling ‘ESP32 unidirectional antenna’ yields many discussion threads and options. A RF engineer friend told me that ‘yagi’ (type, not brand) are the best. I only have to go about 300 ft (100 m) through a few trees on flat land, so I think that it should be successful (I hope). Some are claiming 500 m through clear space. Look for 6 to 10 db gains and ESP32 with a ‘u’ prefix - no internal antenna. Though some ESP32s have the internal antenna connected via a 0 Ohm resister and an empty external connector. Remove the resister (easier said that done!) and you can use the external connector. There are several youtube videos that discuss this.