Soft WDT reset on NodeMCU 1.0 when using IoT Cloud

I'm using a NodeMCU 1.0 (ESP-12E) and trying to connect to Arduino IoT Cloud. I can successfully connect to WiFi but after a few seconds of connecting a soft WDT reset is triggered. The device does not register as online on the IoT Cloud website.

Here's the serial monitor output of the error:

***** Arduino IoT Cloud - configuration info *****
Device ID: CORRECT ID
Thing ID: CORRECT ID
MQTT Broker: mqtts-up.iot.arduino.cc:8884
WiFi status ESP: 3

Connection to "WIFI NAME" failed
Retrying in  "500" milliseconds
Connection to "WIFI NAME" failed
Retrying in  "500" milliseconds
Connection to "WIFI NAME" failed
Retrying in  "500" milliseconds
Connection to "WIFI NAME" failed
Retrying in  "500" milliseconds
Connected to "WIFI NAME"

Soft WDT reset

>>>stack>>>

ctx: sys
sp: 3fffed00 end: 3fffffb0 offset: 01b0
3fffeeb0:  402393af 3ffeda4c 00000012 3ffefabc  
3fffeec0:  40239960 3ffeda4c 00000000 4023baa0  
3fffeed0:  4023938d 3ffedbc8 00000002 3ffeeb48  
3fffeee0:  3fffdc10 00000000 3ffef154 402076af  
3fffeef0:  0000003c 3fff19a4 3ffef154 40205f3d  
3fffef00:  0000001e 3fff19a4 3ffef154 4020757b  
3fffef10:  3ffecf48 3fff19a4 3ffef154 402067e0  
3fffef20:  3ffecf48 40100c03 3fff19a4 40205980  
3fffef30:  40100c3e 00000000 00000002 3ffeeb48  
3fffef40:  3fffdc10 00000000 3fff19a4 4024ef5c  
3fffef50:  40000f49 3fffdab0 3fffdab0 40000f49  
3fffef60:  40000e19 40001878 00000004 00000000  
3fffef70:  3fffff10 aa55aa55 00000012 401047b0  
3fffef80:  401047b6 00000004 00000000 bdc5bf3b  
3fffef90:  4010000d 7ba167e7 ab7d4c57 ad0e3aa2  
3fffefa0:  40100884 3fffef3c 40100831 3ffffdf8  
3fffefb0:  3fffffc0 00000000 00000000 feefeffe  
3fffefc0:  feefeffe feefeffe feefeffe feefeffe  
3fffefd0:  feefeffe feefeffe feefeffe feefeffe  
3fffefe0:  feefeffe feefeffe feefeffe feefeffe  
3fffeff0:  feefeffe feefeffe feefeffe feefeffe  
3ffff000:  feefeffe feefeffe feefeffe feefeffe  
3ffff010:  feefeffe feefeffe feefeffe feefeffe  
3ffff020:  feefeffe feefeffe feefeffe feefeffe  
3ffff030:  feefeffe feefeffe feefeffe feefeffe  
3ffff040:  feefeffe feefeffe feefeffe feefeffe  
3ffff050:  feefeffe feefeffe feefeffe feefeffe  
3ffff060:  feefeffe feefeffe feefeffe feefeffe  
3ffff070:  feefeffe feefeffe feefeffe feefeffe  
3ffff080:  feefeffe feefeffe feefeffe feefeffe  
3ffff090:  feefeffe feefeffe feefeffe feefeffe  
3ffff0a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff100:  feefeffe feefeffe feefeffe feefeffe  
3ffff110:  feefeffe feefeffe feefeffe feefeffe  
3ffff120:  feefeffe feefeffe feefeffe feefeffe  
3ffff130:  feefeffe feefeffe feefeffe feefeffe  
3ffff140:  feefeffe feefeffe feefeffe feefeffe  
3ffff150:  feefeffe feefeffe feefeffe feefeffe  
3ffff160:  feefeffe feefeffe feefeffe feefeffe  
3ffff170:  feefeffe feefeffe feefeffe feefeffe  
3ffff180:  feefeffe feefeffe feefeffe feefeffe  
3ffff190:  feefeffe feefeffe feefeffe feefeffe  
3ffff1a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff200:  feefeffe feefeffe feefeffe feefeffe  
3ffff210:  feefeffe feefeffe feefeffe feefeffe  
3ffff220:  feefeffe feefeffe feefeffe feefeffe  
3ffff230:  feefeffe feefeffe feefeffe feefeffe  
3ffff240:  feefeffe feefeffe feefeffe feefeffe  
3ffff250:  feefeffe feefeffe feefeffe feefeffe  
3ffff260:  feefeffe feefeffe feefeffe feefeffe  
3ffff270:  feefeffe feefeffe feefeffe feefeffe  
3ffff280:  feefeffe feefeffe feefeffe feefeffe  
3ffff290:  feefeffe feefeffe feefeffe feefeffe  
3ffff2a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff300:  feefeffe feefeffe feefeffe feefeffe  
3ffff310:  feefeffe feefeffe feefeffe feefeffe  
3ffff320:  feefeffe feefeffe feefeffe feefeffe  
3ffff330:  feefeffe feefeffe feefeffe feefeffe  
3ffff340:  feefeffe feefeffe feefeffe feefeffe  
3ffff350:  feefeffe feefeffe feefeffe feefeffe  
3ffff360:  feefeffe feefeffe feefeffe feefeffe  
3ffff370:  feefeffe feefeffe feefeffe feefeffe  
3ffff380:  feefeffe feefeffe feefeffe feefeffe  
3ffff390:  feefeffe feefeffe feefeffe feefeffe  
3ffff3a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff400:  feefeffe feefeffe feefeffe feefeffe  
3ffff410:  feefeffe feefeffe feefeffe feefeffe  
3ffff420:  feefeffe feefeffe feefeffe feefeffe  
3ffff430:  feefeffe feefeffe feefeffe feefeffe  
3ffff440:  feefeffe feefeffe feefeffe feefeffe  
3ffff450:  feefeffe feefeffe feefeffe feefeffe  
3ffff460:  feefeffe feefeffe feefeffe feefeffe  
3ffff470:  feefeffe feefeffe feefeffe feefeffe  
3ffff480:  feefeffe feefeffe feefeffe feefeffe  
3ffff490:  feefeffe feefeffe feefeffe feefeffe  
3ffff4a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4c0:  feefeffe feefeffe 53002200 4000050c  
3ffff4d0:  3fffc278 40102368 3fffc200 00000022  
3ffff4e0:  3ffff4f0 feefeffe feefeffe feefeffe  
3fH!⸮ȩ1⸮D⸮N

