Hi !
I’me working on a kind of trail camera (wildlife cam), with a streaming async server, telegram notifications and deepsleep to save batteries.
when trying to put the esp32 in deepsleep, it wakes up immediatly, with the following error :
E (40042) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (40042) task_wdt: – async_tcp (CPU 0)
E (40042) task_wdt: Tasks currently running:
E (40042) task_wdt: CPU 0: IDLE0
E (40042) task_wdt: CPU 1: IDLE1
E (40042) task_wdt: Aborting.
abort() was called at PC 0x400e550f on core 0
Backtrace: 0x400921d8:0x3ffbe170 0x40092409:0x3ffbe190 0x400e550f:0x3ffbe1b0 0x40087df5:0x3ffbe1d0 0x40176c4f:0x3ffbc880 0x400e6fa6:0x3ffbc8a0 0x400900e1:0x3ffbc8c0 0x4008e8ed:0x3ffbc8e0
After using the decoding tool, it gaves me the following information, which I’m unable to understand, could you give me any advice ?
Decoding stack results
0x400921d8: invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 155
0x40092409: abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 170
0x400e550f: task_wdt_isr at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/task_wdt.c line 174
0x40176c4f: esp_pm_impl_waiti at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/pm_esp32.c line 492
0x400e6fa6: esp_vApplicationIdleHook at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/freertos_hooks.c line 63
0x400900e1: prvIdleTask at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 3382
0x4008e8ed: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
Some info :
-ESP32 AI thinker cam
-ESP32 V 1.0.4
I don’t share the code here as it is quite long and messy, but the deepsleep sequence here :
void dodopir() { pinMode(4, OUTPUT); digitalWrite(4, LOW); rtc_gpio_hold_en(GPIO_NUM_4); esp_sleep_enable_ext0_wakeup(GPIO_NUM_13, 0); bot.sendMessage(chat_id, "Dodo Pir", ""); Serial.println("dodopir"); client_tcp.stop(); server.end(); delay(5000); esp_sleep_enable_ext0_wakeup(GPIO_NUM_13, 0); esp_deep_sleep_start(); delay(500); }
Any advice would be nice ! Thanks by advance,
Antoine
Hi.
What triggers the dodopir() function?
Where is it called in the code? In which section of the code that function is called?
Regards,
Sara
Hi Sara,
The function is triggered by a button on the html page, an extract :
<button class="button" id="pir" onclick="Sleepfunct('pir');" >Sleep Pir</button>
function Sleepfunct(x) {
var xhr = new XMLHttpRequest();
{ xhr.open("GET", "/sleep?&state="+ x , true); }
xhr.send();
}
// Send a GET request to <ESP_IP>/slider?value=<inputMessage>
server.on("/sleep", HTTP_GET, [] (AsyncWebServerRequest * request) {
String inputMessage4;
// GET input1 value on <ESP_IP>/slider?value=<inputMessage>
if (request->hasParam(PARAM_INPUT_4)) {
inputMessage4 = request->getParam(PARAM_INPUT_4)->value();
if (inputMessage4 == "pir" ) {
dodopir();
}
else if (inputMessage4 == "delais1") {
dododelais1();
}
else if (inputMessage4 == "delais3") {
dododelais3();
}
else if (inputMessage4 == "total" ) {
dodototal();
}
else {
delay(1);
}
}
request->send(200, "text/plain", "OK");
});
This is an independent function (under Loop() in my case), only called when requested by the button.
Sorry for sharing only snippets, I don’t see a convenient way to share all the code here,
Thanks !
Antoine
Hi.
I think you’re getting that error because you can’t have functions with delays and all that inside the server.on().
Instead, you should have boolean variables that change accordingly to the request. Then, in the loop(), check for the state of those variables and run the corresponding function.
Let me know if this is clear.
Regards,
Sara
Hi,
Thanks for your help, I replaced all delay() with a function using millis(), I still have the same issue :/
int attend(int a) {
int b = millis();
while (millis() - b < a) {
}
}
Seeing the error message, it seems that some tasks are still running in the background isn’t it ?
Thanks again,
Antoine,
Hi.
You can still have the delays(), but the functions can’t run inside the server.on() function. You need to run them on the loop().
Are you running the function on the loop()? Inside the server.on() you should only change the value of your boolean variables, then on the loop(), run the corresponding functions.
Regards,
Sara