PiDog2 is a "hat" for all Raspberry Pi computers with 40-pin GPIO connectors (that only excludes the computer module and the original Model A) that provides much needed hardware watchdog and power management capabilities that the Raspberry Pi itself lacks. It does this with minimal fuss and almost no effort on your part
The Raspberry Pi computers are great. They're cheap, fun to use, run a solid operating system, and can be programmed in whatever languages you like. Furthermore, they have ample IO capability, through USB ports and through that big, beautiful GPIO connector. However, there are a couple of problems with the Raspberry Pi's that make them difficult to deploy in places where a human can't easily visit them and "fix" the from time to time
I designed the PiDog after I had to deploy Raspberry PI-based cameras and sensors around a wide campus, powered by batteries and solar panels. They worked pretty well in most cases, but after a long period of low sun, or certain types of network outages, or OS updates gone bad, the Pi's would "die" and disappear off our network for good, requiring that I visit them and manually reset them. This was tedious and crashes for low voltage / low power sometimes resulted in damage to the uSD flash cards in the Pi's. My solution to this was a small amount of hardware to reset the Pi's and turn them off when power is low or unavailable, but being able to turn them back on when the power is back!
The PiDog2 solves all those problems. First, the PiDog2 can cut the power to a Raspberry Pi after specified period of time. This lets it serve as an external watchdog timer, or let's you use it to perform a complete powerdown after a clean shutdown. Second, it can power the Raspberry Pi back up after a different specified time. Finally, it provides the Pi with a measurement of the 5V and 3.3V supplies, as well as up to two other voltages of your choice. This lets software running on the Pi make intelligent choices about when it should gracefully shut down in order to save battery and avoid flash corruption. Then, using the PiDog2, it can wake again periodically, check the battery voltages and decide whether to power back down or operate normally.
PiDog2 is powered by an Attiny84 microcontroller that is connected to the Pi via the GPIO header and the SPI interface. It uses one of the standard Raspberry Pi SPI chip-selects, but you can still use other SPI devices that work off other chip selects. The PiDog2 inserts a MOSFET switch between the incoming USB 5V and the Raspberry Pi. This way, it can turn the Pi on and off. Connection is very simple: simply remove the USB connector from your Raspberry Pi, attach the PiDog2 to the Raspberry Pi's GPIO header, and put the USB connector onto the PiDog2. That's all the hardware setup you need!
The PiDog2 is programmed to look like a handful of 32 bit registers that contain various countdown timers and control bits, and there is a basic Python library provided that makers interacting with those registers a snap.
The projects can be found on GitHub: https://github.com/djacobow/pidog2. In that repo, you'll find:
Some boards were assembled with a resistor present that does not belong.
On some boards, these resistors were populated when they should not have been. This can cause the PiDog to cut the power to the RPi during in-situ programming, resulting in a sad RPi and an unprogrammed PiDog. Not good. If you board has this resistor, please remove it from the board and you should be good to go. If you have any questions, do not hesitate to contact me at dave -at- southberkeleyelectronics.com.