Chat freely about anything...

User avatar
By bbx10node
#49625 I suggest debugging deep sleep separately. Disconnect other wires and hardware from the NodeMCU. Remove NodeMCU from the breadboard. Connect only RST and D0 using a jumper wire. The only other NodeMCU connection is the USB cable to the PC for power and programming. The following works fine on my Lolin NodeMCU. Arduino IDE 1.6.8.

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.
}
User avatar
By gabriele.labanca
#72024 Dear bbx10node, thanks a lot: your code (quoted) works just fine!
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]
Code: Select all#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.
}
User avatar
By gdsports
#72071 Adding a delay(1) should keep the watchdog happy.

Code: Select allwhile(!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.