0

I have an error when I compiling code: esp_sleep_enable_ext0_wakeup' was not declared in this scope How can I fix this error? I use WEMOS D1. Please help

int bootCount = 0;

void setup(){
  Serial.begin(115200);
  delay(1000); 

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

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

  //Configure GPIO33 as ext0 wake up source for HIGH logic level
  esp_sleep_enable_ext0_wakeup(D4,1);

  //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;
  }
}
Bartek
  • 35
  • 6
  • 1
    Wemos D1 is a esp8266 board. the code is for esp32 – Juraj Feb 08 '20 at 09:28
  • 1
    ESP8266 deep sleep is implemented in a special class called ESP. The source code is at [Esp.cpp](https://github.com/esp8266/Arduino/blob/master/cores/esp8266/Esp.cpp), and the documentation for the class is [here](https://arduino-esp8266.readthedocs.io/en/2.6.3/libraries.html#esp-specific-apis). – hcheung Feb 09 '20 at 10:32

0 Answers0