ESP32 Core 3.0.0: Help with Watchdog Timer
I need help making my ESP32 restart if the loop function doesn't call the reset watchdog for 2 minutes.
I found the following code in a tutorial, but it's not working. I'm getting the following error:
C:\Users\q\Documents\Arduino\test\test.ino: In function 'void setup()':
C:\Users\q\Documents\Arduino\test\test.ino:98:21: error: invalid conversion from 'int' to 'const esp_task_wdt_config_t*' [-fpermissive]
98 | esp_task_wdt_init(120, true);
| ^~~
| |
| int
C:\Users\q\Documents\Arduino\test\test.ino:98:20: error: too many arguments to function 'esp_err_t esp_task_wdt_init(const esp_task_wdt_config_t*)'
98 | esp_task_wdt_init(120, true);
| ~~~~~~~~~~~^
In file included from C:\Users\q\Documents\Arduino\test\test.ino:20:
C:\Users\q\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-442a798083/esp32/include/esp_system/include/esp_task_wdt.h:47:11: note: declared here
47 | esp_err_t esp_task_wdt_init(const esp_task_wdt_config_t *config);
| ^exit status 1
Compilation error: invalid conversion from 'int' to 'const esp_task_wdt_config_t*' [-fpermissive]
#include <esp_task_wdt.h>
void setup() {
esp_task_wdt_init(120, true);
xTaskCreate(
task1, // Task function pointer (the function that defines the task's behavior)
"Task1", // A descriptive name for the task
2000, // Stack depth in words (e.g., 1000 words for the task's stack)
NULL, // Task parameter (can be used to pass data to the task; set to NULL in this example)
2, // Task priority higher numbers represent higher priority.
&taskHandle // Task handle (used to reference the task)
);
void loop() {
esp_task_wdt_reset(); // Reset the watchdog timer to prevent it from triggering
}
void task1(void *parameter) {
for (;;) { //code here}
}