I was just about to build something like this for a device I have, what serendipity!
Home automation gadgets are great, especially when they can be monitored remotely and help keep the house running while you’re away. But, they’re not so great paired with an unreliable router. At home, one could power cycle the router, but when you’re out, it makes for quite the inconvenience. Automatic power cycling is always an option, but if done poorly, that will only make things work. Nick Sayer's Reboot-o-matic, currently available on Tindie, is a solution for safer automatic power-cycling, serving as a DC power interrupting watchdog.
The board works by passing low voltage DC power from a source to a load and has an open-drain input that will cause the power to be dropped for ten-second then restored. As a safety measure, the board also features a microcontroller that only permits the power to be dropped once per hour, preventing malfunctions in the controlling circuit. A Raspberry Pi can run scripts to detect whether the network is operational and power-cycle the router if not.
The basics of the design are a P MOSFET in the positive DC rail with a pull-down on the gate. A second P MOSFET is used to pull the first MOSFET’s gate up to turn the power off. This second gate is pulled up rather than down, so that it defaults to off, and is connected to a third MOSFET, an N channel whose gate is pulled down and connected to a microcontroller pin. This arrangement allows a low-powered microcontroller to turn the output power off briefly, but with everything defaulting to an “on” state instead of requiring an asserted output to turn the power on.
The controller used as the fail-safe also has software de-bouncing in place, forcing the power to stay low for a full second before the power is cycled, cycle for ten seconds, then stay high for at least an hour before any low transition. There are several other methods one could use to power-cycle a router — for example, setting a timer to cycle the device on a daily basis — but these do not have the added benefit of an intelligent gatekeeper to prevent excess power-cycling and a design that attempts to ensure any fault would only cause the power state failing-on. Remote monitoring and action is convenience at the least, and can save both stress and money in situations where leaving a device unattended are more troublesome.