Most DIY sensor setups fail silently — a node drops off the network and you don't notice until your grow tent cooks your seedlings at 3am.
The architecture
After three iterations, here's what I settled on:
- Watchdog timers on each node force a reboot if the main loop stalls
- MQTT Last Will & Testament messages announce when a node goes offline
- A dead-man's-switch that pages me if a node goes dark for more than five minutes
Why MQTT
MQTT's publish/subscribe model means nodes don't need to know about each other — they just publish to topics. The broker handles routing.
client.will_set("sensors/tent1/status", "offline", retain=True)
client.connect("broker.local", 1883)
client.publish("sensors/tent1/status", "online", retain=True)
The retain=True flag is the trick: any subscriber that connects later immediately gets the last known status.
Results
Twelve nodes across the shop, running for three months. Two hardware failures, both caught within minutes instead of hours. The seedlings survived.