0% found this document useful (0 votes)
25 views6 pages

Study of RFID System

The document outlines a study of an RFID system using the RC522 RFID Reader/Writer module and Arduino Uno. It includes objectives such as understanding the pin structure of the Arduino and writing a program to accept or deny RFID cards. The document provides detailed pin connections, programming instructions, and a sample code for implementing the RFID system.

Uploaded by

gangurdesahil52
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views6 pages

Study of RFID System

The document outlines a study of an RFID system using the RC522 RFID Reader/Writer module and Arduino Uno. It includes objectives such as understanding the pin structure of the Arduino and writing a program to accept or deny RFID cards. The document provides detailed pin connections, programming instructions, and a sample code for implementing the RFID system.

Uploaded by

gangurdesahil52
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Study of RFID system

Aim: Study of RFID system using RC522 RFID Reader/Writer module.

Objectives:
a. To understand the basic Pin-out structure of Arduino Uno Board.
b. To study the basics of RC522 RFID Reader/Writer module.
c. To write a Arduino Uno program for Accepting or Denying RFID Card with
interfacing its RFID Reader using Arduino.

Circuit/ Block Diagram:

1
Pin Connection for RFID and LCD:
Pins of RFID Module Pins of Arduino UNO
RST D9
SS (SDA) D10
MOSI D11
MISO D12
SCK D13
VCC +3.3V
(Already Connected)
GND GND
(Already Connected)
Pins of 16 X 2 C-LCD Module
LCD_D4 A0
LCD_D5 A1
LCD_D6 A2
LCD_D7 A3
LCD_EN A4
LCD_RS A5

LED D3
BUZZER D4

Procedure:

Arduino Uno Programming: Arduino Uno IDE

a. Open a new sketch from “File” Menu of Arduino Software.


b. Write a program for RFID system with Ardunio Uno and save it as “rfidsys.ino”.
c. Select your board type and port.
d. You'll need to select the entry in the Tools > Board menu that corresponds to your
Arduino board. Select the serial device of the board from the Tools| Serial Port
menu. This is likely to be COM3 or higher (COM1 and COM2 are usually
reserved forhardware serial ports). To find out, you can disconnect your board and
re-open the menu, the entry that disappears should be the Arduino board.
Reconnect the board and select that serial port.
e. Verify and Upload the program.
Now, simply click the "Upload" button in the environment. Wait for few seconds
– you should see the RX and TX led‟s on the board flashing. If the upload is
successful, the message "Done uploading" will appear in the status bar.

2
Program: Typical pin layout used:

MFRC522 Arduino Uno/101


Reader/ PCD
Signal Pin Pin
RST/Reset RST 9
SPI SS SDA(SS) 10
SPIMOSI MOSI 11/ ICSP-4
SPIMISO MISO 12/ ICSP-1
SPISCK SCK 13/ ICSP-3

#include<SPI.h>
#include<MFRC522.h>
#include<LiquidCrystal.h>

#define SS_PIN 10
#define RST_PIN 9

#define LCD_D4 A0
#define LCD_D5 A1
#define LCD_D6 A2
#define LCD_D7 A3
#define LCD_EN A4
#define LCD_RS A5
#define OK_LED 3
#define ERROR_BUZ 4

LiquidCrystal lcd(LCD_RS,LCD_EN,LCD_D4, LCD_D5,LCD_D6, LCD_D7);

MFRC522 rfid(SS_PIN, RST_PIN); //Instance of the class

MFRC522::MIFARE_Key key; //Unique ID of RFID Tag, which you want to give access.

int My_RFID_Tag[4] ={0xA2,0x33,0xDE, 0x1C};


//A233DE1C-RFIDcard
//A266761C-RFIDcard
//variable to hold your Access_card
boolean My_Card=false;

//Init array that will store new


3
NUID byte nuidPICC[4];
String lastSent;

void setup()

pinMode(OK_LED, OUTPUT);
pinMode(ERROR_BUZ, OUTPUT);

digitalWrite(OK_LED, LOW);
digitalWrite(ERROR_BUZ,LOW);

lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("--FCT--");
delay(1000);

Serial.setTimeout(30);
Serial.begin(9600);
SPI.begin(); // Init SPI bus
rfid.PCD_Init(); //InitMFRC522
}

void loop()
{
//First Assume detected card (Or tag) is My_Card, Then later we will check is it
My_Card or not!
lcd.clear();
lcd.print("PutYourID-Card");
My_Card =true;
if(!rfid.PICC_IsNewCardPresent())
return;
if(!rfid.PICC_ReadCardSerial())
return;
MFRC522::PICC_TypepiccType=rfid.PICC_GetType(rfid.uid.sak);
if( piccType !=MFRC522::PICC_TYPE_MIFARE_MINI &&
piccType!=MFRC522::PICC_TYPE_MIFARE_1K&&
piccType!=MFRC522::PICC_TYPE_MIFARE_4K)
{
//Serial.println(F("YourtagisnotoftypeMIFAREClassic."));
return;
}

4
printHex(rfid.uid.uidByte,rfid.uid.size); //display card number on serial monitor
Serial.println();
delay(500);

//Compare this RFID Tag Unique ID with your My_RFID_Tag's Unique ID


for(inti =0; i< 4; i++)
{
//if any-ones Unique ID Digit is not matching, then make My_Card=false and come
out from loop. No need to check all the digit!
if(My_RFID_Tag[i]!=rfid.uid.uidByte[i])
{
My_Card =false;
break;
}
}
Serial.println();

//If RFID Tag is My_Card then give access to enter into classroom else don’t open
the door.
if(My_Card)
{
Serial.println("\nWelcome To Class Room ");
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("WelcometoClass");
lcd.setCursor(0, 1);
lcd.print("AccessGranted");
delay(1000); //Turn on the Green LED as an indication of permission is given to access
the classroom.
digitalWrite(ERROR_BUZ,LOW);
digitalWrite(OK_LED, HIGH);
delay(1000);
digitalWrite(OK_LED, LOW);
}
else
{
Serial.println("\nDon't enterintheClassRoom");
lcd.clear();
lcd.print("CardNOTFOUND!");
lcd.setCursor(0, 1);
lcd.print("AccessDenied");
delay(1500);
digitalWrite(OK_LED, LOW);

5
digitalWrite(ERROR_BUZ,HIGH);
delay(1500);
digitalWrite(ERROR_BUZ,LOW);
}
// Halt PICC
rfid.PICC_HaltA();
//Stop encryption on PCD
rfid.PCD_StopCrypto1();
}
/* Helper routine to dump a byte array as hex values to Serial. */
void printHex(byte*buffer,bytebufferSize)
{
lastSent= "";
for (byte i = 0; i<bufferSize; i++)
{
byte n1 = (buffer[i] >> 4) & 0x0F;
byten2=buffer[i] & 0x0F;
lastSent += n1 < 10 ? '0' + n1: 'A' + (n1-10);
lastSent += n2 < 10 ? '0' + n2: 'A' +(n2 -10);
Serial.print(buffer[i]<0x10?"0":"");
Serial.print(buffer[i],HEX);
}
}
Steps to execute Program
1. Make connections as given above.
2. Open „rfidsys.ino‟ file in Arduino IDE
3. Compile and upload the program.

You might also like