Esp32_nano watchdog timer

Hi everyone,

I am currently upgrading my boards from arduino nano to ESP32_NANO but having some troubles when using watchdog timer on ESP32_NANO. I tried the some codes i found online but there was error when compiling (esp_task_wdt_config_t twdt_config).

Hopefully there is someone who can share a simple watchdog timer code which is working on ESP32_NANO. i really like this board.

Thank you.

BTW: i am using Arduino IDE.

Topic moved !! Please do not post in "Uncategorized"; see the sticky topics in Uncategorized - Arduino Forum.

Screenshots of errors are basically useless. In IDE 1.8.19 you will see an "Copy error messages" button in the orange bar when an error occurs. Click it and paste the errors here using code tags.

Please post your sketch; do not forget the code tags.

I don't have ESP32 based boards. I did find a post (Watchdog - reset esp32 if stuck more than 120 seconds) with an example "snip" doing some research; I'm sure you can find more relevant examples as well as examples that don't need fixing. After fixing a number of errors in it, I did manage to compile it for the Arduino Nano ESP32.

Code below

#include <esp_task_wdt.h>

TaskHandle_t taskHandle;

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}
  }
}

I can not test this, you can take it from here.

Note:
I've never used RTOS based stuff so I do not know if this code is correct. But at least it compiles :smiley: