From ceb4cb8faac1688ea511b53c282469558ca27889 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Mon, 16 Nov 2020 17:58:14 +0100 Subject: [PATCH] Wtahdog support added. --- WLAN_Thermometer.ino | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/WLAN_Thermometer.ino b/WLAN_Thermometer.ino index b360cea..b1b9c86 100644 --- a/WLAN_Thermometer.ino +++ b/WLAN_Thermometer.ino @@ -12,6 +12,7 @@ #include #include #include +#include #define MDNS_NAME "wlanthermometer" #define AP_SSID_CONFIG_NAME "WLANTHERMOMETER-Config" @@ -33,6 +34,7 @@ #define DHTTYPE DHT22 #define FIRST_MIN_MAX 300000 // = 5 min #define HTML_RELOAD_PAGE_SECS 30 +#define WDT_TIMEOUT 30 LiquidCrystal_I2C lcd(LCD_I2C_ADDR, LCD_COL, LCD_ROW); looper sched; @@ -62,6 +64,9 @@ void setup() { bool ap_reset_last_state; + esp_task_wdt_init(WDT_TIMEOUT, true); + esp_task_wdt_add(NULL); + pinMode(AP_DATA_RESET_PIN, INPUT_PULLDOWN); pinMode(ONBOARD_LED, OUTPUT); @@ -161,6 +166,7 @@ void setup() sched.addJob(show_time, KRATE_TIME); sched.addJob(check_reset_ap_data, KRATE_RESET_AP_DATA); sched.addJob(check_datetime, KRATE_CHECK_DATETIME); + sched.addJob(watchdog_reset, WDT_TIMEOUT / 2); get_sensor_data(); temp[MIN] = temp[ACT]; @@ -590,3 +596,8 @@ void check_datetime(void) show_time(); } } + +void watchdog_reset(void) +{ + esp_task_wdt_reset(); +}