此例程是使用 GPIO4( 对应 RTC_GPIO10) 触发高电平,来唤醒 Deep-Sleep 模式。
测试代码如下:ESP-IDF 版本为 v4.3.1 版本。
#include测试结果如下: 【说明】#include #include #include #include #include "sdkconfig.h" #include "soc/soc_caps.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_sleep.h" #include "esp_log.h" #include "driver/adc.h" #include "driver/rtc_io.h" #include "soc/rtc.h" #if CONFIG_IDF_TARGET_ESP32 #endif void app_main(void) { printf("CPU Start Runningn"); rtc_gpio_init(GPIO_NUM_4); gpio_pullup_dis(GPIO_NUM_4); gpio_pulldown_en(GPIO_NUM_4); rtc_gpio_wakeup_enable(GPIO_NUM_4,0x5); rtc_gpio_set_direction_in_sleep(GPIO_NUM_4,RTC_GPIO_MODE_INPUT_ONLY); esp_sleep_enable_gpio_wakeup(); printf("CPU RTC_GPIO Start Runningn"); esp_deep_sleep_start(); printf("CPU enter Deep-sleep Runningn"); }
- RESET_REASON:5,对应为 “Deep Sleep reset digital core“ 。参考 ”RESET_REASON “ 说明。



