timing deep sleep with external interrupt

stefbryssinckx
Posts: 2
Joined: Thu Mar 18, 2021 4:00 pm

timing deep sleep with external interrupt

Postby stefbryssinckx » Thu Mar 18, 2021 4:36 pm

Hi everyone,


I'm writing code for a battery powered device that measures how long an RTC GPIO is being held high. Because it's battery powered, I want it to be in deep sleep as much as possible. I made a working code using the timer wake up:

Code: Select all

esp_sleep_enable_timer_wakeup(time_in_us)
The esp32 goes into deep sleep for 5 seconds, wakes up, reads the GPIO, assumes it had this status for the last five seconds, stores that information and repeats the process. However, this means it's waking up more than necessary. Also, it's inaccurate because of the assumption made.

What I would like to do is use the external wake up:

Code: Select all

esp_sleep_enable_ext0_wakeup(GPIO_NUM_X, level)
The esp32 would go into deep sleep, wakeup because the GPIO status changed, read how long it had been in deep sleep, store that information and repeat the process.

Is there a way to read how long it had been in deep sleep? If not, suggestions for workarounds are of course welcome. Thanks!

Who is online

Users browsing this forum: No registered users and 35 guests