A LAN-connected watchdog using an ESP32 that safely shuts down your NAS or server when power is lost — like a literal canary in a server mine.
My Zimacube Pro server (MU/TH/UR) runs on a basic UPS without NUT or similar connectivity. I wanted a reliable, local-only way to detect when the power goes out — and shut things down cleanly before ZFS could cry.
Enter: Dead Canary
An ESP32 sits on the same power strip as the NAS (but not on the UPS), and serves a local /
endpoint returning "CHIRP"
. When that chirp goes silent, the NAS knows it’s time to go dark.
- ESP32 development board
- Arduino IDE
- A Linux server or NAS
- Local Wi-Fi
- (Optional) Hipster film cannister for housing
- Connects to Wi-Fi
- Hosts a webserver on port 80
- Responds to
http://CANARY_IP/
with"CHIRP"
- Cron job pings the canary every minute
- If no chirp in 5 minutes, triggers:
shutdown -h now
- Update
ssid
andpassword
with your Wi-Fi credentials - Upload the sketch using Arduino IDE
- Use Serial Monitor to see the assigned IP
Place the script:
sudo nano /usr/local/bin/canary-watchdog.sh
Make it executable:
sudo chmod +x /usr/local/bin/canary-watchdog.sh
Add it to root’s crontab to run every minute:
sudo crontab -e
Then add this line:
* * * * * /usr/local/bin/canary-watchdog.sh >> /var/log/canary-watchdog.log 2>&1
To simulate power loss:
- Unplug the ESP32 or disconnect its Wi-Fi
- After 5 minutes of silence, the NAS will shut down
- (Optional) Replace
shutdown -h now
with a log echo to test safely
- I used Uptime Kuma to monitor the Canary IP.
- If the MU/TH/UR is still up but Kuma alerts me, I know the ESP has been unplugged (likely by Arnold the cat).
- ESP32 must not be powered by the UPS
- No cloud dependencies
- Local, autonomous, and extremely reliable