ESP32 LiPo/Where the power comes from/10. How long a cell lasts
Where the power comes from · 10 of 13

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.

How long a cell lasts is capacity over the average
about 19 days
Cell capacity1000 mAh
The sketch
The board, asleep
Average
1.79 mA
Usable
800 mAh
Lasts
about 19 days
Asleep is most of it. The chip sleeps at 10 µA, but the board around it — regulator, LED, USB chip — draws what it draws, all day. This board’s figure has not been measured; measure yours before you promise anyone a month.

Three ways a sketch can run

On a 1000 mAh cell:

The sketchAverageLasts
Wi-Fi connected all the timeabout 120 mAabout 7 hours
Awake, radio offabout 45 mAabout 18 hours
Wake every 15 minutes, 6 s of Wi-Fi, chip asleep at 10 µAabout 0.81 mAabout 41 days
The same, with the board drawing 1 mA asleepabout 1.79 mAabout 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 waking

Everything in RAM is lost; the sketch starts again from setup(). Deep sleep and wake sources covers the rest.

When it does not work

My cell lasts half as long as the figure says

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.

In deep sleep it still draws milliamps

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.

Does the shield's switch save power when it is off?

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.

Where this goes next

One solder blob, and the board can read its own cell.

The battery monitor pad

Edit this page — content/books/esplipo/how-long-a-cell-lasts.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

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.

Browse Modules and blocks on the forum