Table of Contents

Hibernation mode is the lowest power state available on the ESP32. It is similar to deep sleep but with even lower power consumption, making it ideal for ultra-low-power applications where the device needs to wake up only occasionally.

Key Differences Between Deep Sleep and Hibernation

FeatureDeep SleepHibernation
CPUOffOff
RAMLost (unless RTC memory is used)Lost
RTC PeripheralsOnOff
RTC MemoryRetainedLost
Wake-Up SourcesTimer, GPIO, Touch, ULP, ExternalOnly RTC Timer & External (GPIO)
Power Consumption~10-150µA~5µA

Key Characteristics of Hibernation Mode

  • CPU is completely powered off.
  • All RAM is lost, including RTC memory.
  • Only the RTC timer or an external GPIO signal can wake up the device.
  • Power consumption can be as low as 5µA, which is significantly lower than deep sleep.
  • The ESP32 reboots from scratch after waking up, similar to a power cycle.

Wake-Up Sources

  • Timer Wake-Up – Wake up after a defined time using the RTC timer.
  • External Wake-Up – Wake up via an external signal, such as a button press.

The code for deep sleep and hibernation looks the same because ESP32 uses the same function esp_deep_sleep_start() for both modes. The difference between deep sleep and hibernation comes from what is enabled before entering sleep:

Deep Sleep

  • RTC peripherals and RTC memory can remain powered.
  • Multiple wake-up sources (timer, GPIO, touch, ULP).
  • Power consumption ~10-150µA.

Hibernation

  • RTC peripherals and RTC memory are completely powered off.
  • Only RTC timer and external GPIO can wake up the ESP32.
  • Power consumption ~5µ

How to Force Hibernation Mode
To make the ESP32 enter hibernation instead of deep sleep, you must ensure:

  • No RTC peripherals remain active.
  • No RTC memory is retained.
  • Only the RTC timer or external GPIO is used as a wake-up source.

Example: Hibernation Mode with Timer Wake-Up

#include <esp_sleep.h>

#define TIME_TO_SLEEP  30  // Sleep for 30 seconds

void setup() {
    Serial.begin(115200);
    delay(1000);

    Serial.println("ESP32 going to hibernation...");

    // Enable wake-up using RTC Timer (in microseconds)
    esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * 1000000);

    // Enter hibernation mode
    esp_deep_sleep_start();
}

void loop() {
    // This will not execute after wake-up because the ESP32 restarts
}

Wake-Up from Hibernation
Since RAM and RTC memory are lost, after waking up, the ESP32 boots up as if it had been freshly powered on. Any necessary data must be stored in non-volatile memory (e.g., SPIFFS, EEPROM, or Preferences API).

Categorized in:

Deep Sleep,

Tagged in: