Deep sleep wake up stub?

Jeranimal
Posts: 1
Joined: Sat May 03, 2025 4:19 pm

Deep sleep wake up stub?

Postby Jeranimal » Sat May 03, 2025 4:29 pm

I am working on a low power system to read a anemometer (wind speed). I am running off of solar and a supercap and want to save as much power as possible. I would like to read the number of rotations of the anemometer in a 5 minute period and report that along with the shortest time between rotations for that time. After 5 minutes, I want to wake up and send out the information wireless to the base station.

When I wake up from a wind rotation, all I want to do is increase the wind counter and test if the time between counts is less than what I have previously measured. I want to then get back to sleep as fast as possible to conserve power.

In the wakeup stub I want to:
- determine if the wake up was due to the GPIO
- if so increase a counter variable
- see if the time between counters is less than originally measured
- go back to sleep for the remainder of the sleep interval

If the wake up reason is the timer, then wake up normally and send out the collected data from the sleep period.

This seems like the ideal use of the wake up stub function, but before diving in wanted to see if it was even possible within the Arduino IDE? If it is possible, any pointers for what to be careful with?


Thanks!

lbernstone
Posts: 1132
Joined: Mon Jul 22, 2019 3:20 pm

Re: Deep sleep wake up stub?

Postby lbernstone » Mon May 05, 2025 4:23 pm

The wakeup stub is run before the system is initialized, so you are unlikely to have access to the structures and methods you need to do your record keeping. It is also AFAIK not available in the pre-compiled Arduino framework.
Your use case sounds much more appropriate for the ULP. You can have the ULP do gpio operations and data collection, then go into full sleep between samples. You may only need to come out of deep sleep to write to flash or the network. Note that programming the ULP is much easier with original ESP32 than the variants using Arduino (but much easier with the others in IDF!). The ULP uses less than a mA when doing gpio operations, and down in the single digit uA range when sleeping.

Who is online

Users browsing this forum: Qwantbot and 3 guests