Power budget
Battery life is one number — the average current — and it is almost never set by the thing you think. Wi-Fi bursts are cheap. The power LED nobody removed is not.
Switch parts in and out, then compare "always awake" against deep sleep. Watch what the power LED does to the second number.
Average is the only number that matters
A battery's rating is in milliamp-hours: 2000 mAh will supply 2000 mA for an hour, or 1 mA for 2000 hours. Divide the capacity by your average current and you have the life.
Peaks matter for a different reason — the supply has to survive them without the rail sagging — but they contribute almost nothing to the total if they are short. An ESP32 that wakes, connects and sends — call it 120 mA for six seconds every fifteen minutes — averages 0.8 mA from the radio. Six seconds in nine hundred is two thirds of one percent of the time.
Where the current actually goes
| Item | Draw | Notes |
|---|---|---|
| ESP32 awake, radio on | 120–240 mA | In bursts, so cheap on average |
| ESP32 awake, radio off | ~40 mA | Expensive if it never sleeps |
| ESP32 deep sleep | ~10 µA | The reason sleep works at all |
| Power LED on a dev board | 3–10 mA | Never sleeps. Usually the biggest cost |
| AMS1117 linear regulator | ~5 mA quiescent | Never sleeps either |
| DHT22, LM75, most sensors | 1–2 mA | Only while being read |
The arithmetic that decides a project. An ESP32 asleep at 10 µA lasts about twenty years on an 18650 — on paper. Add one 5 mA power LED and it lasts sixteen days. The sleep code was never the problem.
That is also why the radio is the wrong thing to optimise first. Averaged out it is smaller than the LED sitting next to it and smaller again than the regulator — and unlike either of them, it is buying you something.
Getting from days to months
- Deep sleep between readings. One line of code, and it changes the answer by three orders of magnitude.
- Remove or disable the always-on parts. Desolder the power LED, or pick a board that has none. Replace a linear regulator with a buck converter, or feed 3.3 V straight in and bypass it.
- Wake less often. This is worth doing only after step 2. Switch the LED and the regulator off in the figure above and the interval suddenly moves the answer by more than an order of magnitude; leave them on and no interval gets you past about a fortnight.
- Cut connection time. Most of an ESP32's awake period is spent getting onto Wi-Fi. A static IP and a stored channel can halve it.
Edit this page — content/fundamentals/electricity/power-budget.mdx
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.