class WDT – Watchdog Timer
2023-08-31
This class provides system restart operation when application program exception occurs.
Constructors
machine.WDT
class machine.WDT(period)
Creates a software watchdog object.
Parameter:
period
- Integer type. Set software watchdog detection time. Unit: second.
Return Value:
Returns the software watchdog object.
Methods
wdt.feed
wdt.feed()
This method feeds the watchdog.
Return Value:
Returns integer 0
when the execution is successful.
wdt.stop
wdt.stop()
This method disables the software watchdog.
Return Value:
Returns integer 0
when the execution is successful.
Example:
from machine import WDT
from machine import Timer
import utime
'''
The following two global variables are necessary. You can modify the values of these two global variables based on your actual projects.
'''
PROJECT_NAME = "QuecPython_WDT_example"
PROJECT_VERSION = "1.0.0"
timer1 = Timer(Timer.Timer1)
def feed(t):
wdt.feed()
if __name__ == '__main__':
wdt = WDT(20) # Enables the watchdog and sets the timeout period
timer1.start(period=15000, mode=timer1.PERIODIC, callback=feed) # Feeds the watchdog
# wdt.stop()