From 61a89a97d7d2e401d2dffcdac8388c26b94c2d0a Mon Sep 17 00:00:00 2001 From: Jasper van der Neut - Stulen Date: Mon, 12 Jan 2026 19:03:13 +0100 Subject: [PATCH] [deep_sleep] Fix GPIO wakeup on ESP32-C3/C6 (#12803) --- .../components/deep_sleep/deep_sleep_esp32.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/esphome/components/deep_sleep/deep_sleep_esp32.cpp b/esphome/components/deep_sleep/deep_sleep_esp32.cpp index ea1cd00c5f..79c34f627a 100644 --- a/esphome/components/deep_sleep/deep_sleep_esp32.cpp +++ b/esphome/components/deep_sleep/deep_sleep_esp32.cpp @@ -127,22 +127,14 @@ void DeepSleepComponent::deep_sleep_() { defined(USE_ESP32_VARIANT_ESP32C61) if (this->wakeup_pin_ != nullptr) { const auto gpio_pin = gpio_num_t(this->wakeup_pin_->get_pin()); - if (this->wakeup_pin_->get_flags() & gpio::FLAG_PULLUP) { - gpio_sleep_set_pull_mode(gpio_pin, GPIO_PULLUP_ONLY); - } else if (this->wakeup_pin_->get_flags() & gpio::FLAG_PULLDOWN) { - gpio_sleep_set_pull_mode(gpio_pin, GPIO_PULLDOWN_ONLY); - } - gpio_sleep_set_direction(gpio_pin, GPIO_MODE_INPUT); - gpio_hold_en(gpio_pin); -#if !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP - // Some ESP32 variants support holding a single GPIO during deep sleep without this function - // For those variants, gpio_hold_en() is sufficient to hold the pin state during deep sleep - gpio_deep_sleep_hold_en(); -#endif + // Make sure GPIO is in input mode, not all RTC GPIO pins are input by default + gpio_set_direction(gpio_pin, GPIO_MODE_INPUT); bool level = !this->wakeup_pin_->is_inverted(); if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_INVERT_WAKEUP && this->wakeup_pin_->digital_read()) { level = !level; } + // Internal pullup/pulldown resistors are enabled automatically, when + // ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS is set (by default it is) esp_deep_sleep_enable_gpio_wakeup(1 << this->wakeup_pin_->get_pin(), static_cast(level)); }