ESP8266 Deep Sleep wakes up but code doesn’t run after reset

I’m having a strange issue with ESP8266 deep sleep and I’m running out of ideas.

Problem:

The ESP8266 goes to deep sleep correctly, wakes up (reset happens), but after waking up it does not seem to execute my code properly. I only see the boot messages, but none of my Serial.println() outputs.


What I observe:

  • After wake-up I get:

rst cause:2

boot mode:(3,6)

  • This indicates the reset from deep sleep is happening.

  • However, after that, my code does not appear to run (no Serial output, no LED activity beyond initial test).


Test code (simplified):


#include <ESP8266WiFi.h>

void setup() {

Serial.begin(115200);

delay(2000);

Serial.println("BOOT OK");

pinMode(LED_BUILTIN, OUTPUT);

digitalWrite(LED_BUILTIN, LOW);

delay(200);

digitalWrite(LED_BUILTIN, HIGH);

delay(2000);

Serial.println("Going to sleep...");

Serial.flush();

ESP.deepSleep(5e6);

}

void loop() {}


Hardware setup:

  • ESP8266 (NodeMCU / clone, CH340 USB)

  • D0 (GPIO16) connected directly to RST

  • Also tried adding 1k resistor.


What I already tried:

  • :check_mark: Verified D0 (GPIO16) is used (not D1 etc.)

  • :check_mark: Tried with and without external resistor on RST

  • :check_mark: Removed ALL sensors (no DHT, nothing connected)

  • :check_mark: Used minimal test code (no WiFi, no Blynk)

  • :check_mark: Added delays at boot (2–5 seconds)

  • :check_mark: Used Serial.flush() before deep sleep

  • :check_mark: Tested with LED blinking instead of Serial → only blinks once after first boot

  • :check_mark: Tried disabling WiFi at startup (WiFi.mode(WIFI_OFF))

  • :check_mark: Checked that wake-up actually happens (rst cause:2)

  • :check_mark: Different USB cables and ports

  • :check_mark: Short wires between D0 and RST


Behavior:

  • First boot works perfectly

  • Goes to deep sleep

  • Wakes up (reset happens, boot log visible)

  • After that: code does not run anymore (no Serial, no LED blink)

What should i do?

Thanks!

There is a pinned post in every category called 'How to get the best from the forum'.
We are not sitting beside you, so we cannot see what you see.
Congrats on using code tags to post the code, but if you do an Auto Format (CMD/CTL-T) and remove most of the unneeded vertical white space, it would be even better.

@kolbaszka2014
Some boards have LED_BUILTIN connected to GPIO16

An ESP8266 is not an Arduino Nano ESP32; hence your topic has been moved to a more suitable location on the forum.

Try this:


void setup() {
  Serial.begin(115200);
  delay(5000);

  Serial.println("BOOT OK");

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);
  digitalWrite(LED_BUILTIN, HIGH);

  delay(5000);  // <-- ADD THIS

  Serial.println("Going to sleep...");
  Serial.flush();

  ESP.deepSleep(5e6);
}

I don't know if it's the same problem, but a while back there was an issue with clone Lolin D1 Mini boards, which also use the ESP8266, being unable to wake up from deep sleep:

https://forum.arduino.cc/t/wemos-d1-mini-pro-deepsleep-fail/1394898

The problem involved the 8-pin serial flash chip, and the fix was either to replace the chip with a Winbond, or jumper two points with a resistor.

Edit: It does appear to be the same problem. And if so, the fix would be a 10K pullup resistor (to 3.3V) to physical pin 2 of the serial flash chip. But on the NodeMCU, that flash chip may be under the metal shield.

Edit2: Google AI says:

SDD0/GPIO7 Pull-up Resistor: Some ESP8266 modules (like certain
AZ-Delivery or AI-Thinker boards) have issues with the flash memory
state after sleep. Soldering a 10k resistor between the 3.3V pin
and the SDD0 (GPIO7) pin can solve this issue.

Might be worth a try if you can find GPIO7. Unlikely to harm anything, and it either solves the problem or it doesn't.

The issue may be just in the Serial connection, have you tried something like

void setup() {
Serial.begin(115200);
delay(2000);
Serial.println("BOOT OK");
pinMode(LED_BUILTIN, OUTPUT);
for (uint8_t i = 0; i < 10; i++) {
  digitalWrite(LED_BUILTIN, LOW);
  delay(200);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(200);
}
(etc...)

and see if you actually see a flashing LED (should be on GPIO 2, active LOW)