How much power would you actually save by using light sleep or deep sleep? It depends on which board you're using, what your program is doing when it's not sleeping, what is left turned on during light sleep, and how long you spend sleeping vs running (your program's duty cycle).
Given all those variables, let's look at power consumption using the sample programs in the Alarms and Sleep section of this guide. If you recall, those programs just blink a NeoPixel for one second and then sleep for ten seconds.
We'll show a bunch of power-consumption graphs below. These screenshots were taken using the Nordic Semiconductor Power Profiler Kit II (PPK2) hardware and software. The PPK2 is quite inexpensive (< $100) compared to the usual power meter, is easy to use, and works well.
Here's a graph showing the
TimeAlarm deep sleep demo program, running on a MagTag ESP32-S2, sleeping every ten seconds. There's a big short spike when the program starts up after sleeping. The program blinks the NeoPixel, and then sleeps. We are supplying 3.7V to the board, which is a typical LiPo battery voltage.
Let's zoom in on the power consumption while the program is actively running during one cycle. You can see it's using about 50mA. Note that the vertical axis scale has changed, because we're not including the big spike at the beginning of a run.
If this program were using WiFi, you'd see much higher power consumption, up to a few hundred mA during active WiFi use.
Now let's look at the power consumption during deep sleep. In the graphs above, that's where the power consumption line looks very close to 0. Again, the vertical axis has expanded, so we can see microamps accurately. You can see the board is using a little under 230uA when it's sleeping. About 25-30uA of this is the actual ESP32-S2 module on the MagTag; the rest is board overhead, like the voltage regulator, and the (dim) power LED.
For comparison, here's a graph of the
TimeAlarm light sleep demo program, which also cycles every ten seconds. On the ESP32-S2, as mentioned, light sleep is no better than
time.sleep in terms of power consumption. For one second before the NeoPixel is turned on (marker 1), power consumption is about 33mA. Turning on the NeoPixel raises the current drawn to about 75mA. Then the program sleeps (marker 2), but the consumption is still about 33mA.
So there's not much reason to use light sleep on the ESP32-S2 if you're trying to save power.
Now let's look at deep sleep power consumption when using a
PinAlarm on the ESP32-S2 MagTag. Here are several cycles of sleeping. Each red arrow points to when the D11 button was pressed. The intervals are different lengths because the time between button pushes was not the same.
Here is the start of a single
PinAlarm sleep cycle. Unfortunately, the circuitry that needs to stay on to detect pin changes takes a significant amount of current. Even when deep sleeping, the board is using about 1.65mA, much more than it would if we were just using
TouchAlarm power consumption is similarly higher than you might like It's about 2.6mA, even higher than
PinAlarm, about 2.6mA. So again, if you really want to save your battery, use
Here's a chart of deep sleep power consumption when different kinds of alarms are used. As we add sleep to other chip families, we'll add to this chart.
ESP32-S2 (MagTag) Deep Sleep
ESP32-S2 Light Sleep
- Sleep current is the same as
time.sleep(), so there's no advantage to using light sleep.
As we mentioned, for any particular program and board, there are many things that can affect its power consumption. If you want to be know how long your battery will last, and whether you're consuming power unnecessarily, it's really helpful to have a power meter.
Don't Forget About Simulated Sleep
Don't forget that when your board is connected to a host computer via USB, it does not actually sleep when sleep is requested, because we don't want to break the USB serial and mass storage (CIRCUITPY) connections. So you need to test power consumption when not connected. The board can be powered from the battery connector or via the USB port (via a power pack or a wall adapter), but it can't be actively connected to a host computer.