ESP32 Won't Wake from Deep Sleep: Causes and Fixes

🏠 Part of: Home Repair & Maintenance
ESP32 Won't Wake from Deep Sleep: Causes and Fixes

Deep sleep is the single most useful feature of a battery ESP32 — and the one that trips up the most people. If your board never wakes, wakes instantly, or drains a 18650 in three days, one of the six causes below is almost certainly the reason.

Only RTC GPIOs can wake the chip

Not every ESP32 pin is connected to the RTC domain. If you use a wake source on a non-RTC pin, the chip goes to sleep and simply never wakes. The pins you can use are:

  • ADC1 / RTC pins: GPIO 36, 37, 38, 39, 34, 35, 32, 33, 25, 26, 27, 14, 12, 13, 4, 0, 2, 15.
  • Output-capable RTC pins: 0, 2, 4, 12–15, 25–27, 32, 33.

Pins 34–39 are input-only, so they can wake the chip but cannot drive anything. Pins 6–11 are used by the flash chip and must never be used.

Floating pins wake the chip instantly

If the wake pin is left floating and configured for a low-level wake, noise on the pin will trigger an immediate wake. Always enable the internal pull-up or pull-down, or add an external 10 kΩ resistor:

rtc_gpio_pullup_en(GPIO_NUM_33);
rtc_gpio_pulldown_dis(GPIO_NUM_33);
esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 0); // wake on low

Without the pull-up, the pin floats and the chip wakes as soon as it sleeps — often within milliseconds. From the outside it looks like deep sleep "does not work."

Timer wake and GPIO wake together

You can enable both at once. The chip wakes on whichever fires first:

esp_sleep_enable_timer_wakeup(60ULL * 1000000ULL); // 60 s
esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 0);       // or button
esp_deep_sleep_start();

After waking, check the wake cause so your code can behave differently:

esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
if (cause == ESP_SLEEP_WAKEUP_TIMER) { /* periodic reading */ }
if (cause == ESP_SLEEP_WAKEUP_EXT0)  { /* button pressed */ }

The USB-serial chip ruins your sleep current

A "10 µA deep sleep" figure in the datasheet assumes the ESP32 is alone on the board. On a typical dev board, the CP2102 or CH340 USB chip, the power LED and the onboard LDO all keep drawing current. Real measured sleep current on a NodeMCU-style board is often 2–10 mA — three orders of magnitude higher.

To reach true low power:

  • Use a bare ESP32 module (WROOM or WROVER), not a dev board.
  • Remove or power-gate the power LED.
  • Choose an LDO with low quiescent current: HT7333, MCP1700, TPS7A02. Avoid AMS1117 (5 mA quiescent by itself).
  • Disconnect the USB-serial adapter after flashing.

Measure the real current

You cannot optimise what you cannot measure. Put a multimeter in µA mode in series with the battery, or better, use a USB power meter with a µA range (e.g. Nordic PPK2, Joulescope, or a cheap INA219 breakout). Measure:

  • Current during boot.
  • Current during Wi-Fi transmission (can be 250 mA peaks).
  • Current during deep sleep.

If deep sleep is above 100 µA on a bare module, something is still powered that should not be. Check the LDO, the flash chip (already inside the module), and any external sensor.

Peripherals that keep the chip awake

  • Wi-Fi and Bluetooth must be stopped with WiFi.disconnect(true) and WiFi.mode(WIFI_OFF) before sleeping, or the radio stays powered.
  • Brownout detector can prevent wake if the supply is marginal. Disable it only as a last resort: WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0).
  • External sensors powered from a GPIO: turn that GPIO low before sleeping, and power the sensor from a MOSFET high-side switch.

Putting it all together

void loop() {
  // 1. do the work
  readSensor();
  sendToServer();

  // 2. shut down the radio
  WiFi.disconnect(true);
  WiFi.mode(WIFI_OFF);

  // 3. arm the wake source
  esp_sleep_enable_timer_wakeup(300ULL * 1000000ULL); // 5 min
  esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 0);

  // 4. sleep
  esp_deep_sleep_start();
}

With a bare module, a low-quiescent LDO and a 5-minute interval, a single 18650 will last for months.

Summary

Deep sleep failures come from six places: wrong pin, floating pin, radio left on, USB chip leakage, wrong LDO, and no measurement. Fix those and your battery node will do exactly what the datasheet promised.

Comments