2

enter image description here

I'm testing deep-sleep mode on my ESP32 DEV kit board. For this purpose I've uploaded this code:

#define uS_TO_S_FACTOR 1000000  //Conversion factor for micro seconds to seconds
#define TIME_TO_SLEEP  5        //Time ESP32 will go to sleep (in seconds)

RTC_DATA_ATTR int bootCount = 0;

void setup() { Serial.begin(115200); delay(1000); //Take some time to open up the Serial Monitor

//Increment boot number and print it every reboot ++bootCount; Serial.println("Boot number: " + String(bootCount));

//Print the wakeup reason for ESP32 print_wakeup_reason();

//Set timer to 5 seconds esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) + " Seconds");

//Go to sleep now esp_deep_sleep_start(); }

void loop() {}

//Function that prints the reason by which ESP32 has been awaken from sleep void print_wakeup_reason() { esp_sleep_wakeup_cause_t wakeup_reason; wakeup_reason = esp_sleep_get_wakeup_cause(); switch(wakeup_reason) { case 1 : Serial.println("Wakeup caused by external signal using RTC_IO"); break; case 2 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break; case 3 : Serial.println("Wakeup caused by timer"); break; case 4 : Serial.println("Wakeup caused by touchpad"); break; case 5 : Serial.println("Wakeup caused by ULP program"); break; default : Serial.println("Wakeup was not caused by deep sleep"); break; } }

There isn't anything besides the USB cable (from PC) connected to my ESP board.

Despite this, the board continuously exits from deep-sleep mode reporting Wakeup caused by touchpad in the serial monitor instead of Wakeup caused by timer.

Any idea?

ocrdu
  • 9,195
  • 22
  • 32
  • 42
M4Biz
  • 359
  • 3
  • 13
  • What is the touchpad? I cant see anything that looks like touchpad on the image. If the "touchpad" is a pin, you probably have left it floating. If this is the case, it will get random voltages from environment's noise and will trigger itself. Can you de-activate the touchpad? – Christianidis Vasilis Feb 15 '22 at 15:02
  • @christianidis vasileios . Hi, christianidis, many pins are usable as touchpad input. I don't know if and how touchpad is de-activable – M4Biz Feb 15 '22 at 15:24
  • So I think you should start by finding out how to de-activate the touch pad. – Christianidis Vasilis Feb 15 '22 at 15:53

2 Answers2

1

Had the same problem. Lookup esp_sleep.h the for the esp_sleep_source_t enum. The print_wakeup_reason function should look like this now:

//Function that prints the reason by which ESP32 has been awaken from sleep
void print_wakeup_reason() {
    esp_sleep_wakeup_cause_t wakeup_reason;
    wakeup_reason = esp_sleep_get_wakeup_cause();
    Serial.print("Wakeup");
    Serial.println(wakeup_reason);
    switch(wakeup_reason)
    {
        case 1  : Serial.println("Not a wakeup cause!"); break;
        case 2  : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
        case 3  : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
        case 4  : Serial.println("Wakeup caused by timer"); break;
        case 5  : Serial.println("Wakeup caused by touchpad"); break;
        case 6  : Serial.println("Wakeup caused by ULP program"); break;
        case 7  : Serial.println("Wakeup caused by GPIO (light sleep only)"); break;
        case 8  : Serial.println("Wakeup caused by UART (light sleep only)"); break;
        default : Serial.println("Reset was not caused by exit from deep sleep"); break;
    }
}
ocrdu
  • 9,195
  • 22
  • 32
  • 42
Dawing
  • 11
  • 1
0

Not sure if your sketch was originally written for the 8266 but the case values are incorrect for the ESP32.

Try replacing them with:-

case ESP_SLEEP_WAKEUP_EXT0 :

case ESP_SLEEP_WAKEUP_EXT1 :

case ESP_SLEEP_WAKEUP_TIMER :

case ESP_SLEEP_WAKEUP_TOUCHPAD :

case ESP_SLEEP_WAKEUP_ULP :

default :

Duncan
  • 1
  • 1