Wdt on the esp8266 hardware vs software

Thread Starter

quique123

Joined May 15, 2015
405
I have an Esp8266 with a dht22 measuring and posting to a web server. I understand the esp has a hardware and software wdt. I want to include a wdt in code to catch any hang times like more than an hour of not posting data.

Which would be better, the software or hardware wdt?
 

danadak

Joined Mar 10, 2018
4,057
In general HW approach more robust as it is a seeing eye dog on the SW.
Crude and limited vision, but simple in application. And its not subject to
I/O states in its operation, for the most part.

That is true of course if internal HW is reliable, which generally it is
compared to SW memory management complexity, interrupt activity,
for example.

More robust designs use dual processors in majority voting designs,
considered more non stop computing than simple WDT approaches.
But thats a whole class of design itself. There are dual core embedded
parts now available from the vendors.

Regards, Dana.
 

ArakelTheDragon

Joined Nov 18, 2016
1,366
I have an Esp8266 with a dht22 measuring and posting to a web server. I understand the esp has a hardware and software wdt. I want to include a wdt in code to catch any hang times like more than an hour of not posting data.

Which would be better, the software or hardware wdt?
Might be, but it needs to be tested. There should be a function to enable it.
 

ebp

Joined Feb 8, 2018
2,332
Hardware. The whole idea behind a watchdog is to get the system restarted if for any reason the processor loses its mind and normal program execution ceases. A software watchdog is useless if the software isn't being executed properly. However, there may be things that are worthwhile to implement in software, often in conjunction with hardware, too. For example you might want to start a timer when you start waiting for an expected input from something, so that you can attempt to recover gracefully if the input fails to arrive on time and the timer runs down, which is the situation you describe. A hardware watchdog is just going to reset the processor. Usually the maximum period for a watchdog time is quite short.
 

Thread Starter

quique123

Joined May 15, 2015
405
Ok thanks. So Im reading this article here: https://techtutorialsx.com/2017/01/21/esp8266-watchdog-functions/

Im confused because it begins talking about the sw wdt, and how ESP.wdtDisable() will disable the sw wdt, leaving the hw wdt still active. I also noticed this way of explaining things when reading about arduino wdt and how we always use wdt_disable() in the setup, to make sure that if we take a while setting up, the wdt doesnt trigger, and only after setting up stuff do we call wdt_enable().

The thing about explaining it by first introducing wdtDisable() is that it makes it seem that the wdt starts running as soon as the chip start, which isnt true, at least for arduino atmel chips. The only reason why wdt_disable() is in the startup, is because we call wdt_enable() elsewhere.

So my first question is, is this also true for esp8266; iow, the sw wdt doesnt get enabled automatically at startup, unless we call the WEsp.wdtEnable(1000), right?

So I would add the same thing to my existing code:
Code:
setup(){
Esp.wdtDisable();
//.....my other code
Esp.wdtEnable(1000);
}
loop(){
//all my other stuff...
Esp.wdtFeed();
}
Correct?
 
Top