Hi I have A question regarding an example in the MODULE 3 (esp32 deep sleep) page 114 .and my Question is in the example this instruction is used
( esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,1);
which mean when GPIO 33 is high weakup the esp32… but I noticed that when the GPIO33 still high(keep in high state) the esp32 go to sleep again after that wekup and continue periodically sleep and weakup every nearly 1 sec.
is that normal?
I mean if you have a sensor or data sending to server it can not finish the job.because it will go to sleep…
Hi.
In that specific example, that is normal.
The ESP32 wakes up when GPIO 33 goes to HIGH, when it is asleep.
If the ESP32 is awake and you keep pressing GPIO 33, it won’t react. It will only react to GPIO 33 when it is asleep.
In that particular example, the sketch simply prints the wake up reason, waits 1 second and then it goes to sleep again. That’s why, if you keep pressing GPIO33 HIGH, it will wake up every 1 seconds. Because that’s what that particular code does.
If you have data to read and send to a server, it will only go to sleep when it reaches this line of code:
esp_deep_sleep_start();
So, it will do all the other tasks before going to sleep.
I hope this is clear.
Regards,
Sara
that was clear ,for example if we have a sensor to measure the current flow which is connected to GPIO 33 and when the current not exist esp32 will go to sleep,when the current exist the esp32 will weak-up to measure time elapsed and send the data to the server , but in that case it will always weak up then go to sleep periodically. actually I had an idea that when the current exist the esp32 should be always weak up and when the current not exit esp32 go to sleep
because this situation I ask this question
thanks a lot
However, if you want that to happen, you can add an if statement in your code that checks if GPIO33 is HIGH.
When, the ESP32 wakes up, it checks the state of GPIO 33.
If it is still HIGH, do whatever you want to do (without the sleep command).
If it is not, the ESP32 goes back to sleep.
In that scenario, the ESP32 will be awake as long as the GPIO33 is HIGH.
I hope you understand.
Regards,
Sara