ESP32 GPIO Hold During Sleep Not Working
DodaTech
Updated 2026-06-26
1 min read
In this tutorial, you'll learn about ESP32 GPIO Hold During Sleep Not Working. We cover key concepts, practical examples, and best practices.
The Problem
ESP32 GPIO pins change state during deep sleep despite setting hold.
Quick Fix
Wrong
gpio_hold_en(GPIO_NUM_2); // Hold not applied before sleep
GPIO 2 goes LOW during deep sleep even though set HIGH before.
Right
digitalWrite(2, HIGH); // Set desired state
gpio_hold_en(GPIO_NUM_2); // Enable hold on this pin
gpio_deep_sleep_hold_en(); // Enable hold for all held pins
esp_deep_sleep_start();
// GPIO 2 stays HIGH during deep sleep
GPIO 2 measures 3.3V during deep sleep (held HIGH).
Prevention
Set output state before enabling hold. Call gpio_deep_sleep_hold_en() to enable holds in sleep. Only RTC GPIOs support hold during deep sleep. Hold keeps both level and direction. Release hold with gpio_hold_dis().
DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro