/*
Deep sleep test
Pins RST and GPIO #16 shorted
*/
#define SECONDS_DS(seconds) ((seconds)*1000000UL)
#define SERIAL_DEBUG (1)
void setup() {
#if SERIAL_DEBUG
Serial.begin(115200);
Serial.println(F("\nGood morning, ESP"));
#endif
// Give user a chance to get control before going into deep sleep
delay(5000);
#if SERIAL_DEBUG
Serial.println(F("Good night"));
#endif
ESP.deepSleep(SECONDS_DS(10), WAKE_RF_DEFAULT);
// Execution resumes at the top of this function.
delay(100);
}
void loop() {
// This never executes because deep sleep resets the CPU.
}
I'd like to ask you a question related to this: I also have a code to deepSleep, which unfortunately doesn't work (as soon as I connect D0 and RST, it continuously resets). Could you spot where my mistake is?
[MY BUGGY CODE]
#define RST_PIN D0
void setup() {
Serial.begin(115200);
Serial.setTimeout(2000);
// Wait for serial to initialize.
while(!Serial) { }
Serial.println("READY");
digitalWrite(RST_PIN,HIGH); // ATTEMPT does it fix the automatic reset?
blink(2);
}
void loop() {
delay(1000);
blink(3);
//digitalWrite(RST_PIN,LOW);
ESP.deepSleep(10*1000000UL,WAKE_RF_DEFAULT);
}
/////////////////////////////////////////////////////////////////////
void blink(int n) {
static bool first_time = true;
if (first_time == true) {
pinMode(LED_BUILTIN, OUTPUT);
first_time = false;
}
digitalWrite(LED_BUILTIN, HIGH);
for (int i = 0; i < n; ++i) {
digitalWrite(LED_BUILTIN, LOW);
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
}
}
[YOUR CODE]
Code: Select all/*
Deep sleep test
Pins RST and GPIO #16 shorted
*/
#define SECONDS_DS(seconds) ((seconds)*1000000UL)
#define SERIAL_DEBUG (1)
void setup() {
#if SERIAL_DEBUG
Serial.begin(115200);
Serial.println(F("\nGood morning, ESP"));
#endif
// Give user a chance to get control before going into deep sleep
delay(5000);
#if SERIAL_DEBUG
Serial.println(F("Good night"));
#endif
ESP.deepSleep(SECONDS_DS(10), WAKE_RF_DEFAULT);
// Execution resumes at the top of this function.
delay(100);
}
void loop() {
// This never executes because deep sleep resets the CPU.
}
while(!Serial) { }
You should never stay in a loop like that, watchdog is been trigger after few amount of time, causing a reset loop...
while(!Serial) delay (1);
In the old days (actually not very long ago), I connected GPIO16 and RST using a wire. deepsleep worked until it stopped working. Maybe because I switched to a different ESP12 board. When it failed, the ESP never woke up from deepsleep.
Now I use a 470 ohm resistor which works on all boards I have tried.
I would remove the digitalWrite since I have never had to change anything on GPIO16 for deepsleep.