RFID Security System Using Arduino

by TECHATRONIC in Circuits > Arduino

17 Views, 0 Favorites, 0 Comments

RFID Security System Using Arduino

1623562727215-e1629704057156.jpg

Hello Guys, Welcome back to another interesting Project related to Arduino. Today, we're going to make an RFID Security System with used RFID Tags to authenticate something. We'll use basic hardware and module which are available in the market like I2C LCD. Also, we'll provide full code and Circuit Diagram further. So, let's talk about basic hardware & modules we’re going to use.

I2C LCD is the device which is used to display characters on it. Generally it uses 7-bit mode for making communication with Arduino, but for reduction of pins and easiness we use I2C module for It. Also, as many I2C devices can be connected simultaneously. So There won't be shortage of the pins.

RFID module uses I2C communication to Read & Write the RFID Tags and to authenticate It. Due to its low quality only some type of RFID tags can be read and write so don't try other and get misguided.

For more information related to other modules used, visit my original post.

Material Required

  • Arduino UNO
  • 16×2 LCD and I2C module
  • Servo motor
  • Buzzer
  • Green and Red LED
  • Jumper wires
  • Breadboard
  • RC522 RFID module
  • 220-ohm resistors and a 10K potentiometer
  • USB cable for uploading the code

Circuit Diagram

RFID-Security-System-1024x765.jpg

s1.png
s4.png
 // TECHATRONIC.COM
 // SPI Library  
 //  https://github.com/PaulStoffregen/SPI   
 // MFRC522 Library  
 //  https://github.com/PaulStoffregen/SPI   
 #include <SPI.h>  
 #include <MFRC522.h>  
 #include <Servo.h>  
 #include <Wire.h>   
 #include <LiquidCrystal_I2C.h>  
 LiquidCrystal_I2C lcd(0x3F,16,2);  
 Servo s1;  
 #define SS_PIN 10  
 #define RST_PIN 9  
 #define LED_G 5  //define green LED pin  
 #define LED_R 7  //define red LED  
 #define BUZZER 6 //buzzer pin  
 MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance.  
 //Servo myServo; //define servo name  
 void setup()   
 {  
  Serial.begin(9600);  // Initiate a serial communication  
  SPI.begin();     // Initiate SPI bus  
   lcd.init();             
  lcd.backlight();  
 ;  
  mfrc522.PCD_Init();  // Initiate MFRC522  
  s1.attach(3); //servo pin  
  // myServo.write(0); //servo start position  
  pinMode(LED_G, OUTPUT);  
  pinMode(LED_R, OUTPUT);  
  pinMode(BUZZER, OUTPUT);  
  noTone(BUZZER);  
  Serial.println("Put your card to the reader...");  
  Serial.println();  
  lcd.setCursor(0,0);  
  lcd.print(" Put your card   ");  
 }  
 void loop()   
 {  
  // 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) == "5B 2F 4B 0C") //change here the UID of the card/cards that you want to give access  
  {  
   Serial.println("Authorized access");  
   Serial.println();  
     lcd.setCursor(0,0);  
     lcd.print(" CARD IS VALID      ");  
     lcd.setCursor(0,1);  
     lcd.print("Opening the Door   ");  
     digitalWrite(LED_G, HIGH); //Green LED ON  
     s1.write(0);  
     delay(3000);  
     s1.write(90);  
     lcd.setCursor(0,1);  
     lcd.print("closing the Door   ");  
     digitalWrite(LED_G, LOW);  //Green LED OFF  
     delay(2000);  
     lcd.setCursor(0,0);  
     lcd.print(" Put your card   ");  
     lcd.setCursor(0,1);  
     lcd.print("              ");  
  }  
  else   
  {  
   Serial.println("CARD IS INVALID");  
    lcd.setCursor(0,1);  
    lcd.print("CARD IS INVALID   ");  
    digitalWrite(LED_R, HIGH);   // Red LED ON  
    tone(BUZZER, 300);       // Buzzer ON  
    delay(2000);  
    digitalWrite(LED_R, LOW);  
    noTone(BUZZER);  
    lcd.setCursor(0,1);  
    lcd.print("              ");  
  }  
 }  

For explanation of Code and further troubleshooting visit my original post as all my further post will be available there before it is available here TECHATRONIC.COM