Hi all,
I am trying to implement the use of the WatchDogTimer as seen in several of the available examples.
I have this put in the definitions part of my code:
#include <esp_task_wdt.h>
#define WDT_TIMEOUT 3 // define a 3 seconds WDT (Watch Dog Timer)
And this in setup():
esp_task_wdt_init(WDT_TIMEOUT, true); // enable panic so ESP32 restarts
esp_task_wdt_add(NULL); // add current thread to WDT watch
And this in the loop() part:
esp_task_wdt_reset(); // Added to repeatedly reset the Watch Dog Timer
According to the example(s)s this should work, and since I had a 'hang' only ever 3-4 days, it did not happen so far, I think...
And that is where my question comes from:
Is there a way for the ESP32 to differentiate between a "Power-On' reboot, and a 'Forced by the WDT' ?
Maybe a stored register that can be read somehow, or an Interrupt Service Routine that can run as son as the WDT() is triggered?
If not by means of software, I am thinking of reading an analog input connected to a big, slowly charged capacitor, or an external, One-Shot delay timer like a NE555.
This way, if the ESP32 is booted from Power-On, that input is still seeing a low voltage, but when it reboots WDT initiated that input would already be high, so the program could decide based on that condition.
Anyway, my first interest would be a software solution.
Thanks for reading,
Leo