Introduction

Keycards and RFID fobs have replaced physical keys in offices, makerspaces, apartment buildings, and home labs. But commercial access control systems from vendors like HID, Paxton, and Salto come with per-door licensing fees, proprietary management software, and vendor lock-in that can cost thousands of dollars per door.

The open-source ecosystem offers capable alternatives built on inexpensive ESP32/ESP8266 microcontrollers. ESP-RFID provides a complete standalone web-based access control system with a built-in user database, while OpenMQTTGateway bridges RFID readers into broader smart home and automation platforms through MQTT. For those who need maximum flexibility, raw Wiegand-to-serial bridges let you integrate commercial RFID readers with any backend.

Comparison Table

FeatureESP-RFIDOpenMQTTGatewayWiegand-Interface (ESP-RFID-Tool)
ArchitectureStandalone web server + WebSocketMQTT bridge to Home Assistant/Node-REDRaw Wiegand decoder
RFID ProtocolsRC522 (MIFARE), PN532 (NFC), Wiegand, RDM6300 (125kHz)PN532, RC522, RDM6300, PN5180Wiegand (26-58 bit)
User ManagementBuilt-in web UI with user database, access groupsDelegated to home automation platformNone (raw data)
Door ControlGPIO relay output, timed unlockVia MQTT-triggered relayVia serial/network output
Web InterfaceFull management dashboard with live event logNone (MQTT only)None
APIWebSocket, JSON, RESTMQTT (JSON payloads)Serial, TCP socket
GitHub Stars1,468+3,600+573+
HardwareESP8266/ESP32 + RFID reader + relayESP32/ESP8266 + multiple radiosESP32 + Wiegand reader
Best ForStandalone door accessSmart home-integrated accessCustom backend integration

ESP-RFID

ESP-RFID is a complete access control firmware for ESP8266/ESP32 microcontrollers. Flash it onto a $5 development board, connect an RFID reader and relay module, and you have a fully functional door controller with a polished web management interface.

The web dashboard lets administrators add and remove users, assign access groups, set time-based access schedules, and view a real-time event log of every tap. The WebSocket connection pushes events to the browser instantly — you’ll see who just badged in before they’ve finished walking through the door.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# ESP-RFID setup: Flash the firmware, then configure via web
# No Docker needed — runs directly on ESP8266/ESP32
#
# Hardware wiring (ESP8266 NodeMCU to RC522):
#   RC522 SDA  → D8 (GPIO15)
#   RC522 SCK  → D5 (GPIO14)
#   RC522 MOSI → D7 (GPIO13)
#   RC522 MISO → D6 (GPIO12)
#   RC522 RST  → D3 (GPIO0)
#   Relay IN    → D1 (GPIO5)

Configuration is done entirely through the web interface — no firmware recompilation needed after initial flashing:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
{
  "wifi": {
    "ssid": "Office-IoT",
    "password": "secure-iot-password"
  },
  "network": {
    "hostname": "front-door",
    "ntpServer": "pool.ntp.org"
  },
  "rfid": {
    "readerType": "rc522",
    "openDoorTime": 5000,
    "accessByWiegandCode": false
  },
  "mqtt": {
    "enabled": true,
    "server": "mqtt.local",
    "port": 1883,
    "topic": "esp-rfid/front-door"
  }
}

ESP-RFID supports multiple authentication modes: card-only, card+PIN (for higher-security areas), and administrator override cards. The event log persists in flash memory and survives power cycles.

OpenMQTTGateway

OpenMQTTGateway takes a different approach: instead of being a self-contained access controller, it acts as a universal bridge that converts RFID readings into MQTT messages. This design philosophy means the device itself doesn’t make access decisions — it publishes “card X was presented at reader Y” and lets your home automation platform (Home Assistant, Node-RED, OpenHAB) decide what to do.

This architecture shines in complex environments. The same RFID reader that unlocks the front door can also arm/disarm the alarm system, log attendance, or trigger personalized lighting scenes. OpenMQTTGateway supports not just RFID but also BLE, infrared, LoRa, and 433MHz radios — making it a multi-protocol IoT gateway, not just an access controller.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# docker-compose.yml for MQTT broker + Node-RED control logic
version: '3.8'
services:
  mosquitto:
    image: eclipse-mosquitto:2
    ports:
      - "1883:1883"
    volumes:
      - ./mosquitto/config:/mosquitto/config
      - ./mosquitto/data:/mosquitto/data
    restart: unless-stopped

  nodered:
    image: nodered/node-red:latest
    ports:
      - "1880:1880"
    volumes:
      - ./nodered/data:/data
    environment:
      - TZ=America/Chicago
    restart: unless-stopped

In Node-RED, you can build sophisticated access flows: check the card against an authorized list, verify time-of-day restrictions, trigger the door relay, log to a database, and send a notification — all with drag-and-drop nodes.

Wiegand Interface Tools

Many commercial buildings already have Wiegand-interface RFID readers installed on every door. The ESP-RFID-Tool project helps you decode these existing readers without replacing hardware. Connect the reader’s D0 and D1 lines to GPIO pins, and the tool outputs the raw facility code and card number over serial or TCP.

This is particularly useful for integrating legacy access systems with modern backends. A university with 200 existing HID readers can place an ESP32 next to each reader, decode the Wiegand output, and pipe the data into a centralized PostgreSQL database without touching the physical readers.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Python client to receive Wiegand data from ESP-RFID-Tool
import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("192.168.1.100", 2323))

while True:
    data = sock.recv(1024).decode()
    facility, card_id, bits = data.strip().split(",")
    print(f"Card {card_id} (facility {facility}, {bits}-bit)")

    # Look up in database, trigger relay, log access
    user = db.lookup_card(card_id)
    if user and user.has_access():
        trigger_relay()
        log_access(user, "front-door")

Why Self-Host Your RFID Access Control?

Commercial access control systems charge per-door licensing fees that add up fast: $500-$2,000 per door for the controller, plus annual software maintenance. An ESP-RFID setup costs under $30 per door (ESP8266: $5, RC522 reader: $3, relay: $2, power supply: $5, enclosure: $10) with zero recurring fees.

Data sovereignty matters for physical security. With a self-hosted system, your access logs stay on your network, not a vendor’s cloud. You control backup schedules, retention policies, and who can view audit trails. When a vendor discontinues their cloud platform (as several access control startups have), self-hosted systems keep working.

On the integration side, MQTT-based systems connect seamlessly with existing smart home and building automation. Your door unlock event can trigger HVAC adjustments, lighting scenes, and occupancy tracking — integrations that commercial systems gate behind expensive “enterprise” API tiers.

For related physical security and IoT projects, see our network access control guide and our comparison of ESPHome vs Tasmota IoT firmware platforms. For wireless sensor integration, check our BLE MQTT gateway guide.

Deployment Topology and Failover Planning

A single ESP-RFID device controlling one door is straightforward, but real-world deployments quickly grow more complex. A typical small office might have a front door, a back door, a server room, and two interior office doors — five doors total, each needing independent or coordinated access control.

For multi-door setups, deploy one ESP device per door, each with its own IP address on the IoT VLAN. All devices publish MQTT events to a central broker, and a Node-RED or Home Assistant instance serves as the coordination layer. This architecture means a failure at one door does not affect any other door — each ESP operates independently with its own cached user database.

Power reliability deserves attention. A PoE (Power over Ethernet) ESP32 board like the Olimex ESP32-POE eliminates the need for a separate power supply at each door, drawing power from the same Ethernet switch that provides network connectivity. Combined with a UPS on the network switch, this ensures door controllers stay operational during brief power outages.

For high-security environments, consider a dual-reader configuration at each door: an entry reader on the outside and an exit reader on the inside. ESP-RFID supports this natively, logging both entry and exit events and enabling anti-passback rules that prevent a card from being used twice without an intervening exit.

Audit trail retention is the final consideration. ESP-RFID stores events in flash memory with a configurable maximum count, but for compliance purposes, pipe all events through MQTT to a time-series database like InfluxDB or a simple PostgreSQL table. This gives you searchable, long-term access logs without consuming the limited flash storage on the microcontroller.

FAQ

Is ESP-RFID secure enough for production use?

ESP-RFID uses standard RFID protocols (MIFARE Classic, which has known vulnerabilities if using default keys). For higher security, pair it with PN532 readers using MIFARE DESFire EV2 cards, or use the card+PIN mode. The web interface should be placed behind HTTPS (via a reverse proxy) if accessed over the internet. For mission-critical facilities, consider defense-in-depth: ESP-RFID as the first factor, with a separate PIN pad or biometric as the second factor.

Can I use existing HID/Paxton readers with these open-source solutions?

Yes, if your readers output Wiegand protocol (the industry standard for 26-58 bit cards). Connect the reader’s D0/D1 lines to an ESP32 running ESP-RFID or ESP-RFID-Tool. Most commercial readers from HID, AWID, and Keri Systems use Wiegand output. Note that some readers use proprietary encrypted protocols (HID iCLASS SE, some Paxton models) that require the manufacturer’s decoder.

How many doors can one ESP-RFID device control?

One ESP8266 can control one door (one relay output, one or two readers for entry/exit). An ESP32 has more GPIO pins and can potentially control two doors. For multi-door installations, deploy one ESP device per door and manage them all through the MQTT integration — a central dashboard can aggregate events from dozens of doors.

What happens if Wi-Fi goes down?

ESP-RFID caches its user database in flash memory and continues to operate without network connectivity. Door unlocks work normally; events are queued and synced when connectivity returns. The web interface and MQTT logging will be unavailable, but physical access control is not disrupted. For critical deployments, consider adding a local status indicator (LED/buzzer) to signal connectivity issues.



💰 想测试你的市场判断力?我用 Polymarket 做预测市场交易——这是全球最大的预测市场平台,从大选结果到技术监管时间线,什么都可以押注。和赌博不同,这是真正的信息市场:你懂的信息越多,胜率越高。我靠预测技术相关事件的走向已经赚了不少。用我的邀请链接注册:Polymarket.com