Subscribe To Our List

We help electronics hobbyists to create projects related to Micro-controllers. Join our newsletter to get access to new projects first.
Email address
Secure and Spam free...

In this article, you are going to learn about RFID basics and RFID module interfacing with Arduino with the help of two examples. In the first example, we will simply read from the RFID Tag and in the second example, we will make the buzzer to beep if the correct tag will be shown.

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, birthday and some more information.

RFID Tags can be passive or active

A Passive tag has no battery and it uses the energy transmitted by the reader.

An Active tag contains 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, then 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

We will use two examples to explain the interfacing of RFID module with the Arduino. In the first example, we will simply read form the RFID tag and in the other example, we will beep the buzzer if the correct tag will be shown and will interface the LCD to print the result.

To interface the RFID module with the Arduino, you will required the following parts

  • MFRC 522 RFID Module
  • Arduino
  • 16 X 2 LCD
  • Buzzer
  • 10K potentiometer
  • 220 ohm resistor

Example 1

For the first example, connect the MFRC 522 module with the Arduino as shown in the figure below. The VCC of module should be connected to the 3.3V of Arduino.

The MFRC 522 module works with the Arduino using SPI communication. Download the library from here and add it to your library folder. After that, open the “Dumpinfo” from examples and upload it in your Arduino IDE.

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. Note the UID number, we are going to use it in the second example.

Example 2

Now we are going to beep the buzzer when the correct tag will be shown and we will display the result on the LCD. Follow the circuit diagram below and make the connections

To read more about LCD interfacing with Arduino, Follow this tutorial |Arduino LCD Tutorial

Code

Upload the below code in the Arduino IDE

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

constexpr uint8_t RST_PIN = 9;   
constexpr uint8_t SS_PIN = 10;   
LiquidCrystal lcd(7, 6, 5, 4, 3, 2); //Parameters: (rs, enable, d4, d5, d6, d7)

MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance
int buzzer_pin = 8;

void setup() {
  Serial.begin(9600);   // Initialize serial communications with the PC
  while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
  SPI.begin();      // Init SPI bus
  mfrc522.PCD_Init();   // Init MFRC522
  lcd.begin(16, 2);   // LCD screen
  pinMode(buzzer_pin, OUTPUT);
  }

void loop() {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Show your card ");
  // 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) == "29 B9 ED 23") //change here the UID of the card/cards that you want to give access
  {
    lcd.setCursor(0,1);
    lcd.print("Access Granted");
    digitalWrite(buzzer_pin, LOW);
    delay(3000);
  }
 
 else   
 {
    lcd.setCursor(0,1);
    lcd.print("Access Denied");
    digitalWrite(buzzer_pin, HIGH);
    delay(3000);
  }
}

Video

If you have any questions, then feel free to ask us in the comment section.

JOIN OUR NEWSLETTER
We help electronics hobbyists to create projects related to Micro-controllers. Join our newsletter to get access to new projects first.
We hate spam. Your email address will not be sold or shared with anyone else.

Leave a Reply

Your email address will not be published.

Subscribe To Our List

We help electronics hobbyists to create projects related to Micro-controllers. Join our newsletter to get access to new projects first.
Email address
Secure and Spam free...
Skip to toolbar