Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add watchdog #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions GoodWeLogger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, NTP_SERVER);
bool validTimeSet = false;
int reconnectCounter = 0;
#define WDT_TIMEOUT 600 // 600 seconds = 10 minutes


#ifdef REMOTE_DEBUGGING_ENABLED
RemoteDebug Debug;
Expand Down Expand Up @@ -101,6 +103,9 @@ void setup()
mqqtPublisher.start();
validTimeSet = timeClient.update();
timeClient.setTimeOffset(settings->timezone * 60 * 60);
// Initialize the watchdog timer
esp_task_wdt_init(WDT_TIMEOUT, true); // Enable panic so ESP32 restarts
esp_task_wdt_add(NULL); // Add the current task to the watchdog
}


Expand Down Expand Up @@ -170,6 +175,9 @@ void loop()

pvoutputPublisher.handle();
yield(); //prevent wathcdog timeout

// Feed the watchdog
esp_task_wdt_reset();

#ifdef REMOTE_DEBUGGING_ENABLED
Debug.handle();
Expand Down