An ESP32-based RFID access control system featuring real-time validation through a Node.js/Express backend with MongoDB storage.
Includes a configuration portal, 3D-printed enclosure, device display feedback, and complete wireless provisioning.
This project implements a complete access control system using:
- ESP32 microcontroller
- MFRC522 RFID reader
- Node.js/Express backend
- MongoDB database
- Custom 3D-printed enclosure
- Wi-Fi configuration portal with onboard AP mode
The device reads RFID cards, sends their UID to the backend server, and reacts with ALLOW or DENY feedback based on server response.
- ESP32 firmware written for stable, real-time operation
- MFRC522 RFID card reading
- HTTP communication with backend
- Node.js/Express REST API for validation and logging
- MongoDB database for storing authorized cards and access logs
- Device display + buzzer for user feedback
- Wi-Fi provisioning via internal access point
- Web-based configuration UI (both in AP mode and on normal LAN)
- Custom 3D-printed enclosure designed for daily use
[ RFID Card ] --> [ ESP32 + MFRC522 ] --> HTTP Request --> [ Node.js/Express Backend ] --> [ MongoDB ]
<-- HTTP Response (ALLOW / DENY) <--
- Device reads RFID UID
- Sends UID to backend
- Backend checks database
- Backend sends ALLOW / DENY
- Device displays result + optional buzzer
Components used:
- ESP32 Dev Board
- MFRC522 RFID reader
- Small I2C display (SSD1306 128x64)
- Buzzer
- Reset/config button (accessible through enclosure pinhole)
- Custom 3D-printed enclosure
Enclosure photos and 3D files live in:
./docs/images/
./enclosure/
Located in:
./RFID/
Responsible for:
- Initializing MFRC522 and reading card UIDs
- Connecting to Wi-Fi (STA mode)
- Communicating with the backend via HTTP (JSON)
- Handling configuration mode via:
- Serial command (
cfg) - Long press on reset button
- Serial command (
- Saving Wi-Fi + server settings in NVS (
Preferences) - Providing user feedback on OLED + buzzer
- Driving access control output pins
Located in:
./Server for RFID/
Backend capabilities:
- Validates RFID card UIDs
- Provides API endpoint (e.g.
/api/cards/validate) for device checks - Stores authorized cards and access logs in MongoDB
- Returns JSON responses with
allowflag and optionalcardholderName
cd "Server for RFID"
npm install
npm startRequirements:
- A running MongoDB instance
- A
.envfile containing something like:MONGODB_URI=your_connection_string_here SERVER_PORT=3000
3D files are stored in:
./enclosure/
Includes:
.stland/or.stepCAD files- Photos of the printed and assembled enclosure (
./docs/images/enclosure-*.jpg)
Example gallery (replace with real paths):
### Enclosure Photos
<p align="center">
<img src="./docs/images/enclosure-front.jpg" width="320">
<img src="./docs/images/enclosure-side.jpg" width="320">
</p>When powered, the ESP32:
- Loads saved Wi-Fi + server settings from NVS
- Attempts to connect to the configured Wi-Fi network
- Enters normal operation once connected
If settings are invalid, the device will still stay in normal loop, but you can always enter configuration mode manually (see below).
- Present an RFID card near the MFRC522 reader
- The device reads the UID and normalizes it
- Sends an HTTP POST request to
SERVER_URLwith UID, MAC, IP, RSSI, etc. - Backend returns JSON with an
allowflag and optionalcard.cardholderName - Device behavior:
- On ALLOW:
- Plays “access granted” buzzer pattern
- Activates grant outputs (
SIGNAL_PIN_HIGH_1,SIGNAL_PIN_HIGH_2,SIGNAL_PIN_LOW) - Displays
Welcome+ cardholder name on OLED
- On DENY:
- Plays “access denied” buzzer pattern
- Displays
Access Denied
- On ALLOW:
Backend logs all attempts.
You can later attach a relay or lock to the signal pins.
Configuration mode lets you set Wi-Fi SSID, password and backend URL.
There are two ways to enter it: button or serial.
Your enclosure has a pinhole aligned with the reset/config button.
-
Insert a SIM-tool-style pin or thin rod
-
Press and hold the button for about 5 seconds
-
The device:
- Switches to AP mode
- Starts a config access point:
SSID: DoorConfig Password: 12341234 - Starts the web UI on
192.168.4.1 - Shows “configuration mode active” on the OLED
- Plays a triple config tone on the buzzer
-
Connect your phone or laptop to the Wi-Fi network
DoorConfig -
Open a browser and go to:
http://192.168.4.1/
-
Log in with password:
12341234 -
Use the form to set:
- Wi-Fi SSID
- Wi-Fi password
- Server URL (
SERVER_URL)
-
Click Save & Reboot
- Settings are written to NVS
- Device restarts and attempts to connect with the new settings
You can also enter configuration mode via USB serial:
- Connect the ESP32 to your computer
- Open a serial monitor (115200 baud)
- Type:
cfg
and press Enter.
- Device enters “serial configuration mode” and prompts you in the terminal for:
- New Wi-Fi SSID
- New Wi-Fi password
- New server URL
Press Enter on any field to keep the current value.
- Confirm with
yto save changes, or any other key to discard. - On save:
- Settings are written to NVS
- Device plays a “success” tone
- Device restarts using the new configuration
When the device is already connected to your Wi-Fi network, you can also access the configuration UI via its LAN IP:
- Find the device IP address in your router or via serial logs
- Open:
http://<device-ip>/
- Log in with password:
12341234
- You’ll see the same configuration form as in AP mode (
/cfgroute). - Saving configuration will also reboot the device.
- Wi-Fi reconnection is handled by
ensureWiFi()with retries and error display. - If Wi-Fi or server are down, the device shows error messages and plays an error tone, but you decide when to enter config mode (via button or
cfg). - Duplicate card reads within a short cooldown (
CARD_COOLDOWN_MS) are ignored to avoid spamming the backend.
- Designing a full end-to-end embedded + backend access control system
- Interfacing ESP32 with MFRC522 and SSD1306 OLED
- Implementing Wi-Fi connectivity, HTTP requests, and JSON handling on microcontrollers
- Building REST APIs with Node.js/Express and integrating them with MongoDB
- Using non-volatile storage (
Preferences) for device configuration - Building a simple but effective web admin panel on an ESP32 using
WebServer - Designing and printing a custom enclosure for an electronic device
Released under the MIT License.
See the LICENSE file for full details.
