ESP32 Deep Sleep modes with Arduino IDE


ESP32 comes with a dual-core processor. The dual-core processing provides efficiency in terms of performance as well as power consumption. In this post, we’ll explore how to access both cores on the ESP32 and compare the performance between single-core and dual-core operations.

ESP32 has Five Power Modes:

  • Active Mode
  • Mode-Sleep Mode
  • Light-Sleep Mode
  • Deep-Sleep Mode
  • Hibernation Mode
Power ModeCPUWi-Fi/BluetoothRTC Memory & PeripheralsULPPower Consumption
Active ModeONONONONRefer [RF Modes]
Modem-Sleep ModeONOFFONON20 mA to 68 mA
Light-Sleep ModePAUSEOFFONON0.8 mA
Deep-Sleep ModeOFFOFFONON10 uA to 150 uA
Hibernation ModeOFFOFFRTC Memory – OFF
RTC Timer – ON (Slow clock 8 MHz)
RTC GPIOs – ON
OFF5 uA
Power OffOFFOFFOFFOFF1 uA
ESP32 Power Modes

Please find power consumption for various RF modes in ESP32:

RF ModeMinTypMaxUnit
Transmit 802.11b, DSSS 1 Mbps, POUT = +19.5 dBm240mA
Transmit 802.11g, OFDM 54 Mbps, POUT = +16 dBm190mA
Transmit 802.11n, OFDM MCS7, POUT = +14 dBm180mA
Receive 802.11b/g/n95 to 100mA
Transmit BT/BLE, POUT = 0 dBm130mA
Receive BT/BLE95 to 100mA
ESP32 Power Modes

Imagine you have an ESP32 Smartwatch. Let’s assume we have a battery of 500 mAH and other sensors, display, and modules consume negligible power. Let’s compare the battery backup of the watch in active vs sleep mode. Let’s assume our device is 90% of the time is in Deep-Sleep Mode and 10 % of the time in Active Mode.

battery backup = battery capacity (mAH) / current consumption

battery backup(Active Mode) = 500 (mAH) / 240 mA = 2.1 Hours
battery backup(Deep-Sleep) = 500 (mAH) / {(150*0.9 uA)+(240*0.1 mA)} = 21 Hours

From the battery life calculation, you can clearly see that the watch will have 10x more battery backup. You can still increase the battery backup by putting the ESP32 into Hibernation mode and increasing the sleep duration.

The function esp_deep_sleep_start(void) puts ESP32 in Deep-Sleep Mode. However, you need to define the wakeup source before putting ESP32 into sleep mode.

esp_deep_sleep_start(void);

ESP32 can wake up at predetermined times. It is useful in applications where devices don’t need to remain active all the time.

  • Applications:
    • Alarm clocks in mobile,
    • Smart Watch,
    • Weather Station data logger

esp_sleep_enable_timer_wakeup(time_in_us);

ESP32 will wake up when touch is detected on the capacitive touch-sensing GPIO pins.

  • Applications:
    • Fingerprint Scanner,
    • Touch wake-up on the Smartphone screen

touchSleepWakeUpEnable(pin, threshold);

ESP32 will wake up when the signal is detected on pins.

  • Applications
    • Wildlife tracking Camera (captures photo when movement is detected),
    • The power button in the Smartphone

esp_sleep_enable_ext0_wakeup(pin, level);
AND
esp_sleep_enable_ext1_wakeup(pin, level);

#define TIME_TO_SLEEP  5

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println(esp_sleep_get_wakeup_cause());
  
  Serial.println("ESP32 is going to sleep for ...");
  // Enable timer wakeup
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * 1000000); // Convert to microseconds

  // Start deep sleep
  Serial.println("ESP32 sleeping now");
  Serial.flush(); 
  esp_deep_sleep_start();
  Serial.println("ESP32 sleeping now")
}

void loop() {
   Serial.println("Inside loop() function")
}

CEW

WVE

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *