in common you keep all your Serial.begin() and Serial.print(“hello”) statements, when you start to run your ESP battery powered, using the battery pins, or directly the 3.3V pin.
Unfortunately the C3 seems to have a problem to wake up (timed) after deep sleep, as it will crash on the active Serial.xy lines within the code.
Any thoughts?
As soon as you remove all the Serial.xy lines C3 wil work properly again…?!
This is the test-project i created, that will only work without serial.xy lines:
#include <Arduino.h>
# define sensor_power_pin 3 /* power up sensor */
# define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */
uint64_t time_to_sleep = 5; /* sleep for 5 seconds - short schedule just for testing */
void setup() {
//Serial.begin();
//Serial.println("Hello World");
pinMode(sensor_power_pin, OUTPUT);
/*power up sensor */
digitalWrite(sensor_power_pin, HIGH);
delay(5000);
digitalWrite(sensor_power_pin, LOW);
/* GO DEEP SLEEP */
Serial.println("Done - activating deepsleep mode");
time_to_sleep = time_to_sleep * uS_TO_S_FACTOR;
esp_sleep_enable_timer_wakeup(time_to_sleep);
Serial.flush();
esp_deep_sleep_start();
}
void loop() {
// put your main code here, to run repeatedly:
}
Hi,
thanks for the response… just tested your approach without success.
please keep in mind - the problem only occurs when the esp32c3 is battery powered, or connected to a USB cable without data-lines.
It looks like the ESP crashes somehow directly after wake up.
But how to debug? How to do error handling in that case?
Or is it simply a bug?
All other ESP’s do not crash due to missing serial/USB connection
This is the current code that will not work on a battery powered esp32c3 - remove all serial prints and it will work!
#include <Arduino.h>
# define sensor_power_pin 3 /* power up sensor */
# define uS_TO_S_FACTOR 1000000ULL /* Conversion factor for micro seconds to seconds */
uint64_t time_to_sleep = 5; /* sleep for 5 seconds - short schedule just for testing */
void setup() {
delay(2000);
Serial.begin();
Serial.println("Hello World");
pinMode(sensor_power_pin, OUTPUT);
/*power up sensor */
digitalWrite(sensor_power_pin, HIGH);
delay(1000);
digitalWrite(sensor_power_pin, LOW);
delay(1000);
digitalWrite(sensor_power_pin, HIGH);
delay(1000);
digitalWrite(sensor_power_pin, LOW);
delay(1000);
digitalWrite(sensor_power_pin, HIGH);
delay(1000);
digitalWrite(sensor_power_pin, LOW);
/* GO DEEP SLEEP */
Serial.println("Done - activating deepsleep mode");
time_to_sleep = time_to_sleep * uS_TO_S_FACTOR;
esp_sleep_enable_timer_wakeup(time_to_sleep);
Serial.flush();
esp_deep_sleep_start();
}
void loop() {
// put your main code here, to run repeatedly:
}```