Reset Cause 4 Node MCU

There are countless forum posts on the reset problems with the ESP8266, but I have searched for hours and found no answers to my problem.

When uploading the program below to a NodeMCU ESP8266 based board, I get a recurring reset cause 4 - boot mode 3,2/3,3 (changes intermittently) problem which happens every 2 to 3 seconds.

I know this is a hardware watchdog problem but I don’t have any block code holding up the loop that is causing this? The board is functional as it runs blink with no problem and the example ESP8266 MQTT sketch without resetting.

Placing strategic yield(); functions in certain places had no effect.

Would be grateful if anyone could provide a fix.

Sorry I had to attach the code instead of posting it, it was too long to fit on here

ESPSketch2.ino (8.56 KB)

I know this is a hardware watchdog problem but I don't have any block code holding up the loop that is causing this?

as you said it is a hardware WDT reset, which should mean the code is not at fault.

NodeMCU ESP8266 based board,

you are going to have to be more specific than that.
From this reference it somehow seems to alternate between flash & jump boot mode, i had not heard of them before. Anyway i found something here on the jump mode under section 2.1 and there seems to be something that can be specified. You will have to sift though the library classes of the objects declared to find where anything like that happens. The code you posted is full of delay() and should run ok, and anyway before a hw WDT reset occurs, it should first do a sw WDT reset. Now it seems to be jumping to a location that holds no code. Have you specified the correct settings for the board, being memory size and flash type ?

Hi thanks for the reply,
To confirm I am using the ESP8266MOD based NodeMCU Amica (It's not written on it which version).
Thanks for pointing out its obviously a hardware problem not a code one. I'm going to try a few things from the page you linked which is very helpful.

I can also confirm that it does a reset cause 4 first with a different boot mode, and then I have to press the physical reset button for it to do anything or it will freeze and no longer run the program. Ill also add that the boards isn't connected to anything currently.
I just updated the boards manager for ESP based boards and it reset all the settings so I will try to change them to the correct type.

I can't find where its doing a software reset anywhere before it starts doing hardware resets though?

Furthermore it says on the back of the board on the silk screen to use 9600bps baud rate, but I always assumed to use 115200 with any ESP boards?

marlow_dupont:
When uploading the program below to a NodeMCU ESP8266 based board, I get a recurring reset cause 4 - boot mode 3,2/3,3 (changes intermittently) problem which happens every 2 to 3 seconds.

I am confused. Are you getting the error during upload, or during runtime?

During runtime, if the mqtt topic is "bedroom/logic/switchboard", you will get a WDT timeout because you have delays totalling more than 3 seconds.

It is poor design to put any blocking code in a callback routine. Set a flag then handle it during the loop.

EDIT: I uploaded the code with the sections including delays removed (such as the if statement for the mqtt topic Steve mentioned) and had the same issue.

Exactly what happens is I upload the code with no problem, it starts running the program and connects to the WiFi then to the MQTT server as it should. A few seconds elapse then it resets with this error message:

ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x4010f000, len 1392, room 16 
tail 0
chksum 0xd0
csum 0xd0
v3d128e5c
~ld

After resetting the program restarts and the same thing occurs again, and this loops endlessly (causing it to reset every 4-5 seconds constantly).

I understand that reset cause 4 is a hardware watchdog timeout, but the board isn't connected to anything yet i'm just flashing it as is. I've tried 3 different identical NodeMCU Amicas which all produced the same result, and adjusted the settings to be correct in accordance with your advice.

What I don't understand is why it doesn't do this reset problem when I upload blink, or the example ESP8266 MQTT sketch that comes with the Pub Sub library which also works fine. It confuses me as it points to a code problem, seeing as it can run other programs, but the reset error is not the software watchdog?

Thanks for everyone's help.
I found the problem - I had set the buzzer pin to 8 in the code as I had copied sections of it from an Arduino Nano sketch. You can't use pin 8 on ESP8266 and in the code where it set it to an output it would freeze and reset from that point onward.

1 Like

cause:4, boot mode:(3,7)you sais 3,2 & 3,3 before. Anyway great you found the solution.
Pin 8 as an OUTPUT, i’ll keep it in mind.

During runtime, if the mqtt topic is “bedroom/logic/switchboard”, you will get a WDT timeout because you have delays totalling more than 3 seconds.

nope, delay(); resets the wdt and incurs yield();

1 Like