ESP32 extending the watchdog timeout

Hi all
I have a program that is triggering the watchdog timer with the following error message:

E (70958) task_wdt:  - async_tcp (CPU 0)
E (70958) task_wdt: Tasks currently running:
E (70958) task_wdt: CPU 0: IDLE0
E (70958) task_wdt: CPU 1: IDLE1
E (70958) task_wdt: Aborting.
abort() was called at PC 0x400e2f8b on core 0

Backtrace: 0x4008d054:0x3ffbe170 0x4008d285:0x3ffbe190 0x400e2f8b:0x3ffbe1b0 0x4008535d:0x3ffbe1d0 0x4015e7df:0x3ffbc150 0x400e4342:0x3ffbc170 0x4008af5d:0x3ffbc190 0x40089769:0x3ffbc1b0

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
src\main.cpp
Starting...

As this seems to be embedded in the following library I do not feel qualified or even know where to start to find out why it is timing out.
ottowinter/AsyncTCP-esphome @ ^1.1.1
So in my novice way I’ve read that you can extend the period of time until the watchdog times out by using the following expression.

Tuning

If you find the Interrupt watchdog timeout is triggering because an interrupt or critical section is running longer than the timeout period, consider rewriting the code: critical sections should be made as short as possible, with non-critical computation happening outside the critical section. Interrupt handlers should also perform the minimum possible amount of computation, consider pushing data into a queue from the ISR and processing it in a task instead. Neither critical sections or interrupt handlers should ever block waiting for another event to occur.

If changing the code to reduce the processing time is not possible or desirable, it’s possible to increase the CONFIG_ESP_INT_WDT_TIMEOUT_MS setting instead.

I cannot see a way of increasing this value assigned to the timeout can anyone help please?

Thank you

The words about “tuning” are generally true but maybe it doesn’t apply to your case – simply using a library like AsyncTCP should not burn-and-crash your ESP32 with a watchdog timeout.

I noticed taht

is not the “official” one though, GitHub - OttoWinter/AsyncTCP: Async TCP Library for ESP32 is a 1-year old fork of the welll-established library GitHub - me-no-dev/AsyncTCP: Async TCP Library for ESP32 with some modifications to it. Are you sure you need that fork and not the regular library?

What’s the exact program you’re running on the ESP32 plus platformio.ini?

Good afternoon and sorry for the delay in getting back to you.
I have adapted this program from G6EJD

I’ve added on a wireless relay and various other small changes to the program.

I’m very willing to change the Web server but I cannot find it in the platformio library?

If I want to install it straight from github what is the best way of getting me into platformio. Sorry that is a very dumb question but I should know
but want to check that I’m doing it right.

Thank you for your continued help

They mention explicitly to use the “official” version too, not the

one.

Can you exchange the library information in your platformio.ini for

lib_deps = 
   me-no-dev/AsyncTCP @ ^1.1.1

instead of the old one, remove the .pio folder of your project and retry building? Is the error still there?

Hi sorry for the delay for some reason my email wasn’t running strange?
Anyway I have included in the ini file

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
upload_speed=921600
monitor_speed = 115200
;upload_protocol = espota
;upload_port=192.168.1.206
lib_deps = 
  sparkfun/SparkFun SHTC3 Humidity and Temperature Sensor Library @ ^1.1.3
  me-no-dev/AsyncTCP @ ^1.1.1
  mathworks/ThingSpeak @ ^2.0.0

now there are a bunch of errors


so as I presume that I cannot use that library.

I really do appreciate your help and don’t want to use up a lot of your time would it help me uploading my version of the program to github?
Any suggestions would be really appreciated and I do apologise for troubling you.

Hm maybe the library is just not downloaded yet because the project wasn’t rebuilt.

Yes that would be great.

Also no need to apologize, this is a public forum and I choose what to do with my time :stuck_out_tongue:

Hello there Maxgerhardt
I have uploaded the components to github:
https://github.com/meathome2019/Smart-Thermostat.git
hope that helps

I think it’s just is that you included the faulty library.

I cloned your git repo and modified the platformio.ini to

[platformio]
src_dir = .

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
upload_speed=921600
monitor_speed = 115200
;upload_protocol = espota
;upload_port=192.168.1.206
lib_deps = 
  sparkfun/SparkFun SHTC3 Humidity and Temperature Sensor Library @ ^1.1.3
  ;adafruit/Adafruit BME280 Library @ ^2.1.2
  me-no-dev/AsyncTCP @ ^1.1.1
  mathworks/ThingSpeak @ ^2.0.0
  me-no-dev/ESP Async WebServer @ ^1.2.3

(redirected src_dir to “here” since there was no src/ folder, disabled OTA upload to flash via serial, added me-no-dev/ESP Async WebServer @ ^1.2.3, removed commented out wrong libs)

And when I adapt the WiFi credentials to mine, the ESP32 boots and outputs stuff

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
main.cpp
Starting...

