ESP32 - Deep Sleep for over 3 hours

tHe giafra sHoW
Posts: 4
Joined: Tue Nov 26, 2019 11:33 am

ESP32 - Deep Sleep for over 3 hours

Postby tHe giafra sHoW » Mon Oct 05, 2020 2:21 pm

Hi everyone,
I'm currently working on a IoT project. The board is ESP32-based, from WaveShare displays. I'm using Arduino 1.8 as IDE.
The issue I'm having is about the DeepSleep feature. I'm able to send the device to sleep for a little over 3 hours maximum, but if I insert a higher amount of time (expressed in microseconds) it causes an overflow. Even though I'm using Arduino as the IDE, I'm still using the 2 functions provided by espressif libraries, which are:

esp_err_t esp_sleep_enable_timer_wakeup(uint64_t time_in_us);

esp_err_t esp_deep_sleep_start();

The type "uint64_t" sets a specific limit for the amount of microseconds that could be passed to the function, approximately something that amounts to 3 hours.
But browsing the specifics and some online resources, it's clearly stated that the ESP32, unlike the ESP8266, is able to deep sleep for over a year.

But how can I achieve such a thing? I mean, I don't need an entire year, but at least 8-9 hours. Ideally, the ESP32 is piloting a WaveShare display that should be able to remain in a deep sleep state for a night. The goal is to optimize battery duration by keeping the display sleeping for as long as I don't need the image refreshed on the display attached.

Posts: 536
Joined: Tue Aug 21, 2018 5:28 am

Re: ESP32 - Deep Sleep for over 3 hours

Postby boarchuz » Mon Oct 05, 2020 7:54 pm

Use the ULL (unsigned long long) modifier:
esp_deep_sleep_start(8ULL * 60 * 60 * 1000 * 1000); // sleep 8hrs

Who is online

Users browsing this forum: Baidu [Spider] and 89 guests