Build a Raspberry Pi-Controlled Smart PDU for Remote Power-Cycling Shop Network Gear
Raspberry Pi 4 Model B (2GB or better)
4-channel 5V relay module with opto-isolation
IEC C13/C14 outlet strip or junction-box-mountable outlets (4x)
18 AWG stranded hookup wire, rated for mains
Electrical junction box (plastic, non-conductive)
IEC C14 fused power inlet module
Lever-nut wire connectors for mains splicing
32GB microSD card
5V/3A USB-C power supply for the Pi
Heat shrink tubing assortment
Digital multimeter
Prices and availability as of Nov 30, 12:53 AM ET and subject to change. The price shown on Amazon at the time of purchase applies.
A camera that locks up, an access point that needs a weekly reboot, a Klipper host that occasionally wedges — every maker shop network accumulates at least one device that's more reliable after a power cycle than any amount of software troubleshooting. A commercial networked PDU (power distribution unit) solves this cleanly but starts well into three figures for a real managed unit. This build gets the same core capability — remotely power-cycling individual outlets, not just one shared switch — from a Raspberry Pi and a relay board for a fraction of the cost, with a simple web dashboard for status and control.
How It Works
A relay board switches mains power to each outlet independently, with the Pi's GPIO driving the relay coils through opto-isolation. A small Flask or Node web app running on the Pi exposes a dashboard showing each outlet's state and a button to toggle it, plus a scheduled or threshold-triggered auto-reboot option (for example, pinging a device and power-cycling its outlet automatically after several failed pings in a row). SNMP support is optional but included here as a secondary control path, letting existing network monitoring tools (Zabbix, LibreNMS, and similar — see this site's Zabbix-on-Pi guide for a monitoring pairing) query and control outlets the same way they would a commercial PDU.
Wiring the Relay Side
This is mains-voltage wiring, not a 5V breadboard project — treat it with the same care as any other mains electrical work. Each outlet's hot (live) conductor routes through one relay's normally-open contacts; neutral and ground run straight through to every outlet without passing through any relay — switching only the hot leg is both standard practice and the safer configuration. Keep the Pi's 5V logic side and the relay board's mains-switching side physically separated inside the enclosure as much as the layout allows, and never route low-voltage GPIO wiring and mains wiring through the same unshielded bundle.
| Step | Detail |
|---|---|
| Mount the fused IEC inlet | This is the unit's own power input; the fuse protects the whole build, including the Pi, from a downstream fault |
| Wire inlet hot through to each relay's common terminal | Each relay then switches that hot leg to its own outlet independently |
| Bus neutral and ground to all outlets directly | Never switch neutral or ground; only the hot conductor gets interrupted |
| Wire relay control pins to Pi GPIO through the board's opto-isolated inputs | The opto-isolation is what keeps a relay-side fault from ever reaching the Pi's GPIO directly |
| Secure all mains connections inside the enclosure | Lever-nuts or proper wire nuts, fully enclosed — no exposed mains conductors anywhere accessible |
Software
A minimal Flask app with RPi.GPIO (or gpiozero) handling the relay toggling, SQLite for logging outlet state changes and reboot events, and a simple ping-based watchdog loop are enough for the core feature set: view status, toggle outlets manually, and configure auto-reboot rules per outlet (ping target, failure threshold, cooldown period to avoid reboot-looping a device that's failing for a non-power reason). Expose the dashboard only on your local network or behind your existing VPN/reverse proxy setup — a web-exposed relay controller for mains power is not something to put directly on the open internet.
Safety
This project puts a hobbyist board directly in line with mains voltage, and that carries real risk if built carelessly: use a genuinely rated junction box, keep all mains connections enclosed and inaccessible to a stray finger or a curious pet, double-check polarity and continuity with a multimeter before the first live power-on, and add the fused inlet rather than skipping it to save a part — it's the one component standing between a wiring mistake and a bigger problem downstream. If you're not confident reading and following basic mains wiring practice, this is a good project to build alongside someone who is, or to have the finished wiring checked before it goes live.
Once it's running, the payoff is immediate: a hung camera or wedged access point stops being a trip to the breaker panel or a crawl behind a bench, and becomes a dashboard click or an automatic ping-triggered recovery — the same capability a commercial networked PDU sells for considerably more than this build costs in parts.