Header Ads

RFID-RC522 Based Security System by Arduino with Lcd Display

Overview

In this tutorial, we will learn how to interface RC522 RFID reader module with Arduino and LCD display and make an authorized access system. The RFID-RC522 module is an RFID reader, which can read RFID tags in short-range by creating an electromagnetic field. The working frequency of this module is 13.56MHz. In order to read an RFID tag, the reader and the tag must have the same frequency. RFID is used to identify people, to make transactions etc.

You can watch the following video below:- 

Components Required

The following components needed for the project:-
  • Arduino Uno
  • RC522 RFID Reader
  • RFID Tag
  • 16*2 LCD display
  • 10k Potentiometer
  • 220-ohm Resistor
  • Some Jumper Wire
  • Breadboard

RC522 RFID Reader Pinout

The RC522 RFID reader pin configuration given below:-
Fig: RC522 RFID Pinout

Circuit Schematic

The circuit diagram of the Rfid reader and Arduino interfacing with LCD display below:- 
Fig: Arduino interfacing with Rfid Reader and LCD

Circuit Description

The RFID module pins will be connected with Arduino pins by the following procedure.
  • Arduino 3.3v pin to RFID pin 3.3v.
  • Arduino GND pin RFID GND pin.
  • Arduino digital pin 9 to RFID pin RST pin.
  • Arduino digital pin 10 to RFID pin SDA pin.
  • Arduino digital pin 11 to RFID pin MOSI pin.
  • Arduino digital pin 12 to RFID pin MISO pin.
  • Arduino digital pin 13 to RFID pin SCK pin.
Next, we will connect the LCD display with Arduino.  LCD pins EN, R/W, D4, D5, D6, and D7 will be connected with Digital pins 7, 6, 5, 4, 3, and 2 respectively. LCD pins 1, 4, 16 will connect to GND pin of Arduino. LCD pin 15 will connect to the 5v pin of the Arduino via 220-ohm and LCD pin 2 will also connect with 5VThe middle pin of the 10k potentiometer will be connected to the VO pin 3 and the other two pins will be connected to +5V and ground.

Source Code

The Source of three wire LCD display given below:-

 #include <SPI.h>  
 #include <MFRC522.h>  
 #include <LiquidCrystal.h>  
 #define SS_PIN 10  
 #define RST_PIN 9  
 MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance.  
 #define beep_pin 8  
 LiquidCrystal lcd(2, 3, 4, 5, 6, 7);  
 void setup()   
 {  
  Serial.begin(9600);  // Initiate a serial communication  
  pinMode(beep_pin,OUTPUT);  
  digitalWrite(beep_pin,LOW);  
  lcd.begin(16, 2);  
  lcd.setCursor(3, 1);  
  lcd.print("Welcome!!");  
  lcd.setCursor(0, 0);  
  lcd.print("Circuit is Ready");  
  delay(1500);  
  lcd.clear();   
  SPI.begin();   // Initiate SPI bus  
  mfrc522.PCD_Init();  // Initiate MFRC522  
  Serial.println("Put your card to the reader...");  
  Serial.println();  
 }  
 void loop()   
 {  
  digitalWrite(beep_pin, LOW);  
  lcd.clear();  
  lcd.setCursor(0, 0);  
  lcd.print("Put your card to");  
  lcd.setCursor(0, 1);  
  lcd.print("the reader......");  
  delay(300);  
  // Look for new cards  
  if ( ! mfrc522.PICC_IsNewCardPresent())   
  {  
   return;  
  }  
  // Select one of the cards  
  if ( ! mfrc522.PICC_ReadCardSerial())   
  {  
   return;  
  }  
  //Show UID on serial monitor  
  Serial.print("UID tag :");  
  String content= "";  
  byte letter;  
  for (byte i = 0; i < mfrc522.uid.size; i++)   
  {  
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");  
    Serial.print(mfrc522.uid.uidByte[i], HEX);  
    content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));  
    content.concat(String(mfrc522.uid.uidByte[i], HEX));  
  }  
  Serial.println();  
  Serial.print("Message : ");  
  content.toUpperCase();  
  if (content.substring(1) == "XX XX XX XX") //change here the UID of the card/cards that you want to give access  
  {  
   digitalWrite(beep_pin,HIGH);  
   delay(200);  
   digitalWrite(beep_pin,LOW);  
   delay(100);  
   lcd.setCursor(0, 0);  
   lcd.print("ID : ");  
   lcd.print(content.substring(1));  
   lcd.setCursor(0, 1);  
   lcd.print("Authorized access");  
   Serial.println("Authorized access");  
   delay(1200);     
  }  
  else  {  
   digitalWrite(beep_pin,HIGH);  
   lcd.setCursor(0, 0);  
   lcd.print("ID : ");  
   lcd.print(content.substring(1));  
   lcd.setCursor(0, 1);  
   lcd.print("Access denied");  
   Serial.println(" Access denied");  
   delay(1500);  
    }  
 }   

You can download the RFID library from here: https://github.com/miguelbalboa/rfid

No comments

Powered by Blogger.