Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
The CircuitPython watchdog module lets a microcontroller recover when application code stops making progress. Configure the single watchdog instance at microcontroller.watchdog, set a timeout, select WatchDogMode.RESET or WatchDogMode.RAISE, and call feed() only while your health checks show that the program is functioning. If the timer expires, CircuitPython either resets the system or raises watchdog.WatchDogTimeout, depending on the selected mode.
The five-second value commonly shown in examples is only an illustration. Choose a timeout longer than the application’s longest legitimate interval between successful health checks, include timing margin, and verify watchdog support and disable behavior for the exact board and CircuitPython release. The stable watchdog reference is the authoritative API description.
As an Amazon Associate I earn from qualifying purchases.
What is the CircuitPython watchdog module?
A watchdog timer is a hardware- or firmware-backed safety mechanism that expects an application to report progress periodically. In CircuitPython, the watchdog module supplies the WatchDogMode and WatchDogTimeout definitions, while the actual timer is the sole instance exposed as microcontroller.watchdog. The official reference describes it as support for a Watchdog Timer and explains that it can detect a code lockup or another unrecoverable program state.
The timer does not inspect your application and cannot prove that every task is healthy. Your code must configure a maximum interval, activate a mode, and feed the timer often enough. A loop that keeps feeding after a critical task has stopped can hide the very failure the watchdog is meant to reveal, so feeding should follow meaningful health evidence rather than merely elapsed time.
Popular on Amazon
- 【90 Degree Full Function USB C Adapter】Supports the latest USB4 standard for up to 40Gbps of bandwidth, 8K video support, and up to 240W Fast charging; Support USB PD 3.1 Extended Power Range (EPR) including 140W, 180W and 240W. Your productivity is easily doubled. *Warm Tip: For the best fit, please make sure the USB-C port is fully exposed; thick or bulky cases may affect compatibility.
- 【Reliable Quality】Made from high-quality, scratch-resistant aluminum alloy, delicate metal frame. get excellent wear resistance and heat dissipation. Non-Slip Design for easier insertion and removal.
- 【Small and portable】Ultra thin size, ultra compact design, a petite physique that matches the minimalist design of your modern laptops. Coming with a slim figure that won't block the port next to the one it's plugged into.
- 【Compatibility】Widely work with most usb c, thunderbolt 4/3 devices. Compatibilit for ROG Ally, Steam Deck, Switch, MacBook Pro, Quest 3 VR headset, Surface Book 2, iPhone 18/17/16/15, Samsung Galaxy S23/S22/S21, Note 20/10, Google Pixel, ChromeBook, etc.
- 【Excellence Customer Support】If you experience any issues or cable failure, simply reach out to our dedicated customer service team. We provide a prompt response within 18 hours, providing you with the necessary technical support to resolve any concerns.
How do I use the CircuitPython watchdog module?
You need a CircuitPython-compatible microcontroller board, firmware that implements the watchdog binding, and code that can perform a periodic health check. The exact board support is platform-dependent; consult the watchdog documentation for your release before relying on a particular behavior.
- Import the watchdog instance from
microcontrollerand the mode enum fromwatchdog. - Assign
watchdog.timeoutto the maximum allowed interval between feeds. Assigning the timeout also feeds the timer. - Assign
watchdog.modetoWatchDogMode.RESETorWatchDogMode.RAISE. Setting the mode activates the watchdog. - Perform work and feed the timer only after the application has completed its health checks.
- During bring-up, confirm what happens on expiry and whether the target platform permits later disabling.
This minimal reset-mode pattern follows the documented API:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallfrom microcontroller import watchdog
from watchdog import WatchDogMode
watchdog.timeout = 5
watchdog.mode = WatchDogMode.RESET
while True:
# Do work and check that the application is healthy.
watchdog.feed()
Here, 5 means five seconds between feeds; it is not a universal recommendation. If any legitimate operation can block for longer than that, the timer can reset the board even though the application is behaving normally.
What does the timeout setting do?
watchdog.timeout defines the maximum interval the timer will allow between successful feeds. The API documents that assigning this property also feeds the timer, so configuration itself refreshes the countdown. The timer is not active merely because a timeout has been assigned; assigning mode activates the chosen expiry action.
Size the timeout from the application’s real schedule:
Also popular on Amazon
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
- Find the longest normal gap between health checks, including blocking peripheral operations, sensor conversion, storage access, communication retries, and deliberate low-power waits.
- Add margin for ordinary scheduling variation and startup work that occurs after activation.
- Keep the interval short enough to recover from a genuine lockup in a useful time.
- Revisit the value whenever a new blocking operation or firmware change alters the timing.
A very short interval produces nuisance resets; an interval that is too long delays recovery. The correct value is therefore an application-specific engineering decision, not a performance figure supplied by CircuitPython.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →What is the difference between RESET and RAISE?
Both modes use the same timeout and feeding rules, but expiry has a different result. Choose RESET when a full restart is the intended recovery action; choose RAISE when application code needs to catch a timeout exception and decide what to do next.
| Mode | When the timer expires | Typical use | Important limitation |
|---|---|---|---|
WatchDogMode.RESET |
The system resets. | Restart an unattended device after a lockup. | State in RAM is lost, so startup code must restore safe operation. |
WatchDogMode.RAISE |
watchdog.WatchDogTimeout is raised. |
Let a handler log, shut down hardware, or attempt a controlled recovery. | An exception handler must itself remain reliable; catching it does not automatically reset the board. |
The distinction is behavioral, not a second timer. In either mode, a feed that never occurs allows expiry, while a feed performed on schedule postpones it.
How do I use RAISE mode safely?
Wrap the section that can legitimately recover from a timeout, and make the recovery path finite and conservative. The following example shows the documented exception type; the recovery policy is application-specific:
from microcontroller import watchdog
from watchdog import WatchDogMode
watchdog.timeout = 10
watchdog.mode = WatchDogMode.RAISE
try:
while True:
do_work()
if system_is_healthy():
watchdog.feed()
except watchdog.WatchDogTimeout:
put_outputs_in_a_safe_state()
record_failure()
# Decide whether to retry, enter a safe loop, or request another reset.
do_work(), system_is_healthy(), and the recovery functions are placeholders. A timeout exception can occur at a point where the program holds partial state, so recovery should not assume that every peripheral transaction completed. If a deterministic restart is safer than in-process recovery, RESET is the clearer mode.
Free tools Windows power users keep installed
One-click scans. No signup required.
Also popular on Amazon
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Where should feed() go in my loop?
Place feed() after the checks that define “healthy,” not unconditionally at the top of a loop. For a device with several responsibilities, a supervisor can track completion timestamps or status flags for each critical task and feed only when all required conditions are satisfied.
from microcontroller import watchdog
from watchdog import WatchDogMode
watchdog.timeout = 15
watchdog.mode = WatchDogMode.RESET
while True:
sensor_ok = update_sensors()
link_ok = service_communication()
storage_ok = flush_pending_data()
if sensor_ok and link_ok and storage_ok:
watchdog.feed()
This pattern is an engineering safeguard derived from the feed/expiry mechanism: if the main loop spins while one critical operation is dead, unconditional feeding can conceal that fault. Do not claim that a watchdog catches every deadlock, peripheral failure, or logic error; it only acts when the configured timer is allowed to expire.
The reference specifies that feed() is a no-op when the watchdog is not active. That makes it harmless in code paths that may run before activation, but it does not replace explicit configuration or health checks.
Can I disable the watchdog after enabling it?
The current versioned API documents assigning None to watchdog.mode as the way to disable the timer. However, the stable reference warns that some platforms cannot disable an enabled watchdog. Treat activation as potentially irreversible until the exact board and firmware documentation says otherwise.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
# Only use this if the target platform documents runtime disabling.
watchdog.mode = None
This caveat matters during development: enabling a watchdog in a test script can cause repeated resets after the script exits or fails to reach its feed loop. Configure it late enough that startup is understood, and test the disable behavior on the actual target rather than assuming all CircuitPython ports behave identically.
Also popular on Amazon
- Portable and powerful USB-C HUB: BENFEI USB Type-C HUB, with super-soft and knot-free silicone woven design cable, meets most mobile office needs. Compact, lightweight, stylish, and powerful portable USB C Hub equipped with 1 x HDMI port, 1 x 100W charging, and 3 x USB ports. 18-month warranty, 24-hour response, to ensure you feel at ease when using our product.
- Design centered on comfort and reliability: Thanks to BENFEI's end-to-end in-house cable production capability, in-house PCBA and assembly capability, using the industry's most advanced silicone woven design and process, 20cm cable in length, no knots, super-soft, the HUB is easy to use in all scenarios: laptop, tablet, stand etc. Super-soft, 25000+ life cycles, to meet your daily carrying and office needs.
- 100W Charging: Support up to 90W USB C pass-through charging via Type-C port to keep your laptop powered. 10W is reserved for other interface operations. No data and video function on the Type-C port.
- 4K HDMI Display: The HDMI port supports media display at resolutions up to 4K 30Hz, keeping every incredible moment detailed and ultra vivid. Please note that the C port of the Host device needs to support video output.
- Transfer Files in Seconds: Transfer files and from your laptop at speeds up to 10 Gbps with USB A 3.2 port. Extra 2 USB A 2.0 ports are perfectly for your keyboards and mouse.
Which boards support CircuitPython watchdog?
Support varies by microcontroller port, board implementation, and CircuitPython release. The CircuitPython 10.0.3 watchdog reference includes the Adafruit Feather M4 Express in its board coverage, and the Feather M4 Express guide documents installing CircuitPython on that board. This is version-specific evidence, not a guarantee that every board or later release exposes identical behavior.
Before deploying:
- Identify the board’s exact CircuitPython release.
- Open that release’s watchdog binding reference and board support information.
- Confirm that
microcontroller.watchdogexists and that the selected mode is implemented. - Check whether the platform’s watchdog can be disabled and what reset behavior it uses.
- Run a controlled expiry test only where an automatic reset or exception is safe.
A board can run CircuitPython successfully while still lacking a usable watchdog binding, so general firmware compatibility should not be treated as proof of watchdog support.
How can I diagnose a watchdog reset?
After a reset, CircuitPython’s microcontroller API exposes microcontroller.ResetReason.WATCHDOG as a possible reason for the previous reset. Use the microcontroller API reference to see the reset-reason definitions available to the target release and record that reason early in startup.
Persist a small boot record if the device needs post-reset diagnostics. Include the last known application state, the firmware version, and whether critical tasks had recently completed. A watchdog reset identifies the reset source, but it does not identify which line of code stopped making progress; application-level breadcrumbs are needed for that.
What are the common failure modes?
| Symptom | Likely cause | What to check |
|---|---|---|
| Immediate or repeated resets | The timeout is shorter than normal startup or a blocking operation. | Increase the interval to cover the longest legitimate gap, or activate the watchdog after initialization. |
| No reset when the loop is intentionally stopped | The watchdog was never activated, the platform lacks support, or the test code is still feeding it. | Verify the mode assignment, inspect the exact release documentation, and remove all feeds from the controlled test path. |
| Watchdog cannot be turned off | The platform implements a non-disableable watchdog once enabled. | Follow the stable reference’s platform warning and reboot into a clean program if necessary. |
| System keeps running despite a failed task | An unconditional feed reports loop activity rather than application health. | Gate feeding on task completion, communication status, and other critical conditions. |
RAISE recovery becomes unstable |
The exception handler assumes valid partial state or performs another blocking operation. | Keep recovery bounded, put outputs safe, and use RESET when a restart is more deterministic. |
What should a production watchdog design include?
A robust design treats the watchdog as one layer of fault containment, not as a substitute for validation, timeouts, or error handling. Document the selected mode, timeout rationale, critical health conditions, and expected reset-recovery sequence alongside the code.
Also popular on Amazon
- 【Read before You Buy】 Note: This adapter is USB 2.0 version and cannot transmit HDM, VGA, or other video signals. Nevertheless, they are fully capable of charging devices,duplicating files, and can be seamlessly integrated with USB-C earphones, wireless network adapters, and SD card adapters.
- 【Easy to Use and Safe】Thanks to modern manufacturing techniques, we've made these adapters sufficiently compact so that they can remain inserted in your device without noticeable protrusion or inconvenience. This means you don't have to constantly plug and unplug them, reducing the likelihood of wear and misalignment, and making them more convenient to carry around.
- 【Reliable Quality】Engineered for enhanced durability, durable aluminum alloy shell material,get excellent wear resistance and heat dissipation,the male USB C and female USB connectors & the male USB and female USB C connectors are designed to be plugged and unplugged up to 20000 times. Provides data transfer, device charging, memory space expansion, and additional computer peripherals.
- 【Think more for you】Do you need to connect a USB-C-enabled device to an odd device that only has USB-A ports? Then these USB-A male to USB-C female adapters are made for you.Simply insert the adapter into the USB-A port on the device, and you can instantly connect your USB-C device to the device that originally didn't have the correct connection port.
- 【Trusted xiwxi Quality and Service】As a responsible brand seller, you will receive xiwxi's 12-month Quality assurance and lifetime friendly customer service, you're not just buying a product,you're investing in peace of mind with all-round quality and exceptional customer service.
- Define progress: list the tasks that must complete before a feed is allowed.
- Bound blocking work: ensure peripheral and communication calls cannot exceed the watchdog interval without an intentional health update.
- Choose the action: use
RESETfor deterministic restart, orRAISEfor a deliberately designed exception path. - Protect outputs: make startup and timeout recovery place actuators and power controls in a safe state.
- Record evidence: preserve reset reason and enough state to identify the failed subsystem after reboot.
- Recheck portability: verify support, timeout limits, and disable rules whenever the board or CircuitPython version changes.
The watchdog’s value comes from the combination of a correctly chosen interval and honest feeding discipline. A timer that is never fed cannot distinguish a rare legitimate delay from a permanent lockup; a timer that is fed regardless of health cannot provide meaningful supervision.
Quick reference for the API
| API element | Purpose |
|---|---|
microcontroller.watchdog |
The single watchdog timer instance. |
watchdog.timeout |
Maximum interval between feeds; assigning it also feeds the timer. |
watchdog.mode |
Activates WatchDogMode.RESET or WatchDogMode.RAISE; current references document None for disabling, subject to platform limits. |
watchdog.feed() |
Refreshes an active timer; documented as a no-op when inactive. |
watchdog.WatchDogTimeout |
Exception raised when an active watchdog in RAISE mode expires. |
For exact signatures and port-specific notes, consult the stable API reference and the matching versioned documentation.
Recommended Free Tools
Frequently Asked Questions
Can a watchdog replace normal exception handling in CircuitPython?
No. Exception handling can recover from a known operation-level error, while a watchdog provides a deadline-based response when progress stops. Use both when appropriate: handle expected failures locally and reserve watchdog expiry for states that cannot be repaired safely.
What if startup takes longer than the watchdog timeout?
A watchdog enabled before initialization finishes can reset the board repeatedly if startup performs lengthy discovery or peripheral setup. Either activate it after essential initialization or choose a timeout that covers the full startup path, then tighten the interval once the schedule is understood.
How should I handle a blocking sensor or network operation?
Treat that operation’s worst-case duration as part of timeout sizing, including retries and recovery delays. If the operation can exceed the interval legitimately, redesign it into bounded steps or use a longer timeout rather than feeding blindly during an unknown state.
Does a watchdog reset identify the exact bug?
No. The reset reason can indicate that the watchdog caused the reboot, but it does not identify the stalled task or instruction. Store concise breadcrumbs—such as the last completed task and operation—in nonvolatile or retained diagnostics so the next boot has useful context.

