I observe that the esp_light_sleep_start() wakes up and continues where it left off in the sketch, but I lose the Serial connection on my Arduino IDE. Most of the time, the IDE’s Serial Monitor interferes with the ESP after waking up. When I close the Serial Monitor, the ESP proceeds. When I reopen the Serial Monitor, the ESP halts.
Awakening from esp_deep_sleep_start() reboots the ESP. I have to close then reopen the Serial Monitor to reconnect with the ESP. Seems pretty predictable.
In either case, I can only get my IDE’s Serial connection back by closing and re-opening the IDE Serial Monitor. esp_light_sleep_start() behaves inconsistently with the IDE Serial Monitor, usually hangs up using Serial Monitor.
What I’d hope to see is that the light_ or deep_sleep wakes up, in my case on a timer, and resumes execution, resumes the standard IDE Serial connection it had before the sleep, with no bad interaction between the ESP and the Serial Monitor.
Is there any way to gracefully regain the Arduino IDE Serial Monitor after a light_ or deep_sleep? Possible?
I am mystified. Thanks.
Windows 10 latest version
Arduino IDE latest version
ESP32-S2 Feather w/BME280
ESP32 Arduino package 2.0.2 (Package 2.0.1 had additional problems with ESP32-S2 sleep)
Using Board: Adafruit Feather ESP32-S2 package
Code: Select all
#define SKETCH_NAME "ESP32-S2-SLEEP"
#define SERIAL_SPEED 230400
void setup()
{
Serial.begin ( SERIAL_SPEED );
delay ( 3500 );
Serial.println ( "\n\n=======================================" );
Serial.println ( SKETCH_NAME );
Serial.println();
// Blink the onboard LED 10 times
Serial.print ( "\nLED_BUILTIN defined automatically as pin " );
Serial.println ( LED_BUILTIN );
Serial.println();
pinMode ( LED_BUILTIN, OUTPUT );
for ( int count = 0; count < 10; count++ )
{
digitalWrite ( LED_BUILTIN, HIGH );
delay ( 100 );
digitalWrite ( LED_BUILTIN, LOW );
delay ( 100 );
}
Serial.println ( " executing shutdown..." );
delay ( 1000 ); // Make sure the print gets out
uint64_t sleepTime = 2L * 1000L * 1000L;
esp_sleep_enable_timer_wakeup ( sleepTime ); // in microseconds
esp_light_sleep_start();
//esp_deep_sleep_start();
//Serial.begin ( SERIAL_SPEED ); // I have tried with this Serial.begin in and out - same result
//delay ( 3500 );
Serial.println ( "\n\nSetup done.\n\n" );
} // end setup
// Should never get here after deep_sleep
void loop()
{
Serial.println ( "\n\nvoid loop" );
// Blink the onboard LED 3 times
Serial.println ( "Blinking the onboard LED 3 times\n" );
for ( int count = 0; count < 3; count++ )
{
digitalWrite ( LED_BUILTIN, HIGH );
delay ( 100 );
digitalWrite ( LED_BUILTIN, LOW );
delay ( 100 );
}
delay ( 7500 );
} // end void loop