Smart RFID Access Control
System using ESP32
A secure, real-time authentication system combining a UHF RFID reader, 16×2 I2C LCD, buzzer, and LED — built on the ESP32 with full WiFi/Bluetooth IoT expansion capability.
📋 Project Overview
This project builds a fully functional RFID-based access control system on the ESP32. The UHF RFID reader communicates with the ESP32 over UART (Serial2). When a tag is scanned, the ESP32 looks up its ID against a list of authorised credentials. The result — granted or denied — is instantly shown on the 16×2 I2C LCD, signalled by the LED, and confirmed with a buzzer tone.
Because the ESP32 has built-in WiFi and Bluetooth, this same hardware can be extended to log access events to the cloud, send push notifications, or integrate with a Firebase or MQTT server — all without changing the core wiring.
System operation flow
🔧 Components Required
✨ Key Features
⚡ Circuit Diagram
All components connect to the ESP32 via UART (RFID reader) and I2C (LCD). The LED and buzzer use direct GPIO digital outputs.
Simplified schematic — see pin wiring table below for exact connections
🔌 Pin Wiring Reference
| Component | Component Pin | ESP32 Pin | Notes |
|---|---|---|---|
| UHF RFID Reader | TX | GPIO17 (RX2) | UART Serial2 input |
| UHF RFID Reader | RX | GPIO16 (TX2) | UART Serial2 output |
| UHF RFID Reader | VCC | 5V | Module needs 5V |
| UHF RFID Reader | GND | GND | Common ground |
| LED (+ 220Ω) | Anode + | GPIO2 | Access granted indicator |
| LED | Cathode − | GND | Via 220Ω resistor to GND |
| Buzzer | Signal | GPIO4 | tone() for beep patterns |
| Buzzer | GND | GND | Common ground |
| 16×2 LCD (I2C) | SDA | GPIO21 | I2C data line |
| 16×2 LCD (I2C) | SCL | GPIO22 | I2C clock line |
| 16×2 LCD (I2C) | VCC | 3V3 or 5V | Check your module's voltage |
| 16×2 LCD (I2C) | GND | GND | Common ground |
0x27. If the display stays blank, try 0x3F. Use an I2C scanner sketch to confirm your module's address before uploading the main code.
🛠️ Step-by-Step Build Guide
https://dl.espressif.com/dl/package_esp32_index.json.tone() function (already in the code) — this lets you control frequency and duration."1234567890" in the isAuthorized() function with your actual tag IDs. You can add multiple IDs using || (OR) conditions.isAuthorized() rather than using a chain of OR conditions.💻 Full Source Code
Paste into Arduino IDE. Update the tag ID in isAuthorized() with your actual RFID tag string before uploading.
/* * Smart RFID Access Control System * MakeMindz.com — ESP32 + UHF RFID + I2C LCD + LED + Buzzer * * Connections: * RFID RX → GPIO17 | RFID TX → GPIO16 | RFID VCC → 5V * LCD SDA → GPIO21 | LCD SCL → GPIO22 | LCD VCC → 3V3 * LED anode → GPIO2 (via 220Ω) * Buzzer → GPIO4 */ #include <Wire.h> #include <LiquidCrystal_I2C.h> // Pin definitions #define RFID_RX_PIN 17 #define RFID_TX_PIN 16 #define LED_PIN 2 #define BUZZER_PIN 4 #define LCD_ADDRESS 0x27 #define LCD_COLUMNS 16 #define LCD_ROWS 2 // Authorised tag IDs — add more as needed const String authorisedTags[] = { "1234567890", "AABBCCDDEE" }; const int TAG_COUNT = sizeof(authorisedTags) / sizeof(authorisedTags[0]); LiquidCrystal_I2C lcd(LCD_ADDRESS, LCD_COLUMNS, LCD_ROWS); void setup() { Serial.begin(9600); Serial2.begin(9600, SERIAL_8N1, RFID_RX_PIN, RFID_TX_PIN); pinMode(LED_PIN, OUTPUT); pinMode(BUZZER_PIN, OUTPUT); digitalWrite(LED_PIN, LOW); lcd.begin(); lcd.backlight(); lcd.setCursor(0, 0); lcd.print("RFID Access"); lcd.setCursor(0, 1); lcd.print("System Ready"); delay(2000); lcd.clear(); lcd.print("Scan your tag..."); } void loop() { if (Serial2.available() > 0) { String rfidTag = Serial2.readStringUntil('\n'); rfidTag.trim(); Serial.print("Tag scanned: "); Serial.println(rfidTag); if (isAuthorised(rfidTag)) { grantAccess(rfidTag); } else { denyAccess(); } } } bool isAuthorised(String tag) { for (int i = 0; i < TAG_COUNT; i++) { if (tag == authorisedTags[i]) return true; } return false; } void grantAccess(String tag) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("Access Granted"); lcd.setCursor(0, 1); lcd.print(tag.substring(0, 16)); // show tag ID on row 2 digitalWrite(LED_PIN, HIGH); tone(BUZZER_PIN, 1000, 300); // 1kHz, 300ms — confirmation beep delay(2000); digitalWrite(LED_PIN, LOW); lcd.clear(); lcd.print("Scan your tag..."); } void denyAccess() { lcd.clear(); lcd.setCursor(0, 0); lcd.print("Access Denied"); lcd.setCursor(0, 1); lcd.print("Unauthorised tag"); tone(BUZZER_PIN, 300, 800); // 300Hz, 800ms — warning tone delay(2000); lcd.clear(); lcd.print("Scan your tag..."); }
📡 IoT Expansion Possibilities
Since the ESP32 has built-in WiFi and Bluetooth, this project can be extended without any hardware changes — just add libraries and WiFi credentials to the sketch.
🖥️ Run the Simulation
Test this circuit online before assembling the hardware:
🏭 Applications & Educational Value
Real-world applications
- Smart door lock systems — keyless entry for homes, offices, and labs
- Employee attendance tracking — RFID card-based clock-in/out logging
- Warehouse inventory authentication — scan items in and out of secure areas
- Parking management systems — vehicle RFID pass verification at entry gates
- Asset tracking solutions — locate and authenticate tagged equipment
- Industrial security automation — zone access control on factory floors
- Smart hostel entry systems — student room access via student ID cards
- School ID authentication — library access, lab entry, exam attendance
What students learn
- UART (Serial2) communication on ESP32
- UHF RFID technology and tag reading
- I2C LCD interfacing and LiquidCrystal_I2C library usage
- Authentication logic and credential lookup
- Audio-visual feedback with buzzer and LED
- IoT expansion concepts using ESP32 WiFi
Comments
Post a Comment