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:
- // I won't hide these informations bellow because this is just a test. You can compile on your esp32
- #define BLYNK_TEMPLATE_ID "TMPLc9VK-ym3"
- #define BLYNK_DEVICE_NAME "Wifi Bluetooth ESP32 DHT Station"
- #define BLYNK_AUTH_TOKEN "IzH-vvhVf0uLJaV54Ziero7kjUiFeq5g"
- #include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
- #include <BlynkSimpleEsp32.h>
- #define TRIGGER_PIN 22
- #define LED_PIN 23
- TaskHandle_t Task1;
- int timeout = 120;
- unsigned long blink_timer;
- char auth[] = BLYNK_AUTH_TOKEN;
- WiFiManager wm;
- void wifi_stuff( void * pvParameters ){
- Serial.print("wifi_stuff running on core ");
- Serial.println(xPortGetCoreID());
- for(;;){
- if(!Blynk.connected()){
- wm.autoConnect();
- Blynk.config(auth);
- Blynk.connect(5000);
- }
- if ( digitalRead(TRIGGER_PIN) == LOW) {
- WiFiManager wm;
- wm.resetSettings();
- wm.setConfigPortalTimeout(timeout);
- if (!wm.startConfigPortal("OnDemandAP")) {
- Serial.println("failed to connect and hit timeout");
- }
- wm.setEnableConfigPortal(false);
- }
- }
- }
- void setup() {
- WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
- Serial.begin(115200);
- Serial.println("\n Starting");
- pinMode(TRIGGER_PIN, INPUT_PULLUP);
- pinMode(LED_PIN, OUTPUT);
- wm.setEnableConfigPortal(false);
- wm.autoConnect();
- Blynk.config(auth);
- Blynk.connect(5000); //blynk connect timeout
- xTaskCreatePinnedToCore(
- wifi_stuff, /* Task function. */
- "Task1", /* name of task. */
- 10000, /* Stack size of task */
- NULL, /* parameter of the task */
- tskIDLE_PRIORITY, /* priority of the task */
- &Task1, /* Task handle to keep track of created task */
- 0);
- }
- void loop() {
- Blynk.run();
- //bellow is for debug
- if (millis() - blink_timer > 300){
- digitalWrite(LED_PIN, !digitalRead(LED_PIN));
- blink_timer = millis();
- Serial.println(Blynk.connected());
- }
- }
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
Thank you, folks!