Hello, everyone, I have the following problem. I want that my NodeMCU esp32 to read the temperature sensor data and send it to thingspeak every 10 minutes. Then go to deep sleep. This works fine. With a push button I want also to wake up the esp32 from deep sleep and show the temperature value on the display for 10 seconds. Then the display should switches off to save power until I press the push button again. The problem is when I wake up the esp 32 from deep sleep with the push button (GPIO33 with pull down) to show the temperature value on the display, it does not work. I mean the ESP32 wakes up but doesn’t show any data on the display. What am I doing wrong here. Please It would be very nice if someone could help me. Many Thanks
Here is the pastebin link
Hi.
You’re implementing external wake-up wrong.
You can’t implement it like this:
if (esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 1) == true) //if the push button pressed then wake up and display temperature value on oled display
You have to add the following in the setup(), so that the ESP know that that wake up mode is activated:
esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 1);
Then, to check whether it was awaked by timer or by an external wake-up, you can create something based on the following function:
void print_wakeup_reason(){
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch(wakeup_reason)
{
case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); 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;
}
}
See the complete example in our tutorial: https://randomnerdtutorials.com/esp32-external-wake-up-deep-sleep/
I hope this helps.
Regards,
Sara