While messing with an ESP8266 for the past couple of days, I decided I should look into how the watch dog timer operates.
Turns out the WDT is enabled automatically for the ESP8266. Most of the library routines reset it so you may never even know it is running unless your program hangs in a loop.
My primary resource for researching ESP8266 WDT was:
Hardware and Software Timers
There is a hardware WDT and a software WDT. The HW WDT is always running and will reset the MCU after about 6 seconds if the HW WDT timer is not reset.
The SW WDT seems to reset the MCU at 1.5 about seconds. You can enable/disable the SW WDT, but not the HW WDT. There seems to be little point in disabling the SW WDT as you must reset it to also reset the HW WDT.
Enabling the Software WDT
As previously mentioned, the SW WDT is running by default. If you wish to disable it, the SW WDT is disabled with
The SW WDT is enabled with:
While you must pass a timeout value to wdtEnable, it is currently ignored.
Resetting, Kicking, Feeding the Dog
As mentioned before, most of the libraries will automatically reset the WDT for you so you should not have to do so. But if you are doing something compute bound that will take more than a second or so, you should manually reset the timer with
Unlike Teensy and Arduino, WDT is very easy to use. The downside is when the timer pops, the system just resets. You can’t jump to some code to handle the reset.