RFID Basics

 

RFID stands for radio frequency identification and it basically uses the radio waves to read the information on the tag. The RFID tags contains the embedded transmitter and receiver attached to an object.

RFID is fast and does not require any contact between the reader and the tag and they can be read from feet’s away.

An RFID system consists of two parts: Tag and Reader

 

RFID Tag

An RFID tag contains a chip for storing information about physical object and an antenna to receive and transmit a signal. A RFID tag can usually store 1KB of data but it is enough for storing the name, credit card number, unique identification number, birth date and some more information.

RFID Tags can be passive or active

  

  • Passive taghas no battery and it uses the energy transmitted by the reader.
  • An Active tagcontains a built in battery which makes it able to send a stronger signal and the range increases to 100 feet. Other features are same as the passive tags.

 

RFID Reader

 

The RFID reader performs two functions: Transmit and receive. So you can also say it a transceiver. The RFID reader contains an antenna, radio frequency module and a control unit

How RFID works

The RFID reader generates a high frequency electromagnetic field and when the tag comes near it, a voltage is induced in tags antenna coil due to induction. This induced voltage acts as power for the tag. The tag in return converts the signal in power and responds to the reader

RFID Arduino Interfacing

Now let’s interface the RFID reader module with Arduino. The RFID reader we are going to use is MFRC522 reader module and it communicates with the Arduino through SPI protocol. It operates at 13.56 MHz frequency.

The tags are based on MIFARE protocol and they have 1kb of memory. They also have a microchip that can perform arithmetic operations.

For RFID Arduino interfacing, you are going to require the following parts

  • Arduino Uno or any other Arduino
  • MFRC 522 RFID Module
  • I2C LCD Display
  • Three LED’s (Green, Red, Blue)
  • Sg90 servo motor
  • 3 X 220 ohm resistors
  • Buzzer

 

 

Now open the serial monitor and bring the RFID card in front of the reader, it will show you the information of the RFID tag. Save the UID number, we are going to use it in the second example.

In the above image, you can see the UID number of the tag and also the 1kb of memory which is divided into 16 sectors. Each sector has 4 blocks and each block can store 4 bytes.

Code:

// Include required libraries

#include <LiquidCrystal_I2C.h>

#include <SPI.h>

#include <MFRC522.h>

#include <Servo.h>

 

// Create instances

LiquidCrystal_I2C lcd(0x27, 16, 2);

MFRC522 mfrc522(10, 9); // MFRC522 mfrc522(SS_PIN, RST_PIN)

Servo sg90;

 

// Initialize Pins for led’s, servo and buzzer

// Blue LED is connected to 5V

constexpr uint8_t greenLed = 7;

constexpr uint8_t redLed = 6;

constexpr uint8_t servoPin = 8;

constexpr uint8_t buzzerPin = 5;

 

String tagUID = “29 B9 ED 23”; // String to store UID of tag. Change it with your tag’s UID

 

void setup() {

// Arduino Pin configuration

pinMode(buzzerPin, OUTPUT);

pinMode(redLed, OUTPUT);

pinMode(greenLed, OUTPUT);

 

sg90.attach(servoPin); //Declare pin 9 for servo

sg90.write(0); // Set initial position at 90 degrees

 

lcd.begin(); // LCD screen

lcd.backlight();

SPI.begin(); // Init SPI bus

mfrc522.PCD_Init(); // Init MFRC522

 

lcd.clear();

}

 

void loop() {

lcd.setCursor(0, 0);

lcd.print(” RFID Door Lock”);

lcd.setCursor(0, 1);

lcd.print(” Show Your Tag “);

 

// Look for new cards

if ( ! mfrc522.PICC_IsNewCardPresent()) {

return;

}

 

// Select one of the cards

if ( ! mfrc522.PICC_ReadCardSerial()) {

return;

}

 

//Reading from the card

String tag = “”;

for (byte i = 0; i < mfrc522.uid.size; i++)

{

tag.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? ” 0″ : ” “));

tag.concat(String(mfrc522.uid.uidByte[i], HEX));

}

tag.toUpperCase();

 

//Checking the card

if (tag.substring(1) == tagUID) //change here the UID of the card/cards that you want to give access

{

// If UID of tag is matched.

lcd.clear();

lcd.setCursor(0, 0);

lcd.print(“Access Granted”);

lcd.setCursor(0, 1);

lcd.print(“Door Opened”);

sg90.write(90);

digitalWrite(greenLed, HIGH);

delay(3000);

digitalWrite(greenLed, LOW);

sg90.write(0);

lcd.clear();

}

 

else

{

// If UID of tag is not matched.

lcd.clear();

lcd.setCursor(0, 0);

lcd.print(“Wrong Tag Shown”);

lcd.setCursor(0, 1);

lcd.print(“Access Denied”);

digitalWrite(buzzerPin, HIGH);

digitalWrite(redLed, HIGH);

delay(3000);

digitalWrite(buzzerPin, LOW);

digitalWrite(redLed, LOW);

lcd.clear();

}

}

 

String tagUID = “29 B9 ED 23”; // String to store UID of tag. Change it with your tag’s UID

The Arduino code is as follows

Application:

  • Payments in means of transport: public transports and tolls. …
  • Asset management: Location, identification and transport trace. …
  • Inventories and warehouses. …
  • Identification of animals. …
  • Access control: sports facilities, buildings, tourism. …

 

 

Reference:

https://electronicshobbyists.com/rfid-basics-and-rfid-module-interfacing-with-arduino/

http://www.circuitstoday.com/interfacing-rfid-with-arduino

https://howtomechatronics.com/tutorials/arduino/rfid-works-make-arduino-based-rfid-door-lock/

https://randomnerdtutorials.com/security-access-using-mfrc522-rfid-reader-with-arduino/