hardware wdt or software wdt is better in esp8266?

Jaya's picture

Offline

Joined: Sep 04, 2018

Replies: 1
hardware wdt or software wdt is better in esp8266?
July 16, 2019 - 1:18pm

i am doing a project where i am posting sensor data using dht11 and esp8266 to cloud. i know that esp8266 has two wdt(watch dog timer) i.e. hardware and software. i want to include the wdt in the program.

But i am confused that which will be better to use? software or hardware? 

Abhiemanyu Pandit's picture

Offline

Joined: Jan 21, 2019

Replies: 42
hardware wdt or software wdt is better in esp8266?
July 16, 2019 - 1:27pm

according to me the choosing the HW would be much more robust because it will also look at the software hang up for all the time. 

the software wdt has memory management complexity, interrupt activity as well as a software wdt wont work if the software is not executing properly. The hardware will always reliable in terms of resetting the esp is system hangs up.

the hw wdt will reset the processor starting the execution again which eleiminates any doubt of misbehaving the system. 

Abhiemanyu Pandit's picture

Offline

Joined: Jan 21, 2019

Replies: 42
hardware wdt or software wdt is better in esp8266?
July 16, 2019 - 1:36pm

moreover, it is completely depends upon the application that  which one is suited. the wdt can easily be enabled using software whereas the hw wdt is a bit tricky. 

you can use ESP.wdtDisable(); ESP.wdtEnable(); to control wdt by software. 

also to get a demo of hw wdt just disable software wdt and write this. 

void setup() {
 
 ESP.wdtDisable();
 while (1){};  // infinite loop to trigger wdt
 
}
 
void loop(){}