A mains-powered Zigbee contact sensor that also strengthens your mesh. A Seeed XIAO ESP32-C6 and a €1 reed switch, ready for Zigbee2MQTT and Home Assistant. Flash it from your browser in under a minute.
Battery sensors report and go back to sleep. This one stays awake, relays your other Zigbee devices, and tells you when something's wrong instead of failing silently.
Mains powered, so it routes traffic for every Zigbee device nearby. Your garage, shed or gate finally gets solid coverage.
Only a magnet in place reads closed. A cut wire, a loose connector or a dead sensor all show up as open, never as a false "all good".
A standard IAS Zone contact. One tiny converter and it shows up as a door/window sensor in Home Assistant.
No passwords, IPs or app accounts. It keeps working when your WiFi doesn't, and nothing leaves your house.
The reed goes on the fixed part, the magnet on the moving part. The same firmware works for all of these.
Detects "not fully closed", even a door that stopped 5 cm early. Pairs with a Zigbee relay for a real open/close cover.
Sliding or swing. Long cable runs are fine.
A recessed reed is invisible once fitted.
Skylights, tilt-and-turn, roof windows.
Out of WiFi range, inside the mesh.
"You've got mail" on every flap.
"Left open for 5 minutes" alerts.
The reed closes when the magnet is near. The ESP32-C6 debounces it, reports it as a Zigbee IAS Zone, and re-sends it every 5 minutes so Home Assistant never holds a stale state.
contact: truePlug the XIAO ESP32-C6 into your computer and flash the latest firmware straight from this page. Prefer to build it yourself? It's a single pio run.
Works in Chrome and Edge on desktop (Web Serial). On first install, choose Erase device so the Zigbee stack starts clean.
reed_contact.mjs into Zigbee2MQTT's external_converters/ folder and restart it.The converter uses Zigbee2MQTT's own building blocks, and CI checks it against the same library Z2M runs. The model string is verified against the firmware source on every commit.
import * as m from 'zigbee-herdsman-converters/lib/modernExtend'; export default { zigbeeModel: ['C6ReedContact'], model: 'C6ReedContact', vendor: 'DIY', description: 'Mains-powered reed contact sensor and Zigbee router (XIAO ESP32-C6)', // contact: true = magnet in front of the reed (closed), false = open extend: [m.iasZoneAlarm({zoneType: 'contact', zoneAttributes: ['alarm_1']})], };
The full guide pairs the sensor with a ZB-SW01 Zigbee relay on the motor's push-button input. A ready-made Home Assistant package turns the two into a proper cover.
Close was requested but the door is still not fully closed after 90 s.
It's 22:00 and the garage door is not fully closed.
Plus the 12 V supply you probably already have near a motor or an access-control kit.
| Part | Why | Approx. |
|---|---|---|
| Seeed XIAO ESP32-C6 | Zigbee radio + MCU, U.FL antenna connector | €6 |
| 2.4 GHz U.FL antenna | Range from inside a box | €2 |
| Reed switch (NO/NC) + magnet | The sensor itself | €1–3 |
| LM2596 buck converter | 12–24 V → 5 V | €1–2 |
| IP65/67 enclosure + glands | Garage, gate or garden ready | €5 |
| 10 kΩ + 100 nF | Clean signal on long cables | cents |
For a single contact, Zigbee wins: it joins the mesh your other sensors already use, needs no credentials, survives WiFi outages and, being mains powered, adds a router where you usually need one. The trade-off is firmware updates over USB instead of over WiFi, and a small Z2M converter. For a device you install once, that's a good deal.
Both run the same Espressif Zigbee stack. Arduino gets this sensor done in ~200 readable lines, which is easier for everyone to fork. ESP-IDF pays off for custom clusters, battery tuning down to the µA, or a commercial product.
It can, but then it should become a sleepy end device and stop routing. Commercial battery sensors are cheaper for that. This project is for places where power is close by and a router is welcome.
contact flipping as you move the magnet.Every commit runs host unit tests for the debounce and heartbeat logic (including millis() rollover), builds with both PlatformIO and Arduino CLI, tests the converter against zigbee-herdsman-converters, and validates the Home Assistant package with Home Assistant's own config checker.
Wiring diagrams, a bench-first build, flashing, pairing and the Home Assistant package.
Fifteen euros, an afternoon, and one less thing to worry about.