On a sheep farm outside Graaff-Reinet, a trough far from any plug needs a level reading four times an hour, sent over Wi-Fi to the farmhouse. The ESP32 is awake for seconds and asleep for minutes, so battery life depends on both currents and how often it wakes. This calculator turns them into an average current and days, and checks whether a small solar panel keeps up. The boards are on ESP32.
Awake, asleep and the average
The share of time awake is the awake seconds x wakes per hour / 3,600. The average current is the awake current times that share plus the sleep current for the rest. The battery's usable capacity divided by the average gives the hours. Usable is less than the label: cold nights, an ageing cell and the voltage at which the board browns out all take a share, so 80% is a sensible start. The battery's datasheet gives the real capacity at your current.
Worked example: four readings an hour
The defaults are a 2000 mAh cell, 80% usable, 120 mA for 5 seconds per wake while Wi-Fi sends, 0.15 mA asleep and 4 wakes an hour:
| Figure | Result |
|---|---|
| Awake share | 0.5556% |
| Average current | 0.8158 mA |
| Usable capacity | 1,600 mAh |
| Run time | about 1,961 hours, 81.7 days |
| Used per day | 19.58 mAh |
The table under the calculator runs the same device at other rates: once an hour lasts about 210.7 days, twelve times about 31 days, every minute only 6.6 days.
Sleep current decides the result
In the example the awake time costs about 0.67 mA on average and sleep about 0.15 mA, so both matter. Put the same code on a dev board with a USB chip, a power LED and a cheap regulator drawing 5 mA asleep, and the 81.7 days fall to 11.8. Measure the sleep current on the finished board with a multimeter in series before trusting any figure. Then shorten the awake time: a slow Wi-Fi connection costs more than the reading.
A small panel on the box
The solar fields work out the daily harvest: panel watts x sun hours x charge efficiency / battery voltage. A 1 W panel with 5 sun hours at 70% into a 3.7 V cell gives about 946 mAh a day, far above the 19.6 mAh used, so cloudy weeks and short winter days are what to size for. Past a year on one charge, the battery's own self discharge matters more than the load. Remote nodes are planned on IoT development.
Frequently asked questions
How long will an ESP32 run on a battery?
It depends far more on sleep current and how often it wakes than on the chip. A 2000 mAh cell that wakes four times an hour for 5 seconds lasts about 82 days with a good deep sleep design, and only days if the board stays awake or draws several mA asleep.
Why does my ESP32 battery die so fast?
Usually the dev board: its USB chip, power LED and regulator keep drawing current while the chip sleeps. Slow Wi-Fi connections are next. Measure the current in each state and type the figures in.
Which battery should I use for a sensor node?
A lithium cell with a protection circuit and a matching charger suits most ESP32 nodes, and AA cells suit very low drain designs. Check the battery's datasheet for capacity at your current and temperature, and ask the supplier about cells rated for outdoor heat.
Who will quote me for a battery powered sensor in Graaff-Reinet?
Embedded developers, IoT builders and electronics shops who work in and around Graaff-Reinet and the Karoo. Send the request on this page with what you want to measure and how often; we pass it on and they quote you directly. We build and sell nothing ourselves.
Read more
More tools
- Resistor colour codeFour, five or six colour bands, or a value, tolerance and band count: the resistance, its tolerance range, the bands in order and the nearest E12 and E24 values
- LED resistor calculatorSupply voltage, LED colour or forward voltage, current and LEDs in series: the exact resistor, the nearest E12 and E24 values, the current they give and the power rating
- Voltage divider calculatorInput voltage and two resistors, or the highest input and a safe output: the output voltage, ratio, current, power in each resistor, an E24 pair and the ADC step at the input
- Stepper motor calculatorStep angle, microstepping, belt and pulley or lead screw, speed and motor current: steps per mm, resolution, step rate, rpm and the driver's reference voltage
- PCB trace width calculatorCurrent, copper weight, temperature rise, layer and trace length: the minimum width in mm and mil, the trace's resistance, voltage drop and power lost
- Board pickerLogic voltage, pins, analogue inputs, radio, camera, Linux, battery and the kind of job: a short list of three board families with a reason for each
- PLC I/O calculatorField devices, spare capacity and module sizes: digital and analogue I/O counts with spare, the modules to fit and the points left free
