Hi. Im having an issue. I am using an esp32 with a 6DoF imu. I want the imu to wake the esp32 from deep sleep and set a variable, wristWakeFlag=True. My source looks like this:
I have left off constructors and non-essential code, but basically this is how the code functions. Upon running this the first time, wristWakeFlag prints out as 0. Upon waking the chip, wristWakeFlag is still 0. I thought that once the interrupt runs to wake the board, the flag would be set to 1. However, since the interrupt wakes the board from deep sleep, I am wondering if the interrupt sets wristWakeFlag=true; THEN the code executes re-initializes the variables and runs through setup again because it comes out of sleep?
If this is the case, is there a way to set a variable via the interrupt request and have it maintqain that value upon restart from deep sleep?
There is no interrupt which is executed when the ESP wakes up from deep sleep.
What you are looking for is “external wake-up from deep sleep”.
Please see the tutorials from randomnerdtutorials.com about deep-sleep (listed below)
For a better understanding, I recommend to read all tutorials, especially the first one.
@sivar2311
Thank you, Boris - I had read most of what you attached before- but do not think I really understood until now. Let me see if I have it right:
On esp32 - you can use certain behavior of gpios as one of several wake-up sources. You can also attach an interrupt to the behavior of a gpio. You can even do these on the same pin (which is what I did). But once in deep sleep, the memory (except that stored in RTC memory) is gone - so any information stored in your sketch including the isr is gone. So in my case, I used a pin as a wakeup source and an isr. During powered execution, the isr would trigger and execute normally, however, once in deep sleep the pin can still be used as a wake source, but upon waking there is no isr to execute.