WatchDog timer gets triggered when using the second Core with WiFi Manager Library.

macusking
Posts: 1
Joined: Wed May 18, 2022 4:59 pm

WatchDog timer gets triggered when using the second Core with WiFi Manager Library.

Postby macusking » Wed May 18, 2022 5:14 pm

Hello friends,
I'm killing some neuron cells trying to solve this problem.

The WiFi Manager library opens a Portal for 120 seconds for us to connect and set the wifi ssid and pass through your phone. While this portal is activated, the ESP32 keeps locked into that function (as expected).

When I try to run WiFi Manager is the default CORE1 which Arduino IDE makes as default, everything works as a charm.

Since I need to do things while this is happening, I'm trying to use the CORE0 for Wifi Manager tasks, and CORE1 for my code. However, using this, causes the watchdog timer to kick-in, rebooting my board.

Here's the sketch:
  1. // I won't hide these informations bellow because this is just a test. You can compile on your esp32
  2. #define BLYNK_TEMPLATE_ID "TMPLc9VK-ym3"
  3. #define BLYNK_DEVICE_NAME "Wifi Bluetooth ESP32 DHT Station"
  4. #define BLYNK_AUTH_TOKEN "IzH-vvhVf0uLJaV54Ziero7kjUiFeq5g"
  5.  
  6.  
  7. #include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
  8. #include <BlynkSimpleEsp32.h>
  9.  
  10.  
  11. #define TRIGGER_PIN 22
  12. #define LED_PIN 23
  13.  
  14. TaskHandle_t Task1;
  15.  
  16. int timeout = 120;
  17. unsigned long blink_timer;
  18.  
  19. char auth[] = BLYNK_AUTH_TOKEN;
  20.  
  21. WiFiManager wm;
  22.  
  23. void wifi_stuff( void * pvParameters ){
  24.   Serial.print("wifi_stuff running on core ");
  25.   Serial.println(xPortGetCoreID());
  26.  
  27.   for(;;){
  28.           if(!Blynk.connected()){
  29.     wm.autoConnect();
  30.      Blynk.config(auth);
  31.   Blynk.connect(5000);
  32.   }
  33.  
  34.   if ( digitalRead(TRIGGER_PIN) == LOW) {
  35.     WiFiManager wm;    
  36.     wm.resetSettings();
  37.     wm.setConfigPortalTimeout(timeout);
  38.  
  39.     if (!wm.startConfigPortal("OnDemandAP")) {
  40.       Serial.println("failed to connect and hit timeout");
  41.     }
  42. wm.setEnableConfigPortal(false);
  43.   }
  44.   }
  45. }
  46.  
  47. void setup() {
  48.   WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP  
  49.   Serial.begin(115200);
  50.   Serial.println("\n Starting");
  51.   pinMode(TRIGGER_PIN, INPUT_PULLUP);
  52.   pinMode(LED_PIN, OUTPUT);
  53.    wm.setEnableConfigPortal(false);
  54.    wm.autoConnect();
  55.   Blynk.config(auth);
  56.   Blynk.connect(5000); //blynk connect timeout
  57.     xTaskCreatePinnedToCore(
  58.                     wifi_stuff,   /* Task function. */
  59.                     "Task1",     /* name of task. */
  60.                     10000,       /* Stack size of task */
  61.                     NULL,        /* parameter of the task */
  62.                     tskIDLE_PRIORITY,           /* priority of the task */
  63.                     &Task1,      /* Task handle to keep track of created task */
  64.                     0);
  65. }
  66.  
  67. void loop() {
  68. Blynk.run();
  69. //bellow is for debug
  70. if (millis() - blink_timer > 300){
  71.     digitalWrite(LED_PIN, !digitalRead(LED_PIN));
  72.     blink_timer = millis();
  73.  Serial.println(Blynk.connected());
  74. }
  75. }
  76.  
Here's the error message I get in MONITOR after some seconds of running this code:

Code: Select all

E (13496) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (13496) task_wdt:  - IDLE0 (CPU 0)
E (13496) task_wdt: Tasks currently running:
E (13496) task_wdt: CPU 0: Task1
E (13496) task_wdt: CPU 1: loopTask
E (13496) task_wdt: Aborting.


How can I fix this? How to stop Core0 to kicking the watchdog while running a long function? And why doesn't this happens while running the the Core1 default Arduino setting?

In time: I'm using Arduino IDE. I'm also not a much experienced coder :roll:

Thank you, folks! 8-)

ESP_Sprite
Posts: 9745
Joined: Thu Nov 26, 2015 4:08 am

Re: WatchDog timer gets triggered when using the second Core with WiFi Manager Library.

Postby ESP_Sprite » Thu May 19, 2022 1:26 pm

I don't know much about Blynk and wm, but could the for loop in line 27 be spinning continuously? You could test that by putting a delay in there, see if the error goes away.

Who is online

Users browsing this forum: username and 107 guests