How long a cell lasts
Hours on a cell is its capacity divided by the average current. Wi-Fi left on spends a 1000 mAh cell in about 7 hours; waking for six seconds every fifteen minutes stretches it to weeks — and then the board's own current while asleep decides how many.
Capacity over the average
1000 mAh is 1000 mA for an hour, or 1 mA for a thousand hours. Divide the capacity by your sketch's average current and you have the run time. Count on about four-fifths of the label, because the last of the cell sits below the voltage the regulator can use.
Three ways a sketch can run
On a 1000 mAh cell:
| The sketch | Average | Lasts |
|---|---|---|
| Wi-Fi connected all the time | about 120 mA | about 7 hours |
| Awake, radio off | about 45 mA | about 18 hours |
| Wake every 15 minutes, 6 s of Wi-Fi, chip asleep at 10 µA | about 0.81 mA | about 41 days |
| The same, with the board drawing 1 mA asleep | about 1.79 mA | about 19 days |
The first two are why a battery project sleeps. The last two are why the sleep current matters as much as the sketch.
Asleep is where a dev board leaks
In deep sleep the ESP32 chip draws about 10 µA. The board around it does not sleep: the regulator keeps regulating, and everything else connected to the 3.3 V rail draws what it draws. On a dev board that floor is usually far above the chip's, and it is the whole answer once the sketch sleeps most of the time.
This board's sleep current has not been measured, so the figure lets you pick one. Measure yours — measuring current draw shows how, including the trap of doing it with a multimeter — and put the real number in.
Making it sleep
The ESP32 side is the same as on any ESP32: set a wake-up, then go to sleep.
esp_sleep_enable_timer_wakeup(15ULL * 60 * 1000000); // 15 minutes, in µs
esp_deep_sleep_start(); // setup() runs again on wakingEverything in RAM is lost; the sketch starts again from setup(). Deep sleep and
wake sources covers the rest.
When it does not work
The figure assumes the numbers it was given. Measure what your board draws asleep; count how long it is really awake, because a slow Wi-Fi connection can take several seconds; and allow for an older or colder cell holding less than its label.
That is the board around the chip, not the chip. Its regulator draws whatever it draws whether the chip sleeps or not, and the battery monitor's divider on a shield is one more small load across the cell. Measure the board alone, with nothing else connected, to find its own floor.
Off disconnects the cell, so nothing is drawn from it at all. It is the right way to store a project for more than a few days, and the only way to turn it off without unplugging the cell.
Edit this page — content/books/esplipo/how-long-a-cell-lasts.mdx
Questions about this product
See what other owners have asked, and read their solutions.
ESP32 LiPo Dev Kit: 3 Boards with LiPo Charger + 3 Shields
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.