Watchdog - Hardware


Watchdog.refresh, refresh

You must call Watchdog.refresh() more often than the timeout interval. You can call it on every loop().

If you have logic that blocks loop, you must also call it while blocking. Beware of using long delay() if you are using the hardware watchdog.

Beware of setting a short watchdog timeout if you call Watchdog.refresh() only from loop() if you have lengthy operations that occur during setup(). Since the watchdog is already running, it could fire before you actually are able to refresh the watchdog the first time.

// Call on every loop, or when blocking



  .capabilities(WatchdogCap::NOTIFY | WatchdogCap::DEBUG_RUNNING)

On nRF52840 (Boron, B Series SoM, Argon, Tracker SoM, E404X) devices, you can optionally stop the watchdog from running during sleep by setting the capabilities.

The default is WatchdogCap::NOTIFY | WatchdogCap::SLEEP_RUNNING | WatchdogCap::DEBUG_RUNNING so not setting WatchdogCap::SLEEP_RUNNING will pause the watchdog while in sleep mode.

Since pausing the watchdog is not possible on the RTL872x platform (P2 and Photon 2), we recommend that you set your watchdog and sleep timeout parameters to avoid having to stop the watchdog on sleep. This also provides extra safety in case the device does not wake up at the expected time, as the watchdog will reset the system in this case. This could happen if you have a bug in your logic for how long to sleep, for example.