Connecting to: <my WiFi SSID>
...................................
WiFi connected at: 192.168.1.162
Starting SPIFFS
E (6592) SPIFFS: mount failed, -10025
[E][SPIFFS.cpp:72] begin(): Mounting SPIFFS failed! Error: -1
Formatting SPIFFS (it may take some time)...
E (6597) SPIFFS: mount failed, -10025
Reading settings...
Recovering settings...
mDNS responder started
Device name: smartthero

Server Host1 not open

OTA Initialized
IP address: 192.168.1.162
OTA Setup
ErrorTemperature = 0.0, Humidity =  0
Thermostat OFF
Temperature = 0.0, Humidity =  0
Temperature = 0.0, Humidity =  0
Target Temperature = 21.0°
Thermostat ON

Server Host1 not open

Frost protection actuated...
Temperature = 0.0, Humidity =  0
Target Temperature = 21.0°
Thermostat ON
Frost protection actuated...
Temperature = 0.0, Humidity =  0
Target Temperature = 21.0°
Thermostat ON
Frost protection actuated...

I guess the errors are expected since I don’t have the needed webserver running at the specified IP address, nor do I have an actual temperature / humudity sensor attached to the ESP32.

But, the firmware does not crash-on-boot as your log shows.

So I’d recommend adapting my library changes (while removing the .pio folder to ensure that the old library is cleanly removed).

If it fails to start up WiFi, that might also indicate power problems. My ESP32 wouldn’t start connecting to WiFi when connected to the not-externally-powered USB hub, due to not getting the current it needs probably, but connecting the USB cable directly to my PC worked fine.

Maxgerhardt
thank you for your suggestions and I will certainly implement them.
I will post back with results
again thanking you for your time and trouble.

Hello again
I’ve made the changes as your suggestion to the platformio.ini

[platformio]
src_dir = .

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
upload_speed=921600
monitor_speed = 115200
;upload_protocol = espota
;upload_port=192.168.1.206
lib_deps = 
  sparkfun/SparkFun SHTC3 Humidity and Temperature Sensor Library @ ^1.1.3
  me-no-dev/AsyncTCP @ ^1.1.1
  mathworks/ThingSpeak @ ^2.0.0
  me-no-dev/ESP Async WebServer @ ^1.2.3

and tried clearing out the old libraries as you suggested by deleting .pio and I still have 47 problems. So obviously I’m doing something wrong again. I then copied the two files main.CPP and main.H to a new directory and try it again to compile and exactly the same result 47 problems very very similar to the list I previously published,
my include is as follows:

#include <Arduino.h>
/*
  concepts is Copyright (c) David Bird 2020
  See more at http://dsbird.org.uk
*/
//################# LIBRARIES ################
#include <WiFi.h>                      // Built-in
#include <ESPmDNS.h>                   // Built-in
#include <SPIFFS.h>                    // Built-in
#include "AsyncTCP.h"
#include "SparkFun_SHTC3.h"
#include <ArduinoOTA.h>
#include <ThingSpeak.h>
#include "Main.h"
#include "Wire.h"

did I miss something out?

You have to differentiate IntelliSense “problems” with build errors. IntelliSense won’t pick up the libs if they aren’t downloaded yet before the build.

Does the project build?

The includes-part of the code is unmodified from the repo

#include <Arduino.h>
/*
  concepts is Copyright (c) David Bird 2020
  See more at http://dsbird.org.uk
*/
//################# LIBRARIES ################
#include <WiFi.h>                      // Built-in
#include <ESPmDNS.h>                   // Built-in
#include <SPIFFS.h>                    // Built-in
#include "ESPAsyncWebServer.h"         // https://github.com/me-no-dev/ESPAsyncWebServer/tree/63b5303880023f17e1bca517ac593d8a33955e94
//#include "WebServer.h"
#include "SparkFun_SHTC3.h"
//#include <Adafruit_Sensor.h>           // Adafruit sensor
//#include <Adafruit_BME280.h>           // For BME280 support
//Adafruit_BME280 sensor;                // I2C mode
#include <ArduinoOTA.h>
#include <ThingSpeak.h>
#include "Main.h"
#include "Wire.h"

Hi there
well it now compiles and runs but still crashes out the longest running times so far is about one hour usually it crashes and restarts after 10/15 minutes.
Just for your information I’m running it off a desktop power supply which can deliver up to 5 A of current.

Do you have any further suggestions I can try?

Intersting, the firmware and hardware setup I have is running since crica 1h 20mins without a reboot or exception. But that also doesn’t have a sensor attached or sends data to the Server1 thing or ThingSpeak because I don’t have such a server running + overwrote the API key with an invalid one.

