简体   繁体   中英

Light sleep wake-up via gpio on esp32

I have a simple code for esp32 here. I can only use gpio pin number 35 on the board. So esp32 should go to light sleep and wake up on button press. When I run this program below, my esp32 goes into light sleep, but it doesn't wake up when the button is pressed. What's the problem? Any idea please? Thank you.

#include <esp_sleep.h>

void setup() {

  Serial.begin(115200);
  delay(2000);
  gpio_wakeup_enable(GPIO_NUM_35, GPIO_INTR_HIGH_LEVEL);
  esp_sleep_enable_gpio_wakeup();
  delay(2000); 
  Serial.println("Going to sleep now");
  delay(2000); 
  esp_light_sleep_start();
  delay(2000); 
  Serial.println("This will be NOT printed");

}

void loop() {
  delay(2000); 
  Serial.println("Hi after wake up via GPIO Button!");
  delay(2000); 
}

I've figured out by myself, what the trouble was: just change to rtc_io ext0 and set level on 0. Then it will work fine. Hope, it can be helpful for another users. Kind regards!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM