fix: Update watchdog timer configuration and enable garbage collection

This commit is contained in:
Aaron 2025-11-08 16:12:59 -05:00
parent b93809946a
commit 988bec521f

View File

@ -1,12 +1,12 @@
from machine import Pin, WDT from machine import Pin, WDT # type: ignore
import time import time
import network import network
import json import json
import gc # ADD THIS - for garbage collection import gc # ADD THIS - for garbage collection
# Enable watchdog (8 seconds timeout - auto-reboot if frozen) # Enable watchdog (8 seconds timeout - auto-reboot if frozen)
wdt = WDT(timeout=60000) # wdt = WDT(timeout=8000) # Maximum is 8388ms, use 8000ms (8 seconds)
print("Watchdog enabled (60s timeout)") # print("Watchdog enabled (8s timeout)")
# Initialize pins (LED light onboard) # Initialize pins (LED light onboard)
led = Pin("LED", Pin.OUT) led = Pin("LED", Pin.OUT)
@ -317,6 +317,5 @@ while True:
print("NTP retry {} failed: {}".format(retry_ntp_attempts, e)) print("NTP retry {} failed: {}".format(retry_ntp_attempts, e))
gc.collect() gc.collect()
wdt.feed() # Reset watchdog timer (prevent auto-reboot)
time.sleep(0.1) time.sleep(0.1)
# ===== END: Main Loop ===== # ===== END: Main Loop =====