Light Sleep mode is one of the low-power consumption modes available on the ESP32, similar to a computer’s “sleep” mode.
In this mode, the ESP32 consumes less than 1mA (for example, 800µA on the ESP32 and 240µA on the ESP32-S3).
In this mode, the CPU, RAM, and digital peripherals are disconnected from the clock and their voltage is reduced. Being disconnected from the clock, they stop functioning, but remain powered on and active.
When the ESP32 is in Light Sleep, it stops executing the program and enters a suspended state.
To exit Light Sleep mode, the available WakeUp Sources are:
- Timer
- GPIO Wakeup
- UART Wakeup
- WIFI Wakeup
- Touchpad
- ULP Coprocessor Wakeup
- External Wakeup (Ext0 and Ext1)
Upon exiting Light Sleep, the program continues execution from the exact point where it left off. Any information or variables saved in memory are preserved.
Using Light Sleep Mode in the Arduino IDE
The functions needed to use Light Sleep mode are defined in the “esp_sleep.h” file. This library contains the necessary functions and macros to configure and control the ESP32’s Light Sleep mode.
With this, it is very easy to use the ESP32’s Light Sleep mode in the Arduino environment. First, we define a WakeUp Source using the functions we saw in What are the Sleep Modes on the ESP32.
Next, entering Light Sleep mode is as simple as using the function esp_light_sleep_start
/**
* @brief Enter light sleep with the configured wakeup options
*/
esp_err_t esp_light_sleep_start(void);
Code Examples
Let’s see a complete example of how to use Light Sleep mode to make the ESP32 enter deep sleep for 10 seconds and then wake up:
void setup()
{
Serial.begin(115200);
delay(5000);
}
int counter = 0;
void loop() {
Serial.println(counter);
counter ++;
esp_sleep_enable_timer_wakeup(2 * 1000000); //light sleep for 2 seconds
esp_light_sleep_start();
}

