ESP8266 the core includes a Debugging feature that is controllable over the IDE menu. The new menu points manage the real-time Debug messages. It is very useful to sort out watchdog trigger and exception errors. For debugging you can use Serial or Serial 1 and also you can choose the debug level such as WIFI, Core, OTA etc.
Many times you stuck at WDT reset and Stack Exception errors, this is most rarely used tool, many people don’t know it exists. Let’s get know to it, Its very powerful tool comes with NodeMCU or ESP8266.
Why I Need Debugging ?
To solve the mysterious problems, and get to know what’s going inside WiFi Library?
How to turn on debugging?
To turn on debugging over same programming serial. Go to tools menu choose debug port Serial
After Enabling Debug Port Set Debug Level I am using here WIFI
Depending on different program situations you can choose debug levels.
Note 1: Just enabling Debug port and setting Debug level won’t wok, You need to upload you code after enabling these settings.
Note 2: Debug port work’s at 115200 BAUD if you have not set the serial.
To demonstrate it’s uses and I am uploading a blank sketch with serial initialized that is minimum requirement.
Requirements
For usage of the debugging a Serial connection is required (Serial or Serial1).
The Serial Interface need to be initialized in the setup()
.
Set the Serial baud rate as high as possible for your Hardware setup.
Minimum sketch to use debugging:
void setup() { Serial.begin(115200); } void loop() { }
Now lets move how to turn on debugging. After setting and uploading above ketch I am opening serial monitor.
I have not given any SSID, PASSWORD or not written any single line which makes connection with my wifi, but it still connecting. This is called debugging. Many things are going inside ESP8266. That cause Watch Dog Reset issues or other exceptions.
Let’s make exception and see what happens?
void setup() { Serial.begin(115200); } void loop() { while(1); //Wait forever }
We got the WDT Soft Trigger >>Stack>> Error
By looking at error and this list of causes you can get clear idea that your code is stuck.