Putting the Xiao esp32c3 to sleep

Using the Arduino IDE, I uploaded the following to my Xiao esp32c3:

void setup() {
Serial.begin(9600);
delay(5000);
}
void loop() {
Serial.println(“Here we go to sleep”);
delay(5000);
esp_sleep_enable_timer_wakeup(1000000);
esp_light_sleep_start();
delay(5000);
Serial.println(“Now we are awake again”);
}

Upon opening the serial monitor, I see “Here we go to sleep”…and then nothing. Attempting to do anything further in the Arduino IDE, produces the following error:

Connecting…An error occurred while uploading the sketch
A fatal error occurred: Failed to connect to ESP32-C3: No serial data received.
For troubleshooting steps visit: Troubleshooting - ESP32 - — esptool.py latest documentation

Reloading the bootloader (depress boot button, connect board, release buttor) clears this condition. Rebooting my PC does not.

Okay, first of all, I want to thank everyone who responded to my initial post!

Assuming that sleep mode does to f-up the COM port connection, I uploaded the following:

int led = D10;

void setup() {
pinMode(led, OUTPUT);
esp_sleep_enable_timer_wakeup(2000000);
}

void loop() {
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);

esp_light_sleep_start();

}

Lo, and behold, I get an led that blinks every two seconds!

The saga continues!

With the above sketch running on my Xiao esp32c3, I changed the delay to 200 & tried to re-load.

I say “tried,” because when I hit the upload button, after compiling, I got: “A fatal error occurred: Could not open COMx, the port doesn’t exist.”

So, without even opening or attempting to write to the Serial port, the sleep function has bolixed it up!

HOWEVER…

It does not interfere with the wifi connection, so I can write debug messages to my mqtt server instead of to the Arduino serial monitor! I just have to remember that I have to re-load the bootloader whenever I want to upload a modified sketch.

1 Like