Smart RFID Access Control System Using ESP32 Dev Board and UHF RFID Reader Module

Smart RFID Access Control System using ESP32 Dev Board and UHF RFID Reader | MakeMindz
ESP32 UHF RFID I2C LCD Access Control IoT Security

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.

🕐 45–60 min build 🔧 Intermediate 📡 UART + I2C 🏷️ MakeMindz.com

📋 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

RFID Tag Scanned
ESP32 Reads Tag ID via UART
Check Authorization List
Authorised
LED ON
Confirmation beep
LCD → "Access Granted"
Unauthorised
Warning tone
LCD → "Access Denied"

🔧 Components Required

1
ESP32 Dev Board
Any 38-pin ESP32 with WiFi + Bluetooth
1
UHF RFID Reader Module
UART output, 902–928 MHz, long-range detection
1
16×2 I2C LCD Display
PCF8574 I2C backpack, address 0x27
1
Buzzer (Active)
3.3V–5V active piezo buzzer
1
LED + 220Ω Resistor
Access granted indicator
1
UHF RFID Tags
ISO 18000-6C / EPC Gen2 tags or cards
Breadboard + Jumper Wires
For prototyping connections

Key Features

✔ Long-range UHF RFID detection
✔ Real-time I2C LCD status display
✔ Audio + visual feedback
✔ Secure authentication logic
✔ Multi-tag ID support
✔ WiFi + Bluetooth ready
✔ Expandable cloud logging
✔ Industrial-ready design

Circuit Diagram

All components connect to the ESP32 via UART (RFID reader) and I2C (LCD). The LED and buzzer use direct GPIO digital outputs.

ESP32 Dev Board GPIO17 (RX2) ← RFID TX GPIO16 (TX2) → RFID RX GPIO2 → LED (220Ω) GPIO4 → Buzzer GPIO21 (SDA) → LCD GPIO22 (SCL) → LCD 3V3 → LCD VCC 5V → RFID VCC GND → Common GND UHF RFID Reader 902–928 MHz UART out TX → GPIO17 (ESP32) RX ← GPIO16 (ESP32) VCC ← 5V GND ← GND RFID Tag 16×2 LCD (I2C) Address 0x27 Access Granted Tag: 1234567890 SDA ← GPIO21 | SCL ← GPIO22 Buzzer GPIO4 LED + 220Ω GPIO2 Common Ground Rail — ESP32 GND → RFID GND → LCD GND → LED − → Buzzer − 5V / UART I2C bus

Simplified schematic — see pin wiring table below for exact connections

🔌 Pin Wiring Reference

ComponentComponent PinESP32 PinNotes
UHF RFID ReaderTXGPIO17 (RX2)UART Serial2 input
UHF RFID ReaderRXGPIO16 (TX2)UART Serial2 output
UHF RFID ReaderVCC5VModule needs 5V
UHF RFID ReaderGNDGNDCommon ground
LED (+ 220Ω)Anode +GPIO2Access granted indicator
LEDCathode −GNDVia 220Ω resistor to GND
BuzzerSignalGPIO4tone() for beep patterns
BuzzerGNDGNDCommon ground
16×2 LCD (I2C)SDAGPIO21I2C data line
16×2 LCD (I2C)SCLGPIO22I2C clock line
16×2 LCD (I2C)VCC3V3 or 5VCheck your module's voltage
16×2 LCD (I2C)GNDGNDCommon ground
⚠️ I2C address: Most PCF8574-based LCD backpacks default to 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

1
Install required Arduino libraries
Open Arduino IDE → Library Manager and install: LiquidCrystal_I2C by Frank de Brabander. Ensure the ESP32 board package is installed via the Boards Manager URL: https://dl.espressif.com/dl/package_esp32_index.json.
📦 The Wire.h library for I2C is included with the ESP32 core — no separate installation needed.
2
Wire the UHF RFID reader to ESP32 via UART
Connect RFID module TX → ESP32 GPIO17 and RFID module RX → ESP32 GPIO16. These are the Serial2 pins on the ESP32. Connect the module's VCC to the ESP32's 5V pin and GND to the common ground rail.
⚠️ Ensure your UHF RFID module operates at 3.3V logic levels or use a voltage divider on the TX line if it outputs 5V — the ESP32 GPIO pins are NOT 5V tolerant.
3
Connect the 16×2 I2C LCD display
Wire LCD SDA → GPIO21 and LCD SCL → GPIO22 on the ESP32. These are the hardware I2C pins. Connect LCD VCC to 3V3 (or 5V if your module requires it) and LCD GND to the common ground rail.
💡 Run an I2C scanner sketch first to confirm your LCD's I2C address (0x27 or 0x3F). If the display shows blank rows, adjust the contrast trimmer on the I2C backpack.
4
Wire the LED indicator
Place a 220Ω resistor in series between ESP32 GPIO2 and the LED anode (+). Connect the LED cathode (−) to the GND rail. The resistor limits current to a safe level for the ESP32 output pin.
5
Connect the buzzer
Connect the buzzer signal pin directly to ESP32 GPIO4. Connect buzzer GND to the common ground rail. For an active buzzer, a HIGH signal will trigger the beep — no additional driver circuit is needed for short beeps at 3.3V.
🔊 For louder output, use a passive buzzer with the tone() function (already in the code) — this lets you control frequency and duration.
6
Connect all grounds together
All GND pins — ESP32 GND, RFID GND, LCD GND, LED cathode, and buzzer GND — must share a common ground node. Use the breadboard's negative rail as the GND bus and run short jumper wires from each module to it.
7
Add your authorised tag IDs to the code
Scan your RFID tags and note the tag strings printed in Serial Monitor (at 9600 baud). Replace "1234567890" in the isAuthorized() function with your actual tag IDs. You can add multiple IDs using || (OR) conditions.
💡 For a scalable system, store tag IDs in an array and loop through them in isAuthorized() rather than using a chain of OR conditions.
8
Upload the sketch and test
Select your ESP32 board in Arduino IDE, choose the correct COM port, and upload. Open Serial Monitor at 9600 baud. Bring an authorised tag within range of the RFID reader — the LCD should display "Access Granted", the LED turns on, and the buzzer gives a short beep. An unauthorised tag triggers "Access Denied" with a warning tone.

💻 Full Source Code

Paste into Arduino IDE. Update the tag ID in isAuthorized() with your actual RFID tag string before uploading.

RFID_AccessControl.ino
/*
 * 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...");
}
This improved version supports multiple tag IDs in an array, shows the tag ID on LCD row 2 for granted access, and resets the display to a ready state after each scan — rather than leaving the result on screen indefinitely.

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

☁️ Cloud access logging
📱 Mobile push notifications
📊 Google Sheets attendance
🌐 Web dashboard monitoring
🔁 MQTT server integration
🔥 Firebase database
🔒 Relay for door lock control
🚪 Servo automatic door

🖥️ 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
🎓 This project is ideal for engineering final-year projects, IoT & embedded systems labs, polytechnic diploma projects, smart city innovation models, and science exhibitions.

© 2026 MakeMindz.com · Smart RFID Access Control System Tutorial · MIT Licensed

Built for STEM learners, IoT developers & engineering students.

Comments

try for free