What Is RFID Technology and How Does It Work?

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Expt no 4:Write a program to implement RFID using Arduino.

What is RFID technology and how does it work?


An RFID or radio frequency identification system consists of two main components, a tag
attached to the object to be identified, and a reader that reads the tag.

A reader consists of a radio frequency module and an antenna that generates a high
frequency electromagnetic field. Whereas the tag is usually a passive device (it does not have
a battery). It consists of a microchip that stores and processes information, and an antenna for
receiving and transmitting a signal.

Hardware Overview
The RC522 RFID module based on the MFRC522 IC  is one of the cheapest RFID options you can get
online for less than four dollars. It usually comes with an RFID card tag and a key fob tag with 1KB of
memory. And the best part is that it can write a tag that means you can store any message in it.
The RC522 RFID reader module is designed to create a 13.56MHz electromagnetic field and
communicate with RFID tags.The reader can communicate with a microcontroller over a 4-pin SPI
with a maximum data rate of 10 Mbps. It also supports communication over I2C and UART protocols.
The RC522 RFID module can be programmed to generate an interrupt, allowing the module to alert
us when a tag approaches it, instead of constantly asking the module.
The module’s operating voltage ranges from 2.5 to 3.3V, but the good news is that the logic pins are
5-volt tolerant, so we can easily connect it to an Arduino or any 5V logic microcontroller without using
a logic level converter.
Technical Specifications
Frequency Range 13.56 MHz ISM Band

Host Interface SPI / I2C / UART

Operating Supply Voltage 2.5 V to 3.3 V

Max. Operating Current 13-26mA

Min. Current(Power down) 10µA

Logic Inputs 5V Tolerant

Read Range 5 cm
The RC522 module has a total of 8 pins that connect it to the outside world. The connections are as
follows:
VCC supplies power to the module. This can be anywhere from 2.5 to 3.3 volts. You can connect it to
the 3.3V output from your Arduino.
RST is an input for reset and power-down. When this pin goes low the module enters power-down
mode.
GND is the ground pin and needs to be connected to the GND pin on the Arduino.
IRQ is an interrupt pin that alerts the microcontroller when an RFID tag is in the vicinity.
MISO / SCL / Tx pin acts as master-in-slave-out when SPI interface is enabled.
MOSI (Master Out Slave In) is the SPI input to the RC522 module.
SCK (Serial Clock) accepts the clock pulses provided by the SPI bus master i.e. Arduino.
SS / SDA / Rx pin acts as a signal input when the SPI interface is enabled, as serial data when the I2C
interface is enabled and as a serial data input when the UART interface is enabled.
First connect the VCC pin on the module to 3.3V and the GND pin to ground on the Arduino. Pin RST
can be connected to any digital pin on the Arduino.

Now we are left with the pins that are used for SPI communication. Since RC522 modules require a lot
of data transfer, they will give the best performance when connected to the hardware SPI pins on the
microcontroller.

MOSI MISO SCK CS

Arduino Uno 11 12 13 10

Arduino Nano 11 12 13 10

Arduino
51 50 52 53
Mega
Source code :

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

#define SS_PIN 10
#define RST_PIN A5

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

MFRC522::MIFARE_Key key;

// Init array that will store new NUID


byte nuidPICC[4];

void setup() {
Serial.begin(9600);
SPI.begin(); // Init SPI bus
rfid.PCD_Init(); // Init MFRC522

for (byte i = 0; i < 6; i++) {


key.keyByte[i] = 0xFF;
}

void loop() {
// Look for new cards
if ( ! rfid.PICC_IsNewCardPresent())
return;

// Verify if the NUID has been readed


if ( ! rfid.PICC_ReadCardSerial())
return;

for (byte i = 0; i < 4; i++) {


nuidPICC[i] = rfid.uid.uidByte[i];
}

printHex(rfid.uid.uidByte, rfid.uid.size);
Serial.println();
rfid.PICC_HaltA();

rfid.PCD_StopCrypto1();
}

void printHex(byte *buffer, byte bufferSize) {


for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer[i] < 0x10 ? " 0" : " ");
Serial.print(buffer[i], HEX);
}
}

You might also like