Hello ESPers,
how do you wake up the ESP32 board in light sleep mode periodically and execute a certain function? In deep sleep mode I can check the wakeup reason at the beginning of the main function. However in light sleep mode the board just continues from where it stops right?
Is there any interrupt based methods that could detect the wakeup source is a timer and call a function?
To be more specific, I want to enable the ULP coprocessor while the main processor is in automatic light sleep mode. The ULP coprocessor poll sensor status from a IR camera and only wakes up the main processor when at least one pixel is hotter than a global threshold variable. This global variable should be updated by the main processor, reading from a temperature sensor every 2 hours. Now the problem is, how do I call a function when the main processor is waken from automatic light sleep mode?
Thx.
Best Regards
Zhao
periodically wake up in light sleep mode
-
- Posts: 21
- Joined: Tue Apr 13, 2021 8:43 am
Re: periodically wake up in light sleep mode
Hello @zhaozhaozhao
have you had a look at the light-sleep example? It uses `esp_sleep_get_wakeup_cause()` to figure out the wake up reason.
https://github.com/espressif/esp-idf/tr ... ight_sleep
Thanks
Felix
have you had a look at the light-sleep example? It uses `esp_sleep_get_wakeup_cause()` to figure out the wake up reason.
https://github.com/espressif/esp-idf/tr ... ight_sleep
Thanks
Felix
Re: periodically wake up in light sleep mode
I had the same problem and used this: https://github.com/espressif/esp-idf/pull/4352
Although if I was doing it today I'd simply put a callback in esp_light_sleep_start (just before it returns). Hopefully IDF will have something like that in future.
Although if I was doing it today I'd simply put a callback in esp_light_sleep_start (just before it returns). Hopefully IDF will have something like that in future.
-
- Posts: 21
- Joined: Tue Apr 13, 2021 8:43 am
Re: periodically wake up in light sleep mode
Thanks, but do you how do you call the function in automatic light sleep mode, where you do not explicitly call the esp_light_sleep_start() at all? This is supported by the freeRTOS tickless idle feature. See https://docs.espressif.com/projects/esp ... figurationfelmue wrote: ↑Fri Aug 06, 2021 10:40 amHello @zhaozhaozhao
have you had a look at the light-sleep example? It uses `esp_sleep_get_wakeup_cause()` to figure out the wake up reason.
https://github.com/espressif/esp-idf/tr ... ight_sleep
Thanks
Felix
Since the automatic light sleep mode is all handled by the esp_pm.h module internally I have no idea when the board enters sleep mode.
Best Regards
Zhao
-
- Posts: 21
- Joined: Tue Apr 13, 2021 8:43 am
Re: periodically wake up in light sleep mode
Thanks. It is good to know that there is a callback function interface, so all I need to do is write a function with the name s_light_sleep_cb and check light_sleep_wakeup_cause in it. But I guess a TaskDelay within the callback function is not allowed, because otherwise the automatic light sleep will be activated again? This is very interesting, and hopefully will sovle my problem.boarchuz wrote: ↑Fri Aug 06, 2021 12:19 pmI had the same problem and used this: https://github.com/espressif/esp-idf/pull/4352
Although if I was doing it today I'd simply put a callback in esp_light_sleep_start (just before it returns). Hopefully IDF will have something like that in future.
Best Regards
Zhao
Who is online
Users browsing this forum: atx823, brushlow18, Google [Bot] and 219 guests