I am able to activate light sleep mode with GPIO wake up source : esp_sleep_enable_gpio_wakeup()
i setup 2 pins to wake up from light sleep : gpio_wakeup_enable()
I have a problem when I try to deactivate on of the two GPIO pins with this function : gpio_wakeup_disable(gpio_num_tgpio_num)
But nothing happens, it has no effect.... someone knows how it works?
Code: Select all
void setup(){
gpio_wakeup_enable(GPIO_NUM_37, GPIO_INTR_LOW_LEVEL);
gpio_wakeup_enable(GPIO_NUM_39, GPIO_INTR_LOW_LEVEL);
esp_sleep_enable_gpio_wakeup();
}
void loop(){
Serial.println("boucle loop");
Serial.println("Boot number: " + String(Count));
if (Count == 5){
Serial.println("desactivation du wakeup BUTTON_HOME");
gpio_wakeup_disable(GPIO_NUM_37);
}
//Go to sleep now
Serial.println("Going to sleep now in 2s");
delay(2000);
esp_light_sleep_start();
Serial.println("BUTTON_HOME : ");
Serial.println(digitalRead(GPIO_NUM_37));
Serial.println("BUTTON_B : ");
Serial.println(digitalRead(GPIO_NUM_39));
if (digitalRead(GPIO_NUM_37)== LOW){
Serial.println("Appui du BUTTON_HOME -> WakeUp");
}
if (digitalRead(GPIO_NUM_39)== LOW){
Serial.println("Appui du BUTTON_B -> WakeUp");
}
//Print the wakeup reason for ESP32
print_wakeup_reason();
++Count;
}
void print_wakeup_reason(){
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
Serial.println(wakeup_reason);
switch(wakeup_reason)
{
case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by boutton home A - 37"); break;
case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by boutton B - 39"); break;
case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
case ESP_SLEEP_WAKEUP_GPIO : Serial.println("Wakeup caused by GPIO"); break;
case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
}
}