Repository: esphome/esphome (2025-08-20T22:39:57Z)

Issue:
Deep sleep not compiling on ESP32-C6 with 2025.8.0b1 and dev.
### The problem

Previously deep sleep was working in dev for an ESP32-C6. It now comes up with the errors below.

Suspect it maybe related to PR #9395 

### Which version of ESPHome has the issue?

2025.8.0-b1

### What type of installation are you using?

Home Assistant Add-on

### What platform are you using?

ESP32

### Component causing the issue

deep_sleep

### YAML Config

```yaml
esphome:
  name: moisture-sensor-1
  friendly_name: Moisture sensor 1
  on_boot: 
    then:
      - switch.turn_on: moisture_sensor_power

esp32:
  board: esp32-c6-devkitm-1
  framework:
    type: esp-idf




deep_sleep:
  id: moisture_sensor_1
  run_duration: 25sec
  sleep_duration: 4hours
```

### Anything in the logs that might be useful for us?

```txt
src/esphome/components/deep_sleep/deep_sleep_esp32.cpp: In member function 'void esphome::deep_sleep::DeepSleepComponent::deep_sleep_()':
src/esphome/components/deep_sleep/deep_sleep_esp32.cpp:123:5: error: 'gpio_deep_sleep_hold_en' was not declared in this scope; did you mean 'gpio_sleep_sel_en'?
  123 |     gpio_deep_sleep_hold_en();
      |     ^~~~~~~~~~~~~~~~~~~~~~~
      |     gpio_sleep_sel_en
*** [.pioenvs/moisture-sensor-1/src/esphome/components/deep_sleep/deep_sleep_esp32.cpp.o] Error 1
========================== [FAILED] Took 6.88 seconds ==========================
```

### Additional information

_No response_


Discussion:
Does not work in released 2025.8.0 also.
I found a workaround :)
Copy your yaml file to your esphome directory, In my case C:\Users\bjorn\esp\esphome
run command: esphome run yourfile.yaml
In my case: esphome run hallenv.yaml
It compiled and uploaded it to my esp32-C6 and my changes was included :)
Can you try https://github.com/esphome/esphome/pull/10345 I don't have access to an ESP32-C6 device for testing. This fix is based on ESP-IDF source code analysis and the compilation error reported in the issue. Testing on actual ESP32-C6 hardware would be appreciated.


https://github.com/esphome/esphome/pull/10345#issuecomment-3208282728
I can confirm that #10345 fixes the issue on an ESP32 C6.
Thanks.
I can also confirm that https://github.com/esphome/esphome/pull/10345 fixes the issue on an ESP32 C6.
Thanks.



Patch:
diff --git a/esphome/components/deep_sleep/deep_sleep_esp32.cpp b/esphome/components/deep_sleep/deep_sleep_esp32.cpp
index c5c1fe083573..e9d0a4981f21 100644
--- a/esphome/components/deep_sleep/deep_sleep_esp32.cpp
+++ b/esphome/components/deep_sleep/deep_sleep_esp32.cpp
@@ -1,4 +1,5 @@
 #ifdef USE_ESP32
+#include "soc/soc_caps.h"
 #include "driver/gpio.h"
 #include "deep_sleep_component.h"
 #include "esphome/core/log.h"
@@ -83,7 +84,11 @@ void DeepSleepComponent::deep_sleep_() {
     }
     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
     bool level = !this->wakeup_pin_->is_inverted();
     if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_INVERT_WAKEUP && this->wakeup_pin_->digital_read()) {
       level = !level;
@@ -120,7 +125,11 @@ void DeepSleepComponent::deep_sleep_() {
     }
     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
     bool level = !this->wakeup_pin_->is_inverted();
     if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_INVERT_WAKEUP && this->wakeup_pin_->digital_read()) {
       level = !level;


Test patch:
diff --git a/tests/components/deep_sleep/test.esp32-c6-idf.yaml b/tests/components/deep_sleep/test.esp32-c6-idf.yaml
new file mode 100644
index 000000000000..10c17af0f517
--- /dev/null
+++ b/tests/components/deep_sleep/test.esp32-c6-idf.yaml
@@ -0,0 +1,5 @@
+substitutions:
+  wakeup_pin: GPIO4
+
+<<: !include common.yaml
+<<: !include common-esp32.yaml
diff --git a/tests/components/deep_sleep/test.esp32-s2-idf.yaml b/tests/components/deep_sleep/test.esp32-s2-idf.yaml
new file mode 100644
index 000000000000..10c17af0f517
--- /dev/null
+++ b/tests/components/deep_sleep/test.esp32-s2-idf.yaml
@@ -0,0 +1,5 @@
+substitutions:
+  wakeup_pin: GPIO4
+
+<<: !include common.yaml
+<<: !include common-esp32.yaml
diff --git a/tests/components/deep_sleep/test.esp32-s3-idf.yaml b/tests/components/deep_sleep/test.esp32-s3-idf.yaml
new file mode 100644
index 000000000000..10c17af0f517
--- /dev/null
+++ b/tests/components/deep_sleep/test.esp32-s3-idf.yaml
@@ -0,0 +1,5 @@
+substitutions:
+  wakeup_pin: GPIO4
+
+<<: !include common.yaml
+<<: !include common-esp32.yaml