Hi
I have this code that I was planning that ESP32 took a 5 sec ligth sleep delay
As you se, Ligth sleep should have been between 2 and 3, wich is 0 sec and 0 millisec
20:13:22.194 -> 1 Variable preserved in light sleep: 1
20:13:22.194 -> 2 Sleeping lightly for a few seconds...
20:13:22.194 -> ... 3 Woke up and performing a task here... 10 seconds
20:13:32.197 ->... 4 Task complete
What is it that I dont get?
Code
#include <Arduino.h>
int testValue = 1;
void goToSleep() {
esp_sleep_enable_timer_wakeup(5 * 1000000); // 5 million microseconds = 5 seconds
esp_light_sleep_start(); // Preserves variables
}
void setup() {
Serial.begin(115200);
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("1 Variable preserved in light sleep: ");
Serial.println(testValue);
Serial.println("2 Sleeping lightly for a few seconds...");
goToSleep();
Serial.println(" 3 Woke up and performing a task here... 10 seconds");
delay(10000); // Simulating a task
Serial.println(" 4 Task complete");
}