File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ .. _esp32_wdt :
2
+
3
+ When the WDT timeout is short, there is a software update issue:
4
+ you don't have enough time to copy the updates to the device.
5
+ ESP32 alows reinitialise the watchdog with a longer timeout - like an hour.
6
+
7
+ More comprehansive example usage::
8
+
9
+ # Save as 'main.py' and it will run automatically after 'boot.py'
10
+
11
+ import sys
12
+ from time import sleep
13
+ from machine import WDT, reset
14
+
15
+ try:
16
+ print('Press Ctrl-C to break the program.')
17
+ sleep(5)
18
+ print('Enable the WDT with a timeout of 5s.')
19
+ wdt = WDT(timeout=5000)
20
+
21
+ seconds = 1
22
+ while True: # infinite work loop
23
+ print('Do something useful in less than 5 seconds.')
24
+ print(f'Sleep {seconds} seconds.')
25
+ if seconds >= 5:
26
+ print(f'WDT will reboot the board.')
27
+ sleep(seconds)
28
+ seconds += 1
29
+ wdt.feed()
30
+
31
+ # 1/0 # uncoment this line to raise an runtime exception, then WDT reboot
32
+
33
+ # sys.exit() # uncomment this line for planned program exit
34
+
35
+ except SystemExit:
36
+ wdt = WDT(timeout=1000 * 60 * 60) # 1 hour before WDT reboot
37
+ print('Now you have 1 hour to update program on the board.')
38
+ print('When ready, type reset() on the REPL/WebREPL command line to reboot.')
39
+
You can’t perform that action at this time.
0 commit comments