Maximum deep sleep time for ESP32

Hey guys,
I'm using the ESP32 NodeMCU from AZ-Delivery (https://www.az-delivery.de/en/products/esp32-developmentboard). I tried to put it into deep sleep using this code:

void sleepAndWakeupWithRadioDisabled() {
  WiFi.disconnect();
  delay(1);
  WiFi.mode( WIFI_OFF );
  delay(1);

  esp_sleep_enable_timer_wakeup(interval * 1000000);

  esp_sleep_pd_config(ESP_PD_DOMAIN_MAX, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
  
  //Go to sleep now
  Serial.println("Going to sleep now");
  delay(1000);
  esp_deep_sleep_start();
  Serial.println("This will never be printed");
}

The "interval" is in secondes and if it is more than 2100 (35 min.), the program doesn't go to deep sleep and restart continuously instead.
It needs to go to deep sleep for 4 hours. What am I missing?

Thanks for your help
Laurent

what's the type of interval in this interval * 1000000

you might want to force the whole thing into a uint64_t (so have interval as a uint64_t and as you are at it, write 1000000ull to show you understand it needs to be 64 bits) otherwise you might be stuck with 32 bits (int size on your ESP32)

1 Like

Thanks JML, it worked! The type for the interval was an int.
It's working like a charm with a uint64_t.

glad it helped! have fun

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.