Interfacing Wiegand Access Control Readers with an ESP32: Retrofitting Commercial Door Readers
Most commercial door access readers — the card and fob readers mounted next to office doors, gates, and garage entries — don't speak NFC or any protocol you'd wire up directly to an ESP32 project. They speak Wiegand, a decades-old, dead-simple two-wire signaling protocol that's still the de facto standard for proximity card and keypad readers because it's cheap, reliable, and nobody in the access-control industry has had a reason to replace it. If you've got an existing Wiegand reader on a gate, a shop door, or salvaged from a surplus sale, an ESP32 can decode its output directly and give you a standalone logging, automation, or Home Assistant-integrated access system without the original (and often expensive or proprietary) access control panel.
How Wiegand Actually Works
Wiegand uses two data lines, conventionally called DATA0 and DATA1, each idling high and pulsing low briefly to signal a 0 or a 1 respectively — never both at once. A full card read sends a burst of these pulses (26-bit format is the most common for simple proximity cards, though 34-, 37-, and other bit-length formats exist) representing a facility code and card number, followed by a parity bit on each end for basic error checking.
SignalBehaviorESP32 wiring note DATA0Pulses low (~50µs) to signal a 0 bitWire through a voltage divider or level shifter — most readers output 5V Wiegand, not 3.3V DATA1Pulses low (~50µs) to signal a 1 bitSame voltage consideration as DATA0 12V (or 5V) powerPowers the reader itselfSupply from a bench supply or the reader's original power source, not from the ESP32 LED/beeper control (optional)Some readers accept a control line to trigger a success beep or LEDOptional; can drive from a spare GPIO through appropriate level shiftingCritical: Voltage Level Shifting
This is the step that destroys the most ESP32 boards in Wiegand projects. Most commercial Wiegand readers run their data lines at 5V logic levels, and the ESP32's GPIO pins are not 5V tolerant — feeding a 5V Wiegand pulse directly into an ESP32 input pin risks damaging the pin or the whole chip over repeated exposure. Always run DATA0 and DATA1 through a proper level shifter (a simple resistor voltage divider works for a slow, digital-only signal like this, or use a dedicated logic level shifter chip for a cleaner result) before they reach any ESP32 GPIO pin. Confirm your specific reader's actual output voltage with a multimeter before wiring anything — some newer or lower-power readers do run 3.3V-compatible outputs, but don't assume it without checking.
Decoding on the ESP32
Attach interrupt handlers to both the DATA0 and DATA1 GPIO pins, each one recording a 0 or 1 bit and a timestamp when it fires. A short inter-bit timeout (a few milliseconds of no new pulses) signals the end of a transmission, at which point your code assembles the collected bits into the card's facility code and ID number according to whatever bit-length format your specific reader uses — 26-bit is the most common starting assumption, but confirm against your reader's actual output by reading a known card and comparing the decoded number to what's printed or encoded on it, since not every reader you'll encounter in the wild follows the format you expect.
FormatBit layoutWhere you'll see it 26-bit standard1 parity + 8-bit facility code + 16-bit card number + 1 parityThe most common legacy format on basic proximity readers 34-bit, 37-bit, and other extended formatsVendor-specific bit allocations for facility code and card numberHigher-security or higher-capacity systems; decode carefully and verify against known cardsWhat to Build With the Decoded Data
- Standalone logging: timestamp every read to a local file or send it to Home Assistant or an MQTT broker, giving you an access log without needing the original panel's (often subscription-gated or proprietary) software.
- Relay control: compare decoded card numbers against a local allow-list and drive a relay to an electric strike or gate opener directly from the ESP32, effectively replacing a basic single-door access panel for simple cases.
- Bridging to Home Assistant: publish each read event over MQTT so a card read can trigger automations — unlocking a smart lock, turning on shop lights, or logging who's clocked into a shared space, alongside other sensors this site has covered for home and shop automation.
Where This Fits Legally and Practically
This project is specifically about interfacing with hardware you own or have explicit authorization to work on — a reader on your own gate, shop door, or a salvaged unit on your bench — not about intercepting or attacking someone else's access control system. If you're retrofitting a reader that's still protecting a real door, test your wiring and decoding thoroughly on a bench setup before it's anywhere near the live door, and keep a manual override or physical key available in case your relay logic has a bug; a locked door that won't open because of a software fault is a bad surprise to discover from the wrong side of it.
Safety
Confirm actual supply voltage and current draw before wiring any reader, and don't share a power rail between the reader and your ESP32's own supply without appropriate regulation — a reader's 12V supply line browning out or spiking can take microcontroller electronics with it if they're not isolated. If you're driving an electric strike or maglock relay, use a flyback diode across the inductive load and keep the relay's switching circuit isolated from your logic-level wiring, the same precaution that applies to any relay-driven inductive load.
Wiegand is primitive by modern standards, but that simplicity is exactly why it's stuck around for decades and why so much existing access hardware still speaks it. Once an ESP32 can decode it reliably, you've got a bridge from a protocol that predates the smart home entirely into whatever modern automation stack you're already running.