NodeMCU Resetting and Entering Boot Mode

Hello everyone,
I have a project but my NodeMCU keeps resetting with causes 2 (even when I changed pins in order not to use D0, D2 and D8 because I read that they cause boot mode) and 4. This is causing my code to restart all over again every around 1 minute.
Exception (0):
epc1=0xc0030037 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000


ctx: cont
sp: 3ffffd40 end: 3fffffc0 offset: 01a0
3ffffee0: 3fff077c 00000000 00000000 4020724c
3ffffef0: 00000000 00000000 00000000 40201abd
3fffff00: 401052b1 00338145 3fff091c 00000000
3fffff10: 3ffee340 3fff091c 3ffe8500 3ffee9a4
3fffff20: 00000002 3fff091c 3ffe8500 40207cce
3fffff30: 4020850e 000001f4 000001f4 3ffee9a4
3fffff40: 3fff4444 00000000 00000000 40201b1c
3fffff50: 00000000 00000000 00000000 40202cb3
3fffff60: 3fff9e00 0041004f 80000015 40209858
3fffff70: 00000001 3ffee950 3fff077c 3fff08bc
3fffff80: 00000015 00000000 3ffee950 3fff08bc
3fffff90: 3fffdad0 00000000 3fff087c 40201b48
3fffffa0: 3fffdad0 00000000 3fff087c 40207e10
3fffffb0: feefeffe feefeffe 3ffe8500 40100c61

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d

Can anyone help me as soon as possible?
Thank you

#include <SoftwareSerial.h>
SoftwareSerial mySerial(D2, -1, true, 128);

char telegram[64];

int readTelegram();

void setup()
  Serial.begin(115200);  // 115200  256000

void loop() {
  int t = readTelegram();

int readTelegram() {
  if (mySerial.available() > 0) {
    int len = 0;
    char c;
    unsigned long timeout = 2;
    unsigned long start = millis();
    while ((len < 63) && (millis() - start < timeout)) {
      c =;
      if  ((c == '\n') || (c == '\r')) break;
      if ((c >= 32) && (c <= 126)) {
        telegram[len++] = c;
    telegram[len] = 0;
    return len;
  else return 0;

Pin D2 is connected to my “Smart Meter”, which generates a 27 lines, all terminated with \r\n.
Each line is max 47 char long (shortest is 5 char, longest 47 char).
It is at 115200 baud, with inverted signal.
The lines are sent every 10 sec.

Sometimes there is some garbage, and sometimes no \r\n is received, so I have a timeout (2mSec) and a filter (c = 32-127).

Earlier I tried ReadBytsUntil, it also crashed.
So I now tried to write it with just read() and my own filter and timeout function.

Also tried with a shorter timeout, using micros() and a value of 500.

After running for a couple of minutes, mostly less then an hour, it crashes with a WDT reset.

i think this this is your c file change this syntax

Also please run CheckFlashConfig example and verify that your flash chip is indeed 1Mb.

Looks like you need to erase flash completely and then try CheckFlashConfig with 512K option selected.

To erase the flash, you can use esptool (the same one which is used by Arduino to upload the sketch).
Run it like this: esptool -cp <port name> -cd ck -ce . Make sure the ESP is in bootloader mode before running this command (if you are triggering it manually).

A little question, does the NodeMCU do a software reset at each void loop() iteration? I had an infinitely running recursive method which I suspect to have causing the error. I fixed it. But I still have a problem because I am using Adafruit IO and so the data on a certain feed is read again at every loop() iteration although no new data is added to the feed.

CheckFlashConfig result:
Flash real id: 00164020
Flash real size: 4194304 bytes

Flash ide size: 4194304 bytes
Flash ide speed: 40000000 Hz
Flash ide mode: DIO
Flash Chip configuration ok.

So this is not a problem.

running the following code on an ESP8266 nodeMCU, the while(1) at end of loop causes a runtime error, reset (on Uno ok though):

Soft WDT reset

ctx: cont 
sp: 3ffef2a0 end: 3ffef4a0 offset: 01b0

3ffef450:  3ffe8438 00000001 3ffee448 402020a1  
3ffef460:  0000007f feefeffe 3ffee448 40202504  
3ffef470:  3fffdad0 00000000 3ffee448 3ffee46c  
3ffef480:  3fffdad0 00000000 3ffee464 402027b4  
3ffef490:  feefeffe feefeffe 3ffee480 40100114  

// --------------------------------------
    // i2c_scanner
    // This sketch tests the standard 7-bit addresses
    // Devices with higher bit address might not be seen properly.
    #include <Wire.h>

    void setup()
      Wire.begin(D4,D5);  // ESP8266
      //Wire.begin();       // Uno
      while (!Serial);             // Leonardo: wait for serial monitor
      Serial.println("\nI2C Scanner");
    void loop()
      byte error, address;
      int nDevices;
      nDevices = 0;
      for(address = 0; address < 127; address++ )

        if (address%16 == 0)  {   
          Serial.print( (address+1)/16);
          Serial.print("  ");

        if(address==0) {
           Serial.print("** ");
        error = Wire.endTransmission();
        if (error == 0)
          if (address<16) Serial.print("0"); 
          Serial.print(address,HEX); Serial.print(" ");         
        else if (error==4)
          Serial.print("?? ");   
           Serial.print("-- ");   
      Serial.print("found: "); Serial.print(nDevices); Serial.print(" devices \n");
      //delay(5000);  /// <<< fine on all boards
      while(1);    // <<<<<<<<<< runtime error: reset on ESP8266 // Uno: ok


0x4010023c: millis() at C:\Users\User\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266\ core_esp8266_wiring.cpp line 188
0x401006d9: _umm_free(void)* at C:\Users\User\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc\ umm_malloc.cpp line 1380
0x40202bc8: Adafruit_MQTT::processPackets(short) at C:\Users\User\Documents\Arduino\libraries\Adafruit_MQTT_Library-master\ Adafruit_MQTT.cpp line 418
0x402097d8: Adafruit_MQTT_Client::connected() at C:\Users\User\Documents\Arduino\libraries\Adafruit_MQTT_Library-master\ Adafruit_MQTT_Client.cpp line 48
0x40201f84: AdafruitIO::run(unsigned short) at C:\Users\User\Documents\Arduino\libraries\Adafruit_IO_Arduino-master\src\ AdafruitIO.cpp line 179 0x402017df: loop() at C:\Users\User\Documents\Arduino\Project_NodeMCU/ Project_NodeMCU.ino line 142
0x4010015c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\User\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266\ core_esp8266_main.cpp line 156
0x40207c6d: esp_schedule() at C:\Users\User\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266\ core_esp8266_main.cpp line 109
0x40207d90: loop_wrapper() at C:\Users\User\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266\ core_esp8266_main.cpp line 176

what is your repo link ?

If you mean repository I do not have one.

Can libraries be a problem? I got the git version not the boards manager one and I have libraries transferred via USB from another pc.

1 Like

tri to contribute your repo on the github

My understanding is that the NodeMCU code core requires CPU time to process the wi-fi operations (whether you’re using them or not). So you can’t run a while(1) because it doesn’t allow the wi-fi core to run, and the watchdog will reset the CPU.
You should include somewhere in any infinite loop (including the main loop) a delay(nnn); line or a yield(); line, either of which allows the background tasks to run periodically (when those commands are called).