# PiWatcher TB: the other Raspberry Pi watchdog

The PiWatcher TB is a small board that will automatically shut down and/or reboot your Raspberry Pi when needed.

- **Seller:** [omzlo](https://lectronz.com/stores/omzlo), Thrakomakedones, Attica, Greece
- **Price:** €7.90 (EUR, before shipping and taxes)
- **Availability:** Sold out
- **Categories:** Raspberry Pi, Power management
- **HS code:** 85423190
- **Product page:** https://lectronz.com/products/piwatcher-tb-the-other-raspberry-pi-watchdog

## Options

**Pre-soldered headers and terminal block**

- Unsoldered
- Soldered [Add €2.00]

## Links

- [Documentation](https://www.omzlo.com/articles/the-piwatcher)
- [Code](https://github.com/omzlo/piwatcher)
- [Design Files](https://www.omzlo.com/uploads/piwatcher-hardware.zip)

## Images

![PiWatcher TB: the other Raspberry Pi watchdog](https://lectronz-images.b-cdn.net/lectronz/active_storage/representations/proxy/eyJfcmFpbHMiOnsiZGF0YSI6MTQ1LCJwdXIiOiJibG9iX2lkIn19--5e37c843fa01c22e775df9f4e04d736009b303a8/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls5NjAsNjQwXSwic2F2ZXIiOnsic3RyaXAiOnRydWV9fSwicHVyIjoidmFyaWF0aW9uIn19--970c165836a83091725a1a0fd4f37ce9408da1bf/2020-11-11T16-34-54.251Z-piwatcher3-TB-angled.jpg)
![PiWatcher TB: the other Raspberry Pi watchdog](https://lectronz-images.b-cdn.net/lectronz/active_storage/representations/proxy/eyJfcmFpbHMiOnsiZGF0YSI6MTQ2LCJwdXIiOiJibG9iX2lkIn19--e4a89848fd8343d0b7508099088f54ce9ff916c7/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls5NjAsNjQwXSwic2F2ZXIiOnsic3RyaXAiOnRydWV9fSwicHVyIjoidmFyaWF0aW9uIn19--970c165836a83091725a1a0fd4f37ce9408da1bf/2020-11-11T16-34-54.251Z-piwatcher3-TB-rpi-2.jpg)
![PiWatcher TB: the other Raspberry Pi watchdog](https://lectronz-images.b-cdn.net/lectronz/active_storage/representations/proxy/eyJfcmFpbHMiOnsiZGF0YSI6MTQ3LCJwdXIiOiJibG9iX2lkIn19--f26bad462c09f5838833dafb6d6b30d5283e0ea0/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJwbmciLCJyZXNpemVfdG9fbGltaXQiOls5NjAsNjQwXSwic2F2ZXIiOnsic3RyaXAiOnRydWV9fSwicHVyIjoidmFyaWF0aW9uIn19--605f1da017bcbb03ce31845cd0e81d97e3b3c574/2020-11-11T16-34-54.251Z-PiWatcher-TB-pinout.png)

## Description

## What is it?

The **PiWatcher TB** is a very small board that helps you fully shut down or reboot a Raspberry Pi in case of an incident or simply for power saving purposes. You can even program your **PiWatcher** to shut down and automatically reboot your Pi a few minutes or hours later. 

In essence, the **PiWatcher TB** is a programmable watchdog circuit for the Raspberry Pi.

The **PiWatcher TB** is a variation of the classic PiWatcher [also available on Lectronz](https://lectronz.com/products/piwatcher-the-best-watchdog-for-your-raspberry-pi), where the USB connector has been replaced with a high-quality 2.54mm pitch screw terminal block. In addition, the **PiWatcher TB** can be connected to an external switch, a possibility not currently offered on the simple **PiWatcher**. While most users will likely prefer the [simple PiWatcher with a USB connector](https://lectronz.com/products/piwatcher-the-best-watchdog-for-your-raspberry-pi), this alternative was created at the request of some customers in more industrial applications.

The board must be fitted on the first 6 pins of the Raspberry GPIO header and wired to a 5V power supply suitable for the Raspberry Pi in use. Based on instructions it receives through I2C, the **PiWatcher** can then be instructed to:

- power off (or reboot) the Raspberry Pi if it becomes irresponsive for more than 'X' seconds. 
- power off and reboot the Raspberry Pi after several seconds, minutes or hours for recurring tasks for example.

The board also features a miniature tact switch to allow manual control. The board can also connect an external switch through the terminal block.

It has been tested to work with:

- the humble Pi Zero and Pi Zero W,
- the Raspberry Pi 2 B
- the Raspberry Pi 3 B
- the Raspberry Pi model B, with some [extra I2C configuration](https://www.omzlo.com/articles/the-piwatcher#setup-on-older-raspberry-pi-models).
- the Raspberry Pi 4.

Warning: The PiWatcher may not operate correctly if the Raspberry Pi is connected to some power-hungry peripherals such as an SSD hard drive, or with peripherals that have a separate power supply.

The PiWatcher does not seem to currently work on the Raspberry Pi 5, due to bugs in the I2C hardware drivers on the Pi. This will hopefully get fixed soon.

## A solution for Raspberry Pi power management

The **PiWatcher TB** is designed to solve 2 problems with power management on the Raspberry Pi.

First, if you shut down a Raspberry Pi through software, for example by issuing a `shutdown` or `halt` command, 
your Raspberry Pi will cease to operate, but it does not completely shut down. Instead, it enters a quiescent state
where it continues to eat 30 to 50mA, sometimes more depending on connected peripherals. This is wasteful and can
become an issue in battery powered systems.

The **PiWatcher TB** can be programmed to fully cut power to the Raspberry Pi after a certain delay of inactivity. For 
example, you can tell the **PiWatcher** to cut power 10 seconds after a `shutdown` command has been issued, giving 
the Raspberry Pi enough time to cleanly power off.

The second issue with power management has to do with the ability to recover from situations where a Raspberry Pi
becomes stuck in an unrecoverable state. While in theory, this should not happen, a long-running Raspberry Pi can get 'stuck' or 'freeze', due to software or hardware failures or even environmental factors such as heat. In some cases
the least unsatisfactory approach to deal with this issue is to simply switch off and on again the Raspberry Pi,
enabling the application to continue and/or send out an alert.  

The **PiWatcher TB** can be programmed to automatically power cycle a Raspberry Pi if it does not receive a 'heartbeat'
from the device after a user selectable delay. This can allow some critical applications to continue to operate
without human intervention.

Furthermore, the **PiWatcher TB** can be programmed to wait for a certain delay, ranging from a few seconds to about 36 hours, before rebooting your Raspberry Pi after a shutdown.
The **PiWatcher** has an LED. When the Raspberry Pi is powered on, the LED is continuously on.
When the Raspberry Pi is powered off, the LED blinks slowly.

The **PiWatcher** also has a useful micro tact-switch:

* When your Raspberry Pi is running:

 * a long press (5 seconds) on the button will fully power off the Raspberry Pi.
 * a short press (half a second) on the button will send a software signal that can be exploited for user-defined purposes.

* When your Raspberry Pi is shut down, a short press on the button will restart the Raspberry Pi.

The user can connect an external switch as an alternative to the micro tact-switch provided on the board: this is useful when putting the Raspberry-Pi in an enclosure, where the on-board switch becomes hard to access. The external switch must be connected to the `BUTTON_ALT` and `GND` pins shown in the picture below. Closing the switch shorts these two pins together.

![PiWatcher connections](https://www.omzlo.com/uploads/std_PiWatcher-TB-pinout.png "enter image title here")

## How to use the PiWatcher

The **PiWatcher TB** must be provided with a 5V power source connected with two wires plugged in the terminal block following the indications in the picture above.  

The **PiWatcher TB** is fully controlled with a command line utility called `piwatcher`. It is very simple to use.

For more details, including software download instructions, see our documentation [here](https://www.omzlo.com/articles/the-piwatcher). 

## What's included 

The board comes with an _unsoldered_ 2x3 female pin header and and _unsoldered_ 3-pin 2.54mm terminal block. You will need to provide your own Raspberry Pi.

The board does not come with standoffs. If you need some, look for M2.5, 11mm.

This product is open-source/open-hardware.

## Shipping policy

We ship twice a week, typically on Tuesdays and Fridays. 
