Introduction
An RFID (Radio-Frequency Identification) access control system with an I2C LCD display is a powerful and secure way to manage access to restricted areas. It combines the convenience of RFID technology with visual feedback through an I2C-enabled LCD screen, making it an ideal choice for homes, offices, or any place where access needs to be controlled. In this comprehensive guide, we’ll walk you through building your own RFID access control system with an I2C LCD display, explaining its working principles, the components needed, providing circuit and pin diagrams, and sharing the Arduino code to bring it to life.
Working Principle
The RFID access control system operates by reading unique RFID tags/cards and comparing their data to an authorized list. When an authorized tag is presented, the system grants access and displays a message on the I2C LCD screen. If an unauthorized tag is detected, access is denied, and a different message is displayed.
Things we need
- Arduino Uno
- RFID Reader RC522
- RFID Cards / Tags
- I2C LCD Liquid Crystal Display
- Jumper cables
- Breadboard
Circuit diagram
Working of the system with Arduino
The Arduino code provided below will read RFID tags, compare them to the authorized list, and display messages on the LCD screen accordingly. Here’s how it works:
RFID Reader Module: The RC522 RFID module communicates with RFID tags/cards using radio-frequency signals. It reads the tag’s unique identifier, which is then compared to the authorized list.
I2C LCD Display: An I2C-enabled LCD display simplifies the wiring and communication with the Arduino. Make sure to set the correct I2C address in the LiquidCrystal_I2C constructor.
Code
We need to find the tag ID in order to do that please refer to the article mentioned below
#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);
LiquidCrystal_I2C lcd(0x27, 16, 2); // Change the I2C address if necessary (0x27 is common)
String authorizedRFID[4] = {
"Your_Tag_1_ID", //To read the tags you need to perfrom another activity.
"Your_Tag_2_ID", // Please check the link in the post
"Your_Tag_3_ID",
"Your_Tag_4_ID"
};
void setup() {
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Place your card...");
}
void loop() {
if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) {
return;
}
String currentTag = "";
for (byte i = 0; i < mfrc522.uid.size; i++) {
currentTag += String(mfrc522.uid.uidByte[i], HEX);
}
currentTag.toUpperCase();
bool accessGranted = false;
for (int i = 0; i < 4; i++) {
if (currentTag == authorizedRFID[i]) {
accessGranted = true;
break;
}
}
lcd.clear();
lcd.setCursor(0, 0);
if (accessGranted) {
lcd.print("Access Granted");
// Add your access control logic here
} else {
lcd.print("Access Denied");
// Add your access denied logic here
}
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Place your card...");
}
Conclusion
Building your RFID access control system with an I2C LCD display is a practical and secure project that can enhance security and access management in various environments. You’ve learned about the fundamental working principles, gathered the necessary components, connected them as per the circuit diagram, and programmed the Arduino to control access and display messages on the I2C LCD screen. This versatile system can be used for homes, offices, or any place where controlled access is essential. Embrace the possibilities, and let your DIY access control system enhance your understanding of electronics and RFID technology. Happy building!