I have a node MCU and it hangs when I used a deep sleep, as shown in the image attached. My code looks like this:

 * ESP8266 Deep sleep mode example
 * Rui Santos 
 * Complete Project Details https://randomnerdtutorials.com
void setup() {

  // Wait for serial to initialize.
  while(!Serial) { }
  // Deep sleep mode for 30 seconds, the ESP8266 wakes up by itself when GPIO 16 (D0 in NodeMCU board) is connected to the RESET pin
  Serial.println("I'm awake, but I'm going into deep sleep mode for 30 seconds");
  // Deep sleep mode until RESET pin is connected to a LOW signal (for example pushbutton or magnetic reed switch)
  //Serial.println("I'm awake, but I'm going into deep sleep mode until RESET pin is connected to a LOW signal");

void loop() {


Please help!

  • 1
    remove while (!Serial) it doesn't do anything here. add delay(500); after Serial.begin. add Serial.flush before sleep – Juraj Feb 25 at 12:12
  • 1
    tried the same. No changes. Its still the same. – dachu darshan Feb 25 at 14:26
  • and what baud rate do you have set in Serial Monitor? do you see the ""I'm awake, but ..." message at first start after upload or at normal reset or power up? – Juraj Feb 25 at 16:06
  • The serial monitor also had the same baud rate as the code and I don't see that message printed through serial.print command – dachu darshan Feb 25 at 16:34
  • did you do all 3 changes I recommended? could you add the modified sketch as edit to the question – Juraj Feb 25 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.