RFID Attendance System(IoT Projects Arduino)
This project IoT Projects Arduino is designed to create an RFID-based attendance system using an ESP32 microcontroller and an MFRC522 RFID reader. The system reads RFID card UIDs, compares them with predefined UIDs to identify users, and displays the results on a LiquidCrystal_I2C LCD screen. If the scanned card UID matches the predefined UID, a "Welcome" message is shown; IoT Projects Arduino otherwise, an "Access Denied" message is displayed. This project demonstrates the use of RFID technology for access control and attendance management.IoT Projects Arduino
Project : 50
Introduction
This project IoT Projects Arduino is
designed to create an RFID-based attendance system using an ESP32
microcontroller and an MFRC522 RFID reader. The system reads RFID card UIDs, compares
them with predefined UIDs to identify users, and displays the results on a
LiquidCrystal_I2C LCD screen. If the scanned card UID matches the predefined
UID, a "Welcome" message is shown; otherwise, an "Access
Denied" message is displayed. This project demonstrates the use of RFID
technology for access control and attendance management.
Components Required
-
ESP32 Microcontroller: The central unit that processes RFID card
data and controls the LCD display.
- MFRC522 RFID Reader: Detects and reads RFID card UIDs.
- LiquidCrystal_I2C Display: For displaying user access status and other messages.
-
- Connecting Wires: For connecting the RFID reader and LCD to the ESP32.
- Power Supply: To power the ESP32 and other connected components.
-
Pin Configuration:
- RFID Reader Pins:
- SDA (SS): Connected to GPIO 27 of
the ESP32.
- RST: Connected to GPIO 5 of the
ESP32.
LCD Pins: Connected via I2C (SDA and SCL pins on ESP32).
Libraries Used
- MFRC522: For interfacing with the
RFID reader.
- Wire: For I2C communication with
the LCD.
- LiquidCrystal_I2C: For interfacing
with the LCD display.
PCB (Printed Circuit Board) DIAGRAM:
SCHEMATIC DIAGRAM
Code
#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD display via I2C
#include <SPI.h> // Library for SPI communication
#include <MFRC522.h> // Library for RFID reader
#define SS_PIN 27 // Pin for Slave Select (SS) of RFID reader
#define RST_PIN 5 // Pin for Reset (RST) of RFID
reader
MFRC522 rfid (SS_PIN, RST_PIN); // Create
an MFRC522 object with SS and RST pins
LiquidCrystal_I2C lcd (0x27, 16, 2); //
Create an LCD object with I2C address 0x27 and 16x2 display
// Predefined UID for comparison (set this
to the UID you want to match)
const byte predefined [] = {0x83, 0xC8,
0xFA, 0xFA}; // Example UID, adjust to your actual UID
void setup () {
Serial.begin(115200); // Initialize serial communication at 115200 baud
rate
SPI.begin(); // Initialize
SPI communication
lcd.init(); //
Initialize the LCD
lcd.
backlight (); // Turn on the
LCD backlight
//
Display initial welcome message on LCD
lcd.
setCursor (2, 0);
lcd.print("Attendance");
delay
(1000); // Wait for 1 second
lcd.
setCursor (1, 1);
lcd.print("System");
delay
(4000);
lcd.
clear (); // Clear the LCD display
lcd.
setCursor (0, 0);
lcd.print("Please");
lcd.
setCursor (0, 1);
lcd.print ("Scan card");
rfid.PCD_Init (); //
Initialize the RFID reader
Serial.println("Scan RFID card");
}
void loop () {
//
Check if a new RFID card is present
if (!
rfid. PICC_IsNewCardPresent ()) {
return; // Exit if no new card is detected
}
//
Try to read the UID from the detected card
if (!
rfid. PICC_ReadCardSerial ()) {
return; // Exit if reading the UID fails
}
lcd.
clear ();
Serial.print("Card UID: ");
byte scannedUID[rfid.uid.size]; // Array to store the scanned UID bytes
//
Read the UID bytes from the RFID card
for
(byte i = 0; i < rfid.uid.size; i++) {
scannedUID[i] = rfid.uid.uidByte[i]; // Store each byte of UID
Serial.print(rfid.uid.uidByte[i], HEX); // Print each byte in
hexadecimal format
Serial.print(" ");
}
Serial.println();
//
Compare the scanned UID with the predefined UID
bool match = true; // Flag to indicate if UIDs match
if
(rfid.uid.size == sizeof(predefinedUID)) { // Check if the size of UID matches
for (byte i = 0; i < rfid.uid.size; i++) {
if (scannedUID[i] != predefinedUID[i]) { // Compare each byte
match = false; // Set flag to false if any byte does not match
break; // Exit the loop if mismatch is found
}
}
}
else {
match = false;
}
//
Display result based on UID comparison
lcd.setCursor(0, 0);
if
(match) {
lcd.print("Welcome");
lcd.setCursor(0, 1);
lcd.print("Nepatronix");
Serial.println("Registered");
}
else {
lcd.print("Access Denied");
Serial.println("Access Denied");
}
delay(4000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Please");
lcd.setCursor(0, 1);
lcd.print("Scan card");
rfid.PICC_HaltA();
rfid.PCD_StopCrypto1(); // Stop encryption on the RFID reader
}
Working of
- Initialization:
- Serial Communication: The ESP32
initializes serial communication at 115200 baud rate.
- LCD Initialization: I2C
communication is set up for the LCD, and an initial message is displayed.
- RFID Reader Initialization: The
RFID reader is initialized to start reading cards.
- Main Loop:
- Card Detection: The system
continuously checks for the presence of a new RFID card.
- UID Reading: When a card is
detected, its UID is read and displayed on the LCD.
- UID Comparison: The read UID is
compared with a predefined UID. Based on the comparison, a
"Welcome" or "Access Denied" message is displayed.
- UID Comparison:
- Byte-by-Byte Comparison: The
scanned UID is compared byte-by-byte with the predefined UID.
- Display Result: If the UID
matches, the LCD shows "Welcome"; otherwise, it shows
"Access Denied".
Testing
- Setup: Connect all components
according to the pin configuration.
- Power Up: Power the ESP32 and ensure
all components are properly connected.
- RFID Scanning: Scan an RFID card
and verify that the UID is correctly read and displayed.
- UID Matching: Test with both
matching and non-matching RFID cards to ensure that the system correctly
identifies registered users and denies access to unregistered ones.
- LCD Display: Verify that the
correct messages ("Welcome" or "Access Denied") are
displayed on the LCD based on the UID comparison.
Conclusion
The RFID-Based
Attendance System project effectively demonstrates how an ESP32 microcontroller
can be used in conjunction with an MFRC522 RFID reader to create a secure
access control system. By integrating the RFID reader with an LCD display, this
project provides a clear and immediate indication of user access status. The
system is suitable for various applications requiring secure identification and
access management.
Team Members:
·
Nehasha Ale
·
Tasmina Khatri
·
Sujan Saru
·
Utsav Paudyal
·
Ashwin Gautam
·
Trilochan Gaha
College Name: Nepathya College ,Rupandehi ,Nepal