I tried using ArduinoCloud.begin(ArduinoIoTPreferredConnection, false) to disable the watchdog timer included in the ArduinoIoTCloud library without success.

Here's my .ino and thingProperties.h

#include "arduino_secrets.h"
#include "thingProperties.h"

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);

  // Defined in thingProperties.h
  initProperties();
  
  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
  */
  setDebugMessageLevel(4);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here
}

void onNumberChange() {
  // Do something
}
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>


const char THING_ID[]           = "CORRECT ID";
const char DEVICE_LOGIN_NAME[]  = "CORRECT ID";

const char SSID[]               = SECRET_SSID;    // Network SSID (name)
const char PASS[]               = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[]  = SECRET_DEVICE_KEY;    // Secret device password

void onNumberChange();

int number;

void initProperties(){

  ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
  ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
  ArduinoCloud.setThingId(THING_ID);
  ArduinoCloud.addProperty(number, READWRITE, ON_CHANGE, onNumberChange, 5);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

Any suggestions? The only thing I can come up with is that the ArduinoCloud.update() function is too slow and triggers the onboard WDT.

Thanks in advance!

Hope you get an answer, taking a look at the stack output might help

But that's the basic scene, so not sure how it's erroring on the watchdog. Faulty board?

Thanks for the decoder! I have tested the exact same code (mentioned in the original post) on two different NodeMCU boards with the same result and the same exception stack trace.

Decoding stack results
0x40205d57: WiFiClient::available() at C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src\WiFiClient.cpp line 263
0x40207632: BearSSL::WiFiClientSecure::_run_until(unsigned int, bool) at C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 489
0x402076af: BearSSL::WiFiClientSecure::flush(unsigned int) at C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 204
0x40205f3d: WiFiClient::stop(unsigned int) at C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src\WiFiClient.cpp line 326
0x4020757b: BearSSL::WiFiClientSecure::stop(unsigned int) at C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 191
0x402067e0: WiFiClient::stopAll() at C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src\WiFiClient.cpp line 386
0x40205980: ESP8266WiFiGenericClass::_eventCallback(void*) at c:\users\administrator\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/range_access.h line 48

Ok, I got it to work.

As I'm using a NodeMCU 1.0 the code uploading process is not that straightforward. See thread Arduino IoT Cloud not recognizing NodeMCU 1.0 (ESP-12E).

The problem that caused the soft WDT reset (software watchdog timer) to trigger was the usage of an old ESP8266 board platform on the Arduino IDE. Version 2.5.0 to be more precise.

The solution was to update it to version 2.5.1 or higher, however, keeping it below 3.0.0 as then the Arduino IoT Cloud library wouldn't work anymore.