A few things to try would be:

  • flashing the original unmodified sketch to the device, and see if the same behavior occurs
    • if no → fault must be in code additions / delta;
    • if yes → fault existed in original sketch or used library code already.
    • tracks down the code one has to look at very well.
  • if a firmware is “crashing over time”, it may be an indication of a memory leak: some ressource / memory is allocated but not freed / released again (in some cases), leading to less-and-less memory becoming available over time, until the firmware cannot operate anymore. Such would e.g. be the case if one uses a WiFiClient object which isn’t stopped / released correctly or keeps connections open / doesn’t free its memory or internal resources. As a sanity check whether that is the case, you can periodically print the amount of available heap memory (and lowest ever-recorded memory amount), as stated here, with ESP.getFreeHeap() and ESP.getMinFreeHeap(). If that goes down over time, it’s a very strong indication that something is wrong there.
  • if crashes are rather random at different times, some memory corruption may occur leading to really wild behavior. If a crash produces an exception that is printed on the serial, that can be used to look at for debugging. The exception trace can be decoded with PlatformIO when serial monitor is open and a firmware in debug mode has been flashed. Can be achieved by putting
build_type = debug
monitor_filters = esp32_exception_decoder, log2file, time

in the platformio.ini. The log2file filter also produces a platformio-device-monitor-xyz.txt file in the project directory. So the monitor can just be left running and hopefully a crash will be observed and saved in the file, along with the decoded exception and the time at which it occurred.

The error and receiving is always the same error:

E (1022078) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (1022078) task_wdt:  - async_tcp (CPU 0)
E (1022078) task_wdt: Tasks currently running:
E (1022078) task_wdt: CPU 0: IDLE0
E (1022078) task_wdt: CPU 1: IDLE1
E (1022078) task_wdt: Aborting.
abort() was called at PC 0x400e9b0b on core 0

Backtrace: 0x4008d054:0x3ffbe170 0x4008d285:0x3ffbe190 0x400e9b0b:0x3ffbe1b0 0x4008535d:0x3ffbe1d0 0x40184d47:0x3ffbc150 0x400eaec2:0x3ffbc170 0x4008af5d:0x3ffbc190 0x40089769:0x3ffbc1b0

Rebooting...
ets Jun  8 2016 00:22:57

but I will follow through with your other suggestions and if you don’t mind I will let you know how I get on thank you for persevering.

Instead of opening a new thread, i’d post here since it’s related.

How can we modify the Watchdog timer variable “CONFIG_ESP_TASK_WDT_TIMEOUT_S”.
I tried from the platformio.ini as the following:
build_flags = **
** -D CONFIG_TASK_WDT_TIMEOUT_S = 20

but it gives me the following warning then it fails to build.

In file included from C:/Users/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-tinyusb.c:2:
C:/Users/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/dio_qspi/include/sdkconfig.h:799: warning: "CONFIG_TASK_WDT_TIMEOUT_S" redefined
 #define CONFIG_TASK_WDT_TIMEOUT_S CONFIG_ESP_TASK_WDT_TIMEOUT_S

<command-line>: note: this is the location of the previous definition
In file included from C:/Users/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/soc/esp32/include/soc/soc_caps.h:33,
                 from C:/Users/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-touch.c:15:
C:/Users/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/dio_qspi/include/sdkconfig.h:799: warning: "CONFIG_TASK_WDT_TIMEOUT_S" redefined
 #define CONFIG_TASK_WDT_TIMEOUT_S CONFIG_ESP_TASK_WDT_TIMEOUT_S

<command-line>: note: this is the location of the previous definition
Compiling .pio\build\heltec_wireless_stick_lite\FrameworkArduino\main.cpp.o
Compiling .pio\build\heltec_wireless_stick_lite\FrameworkArduino\stdlib_noniso.c.o
Compiling .pio\build\heltec_wireless_stick_lite\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\heltec_wireless_stick_lite\FrameworkArduino\wiring_shift.c.o
In file included from C:/Users/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freertos/include/esp_additions/freertos/FreeRTOSConfig.h:10,
                 from C:/Users/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freertos/include/freertos/FreeRTOS.h:57,
                 from C:/Users/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:1: 
C:/Users/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/dio_qspi/include/sdkconfig.h:799: warning: "CONFIG_TASK_WDT_TIMEOUT_S" redefined
 #define CONFIG_TASK_WDT_TIMEOUT_S CONFIG_ESP_TASK_WDT_TIMEOUT_S

<command-line>: note: this is the location of the previous definition
Archiving .pio\build\heltec_wireless_stick_lite\libFrameworkArduino.a
Indexing .pio\build\heltec_wireless_stick_lite\libFrameworkArduino.a
*** [.pio\build\heltec_wireless_stick_lite\firmware.elf] Implicit dependency `C:\Users\.platformio\platforms\espressif32\builder\=' not found, needed by target `.pio\build\heltec_wireless_stick_lite\firmware.elf'. 

Hello, i defined my own sdkconfig.h file and used the flag -I /path/sdkconfig.h but I still see the task-watch-dog get a timeout after the default 5 seconds.

how can I force platformIO to use my config file instead of the original one?

Thank you
Amir