Open source · Zigbee 3.0 · No cloud

Know it's closed.

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.

ESP32-C6IAS Zone contactZigbee routerZigbee2MQTTHome AssistantMIT
LIVE DEMO · garage door Closed
C6
// zigbee2mqtt/garage_door_sensor
{ "contact": true, "linkquality": 236 }
Tap the door to open or close it
Why build it

A contact sensor that pulls its weight.

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.

A Zigbee router, too

Mains powered, so it routes traffic for every Zigbee device nearby. Your garage, shed or gate finally gets solid coverage.

Fail-safe by design

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".

Z2M & HA native

A standard IAS Zone contact. One tiny converter and it shows up as a door/window sensor in Home Assistant.

No WiFi, no cloud

No passwords, IPs or app accounts. It keeps working when your WiFi doesn't, and nothing leaves your house.

Put it anywhere

If a magnet can move, you can watch it.

The reed goes on the fixed part, the magnet on the moving part. The same firmware works for all of these.

Gate

Sliding or swing. Long cable runs are fine.

Doors

A recessed reed is invisible once fitted.

Windows

Skylights, tilt-and-turn, roof windows.

Shed & cellar

Out of WiFi range, inside the mesh.

Mailbox

"You've got mail" on every flap.

Freezer & fridge

"Left open for 5 minutes" alerts.

How it works

From a magnet to an automation.

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.

Reed + magnetNO contact to GND
XIAO ESP32-C6200 ms debounce · router
Zigbee meshIAS Zone contact
Zigbee2MQTTcontact: true
Home Assistantbinary_sensor · door
Flash

No toolchain. Just a USB cable.

Plug 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.

Install the firmware

Works in Chrome and Edge on desktop (Web Serial). On first install, choose Erase device so the Zigbee stack starts clean.

Your browser doesn't support Web Serial. Open this page in Chrome or Edge on a computer. Web Serial needs a secure (https) page.
firmware · 6dc2aca · XIAO ESP32-C6 · Zigbee router
  1. Connect the boardUSB-C to your computer, with nothing else powering it.
  2. Flash itClick Connect & install, pick the serial port, and accept the erase on the first install.
  3. Add the converterDrop reed_contact.mjs into Zigbee2MQTT's external_converters/ folder and restart it.
  4. PairClick Permit join. The LED blinks while it searches and goes dark once it joins. Hold BOOT for 3 s to reset.
Zigbee2MQTT

Twelve lines and you're paired.

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.

external_converters/reed_contact.mjs
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']})],
};
Worked example

The garage door that tells you it didn't close.

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 & verifyAsks the motor to close, then checks the door really shut within 90 s.
  • Left-open alertNotifies you after N minutes. You choose N from the dashboard.
  • Night checkA 22:00 reminder if the door isn't shut.
  • Sensor offlineKnow when the sensor itself stops reporting.
Home Assistantnow
Garage door

Close was requested but the door is still not fully closed after 90 s.

Home Assistant22:00
Garage door

It's 22:00 and the garage door is not fully closed.

Bill of materials

About €15 of parts.

Plus the 12 V supply you probably already have near a motor or an access-control kit.

PartWhyApprox.
Seeed XIAO ESP32-C6Zigbee radio + MCU, U.FL antenna connector€6
2.4 GHz U.FL antennaRange from inside a box€2
Reed switch (NO/NC) + magnetThe sensor itself€1–3
LM2596 buck converter12–24 V → 5 V€1–2
IP65/67 enclosure + glandsGarage, gate or garden ready€5
10 kΩ + 100 nFClean signal on long cablescents
FAQ

Good questions.

Why Zigbee and not WiFi / ESPHome?

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.

Why the Arduino framework instead of ESP-IDF?

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.

Can it run on a battery?

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.

How do I know it's working?
  • The LED blinks while searching for a network and turns off once joined.
  • Zigbee2MQTT shows it as a Router with contact flipping as you move the magnet.
  • The state is re-sent every 5 minutes, and Z2M availability flags it if it disappears.
Is it tested?

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.

Documentation

Everything, step by step.

Wiring diagrams, a bench-first build, flashing, pairing and the Home Assistant package.

Stop wondering if you closed it.

Fifteen euros, an afternoon, and one less thing to worry about.