Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Voltaat Arduino Ultimate Kit
80 min
Share

RFID reader for safe pass gate

The RFID reader is a module that reads a unique number from a tag or a card when it comes near it. You can then use the scanned number to identify the card holder.

Project Video

Overview

In this tutorial, we will use the RFID reader to read the data from the tag and then print a message on your computer. We can use this project to open a gate so that only the person with the correct information on his tag can enter.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
RFID Kit
Get Item
Jumper Wires - Male to Male (40 Pack)
Get Item

Steps

Wiring it Up

It is important to note that the RFID reader module operates on 3.3V, not 5V, so we connected it with the 3.3V pin.

To set up the RFID reader in the correct way, follow the instructions below. The image demonstrates how to connect the wires between the RFID reader and the Arduino. Once the RFID reader and the Arduino are connected to each other, connect the Arduino to your computer using the USB cable.

 

Connections from the RFID reader to the Arduino:


 • RFID 3.3V pin → Arduino VCC (3.3V) pin


 • RFID RST pin → Arduino pin 9


 • RFID GND pin → Arduino GND pin


 • RFID IRQ pin → unconnected


 • RFID MISO pin → Arduino pin 12


 • RFID MOSI pin → Arduino pin 11


 • RFID SCK pin → Arduino pin 13


 • RFID SDA pin → Arduino pin 10

Coding


/*
 Voltaat learn (http://learn.voltaat.com)
 Link for full tutorial:
 RFID reader library:

 SPI library:It is included in the Arduino IDE by defulalt

 Tutorial: RFID reader for safe pass gate

 It is important to note that the RFID reader module operates on 3.3V not 5V,
 so we connected it with the 3.3V pin.

 Connections from the RFID reader to the Arduino:
 • RFID 3.3V pin → Arduino VCC (3.3V) pin
 • RFID RST pin → Arduino pin 9
 • RFID GND pin → Arduino GND pin
 • RFID IRQ pin → unconnected
 • RFID MISO pin → Arduino pin 12
 • RFID MOSI pin → Arduino pin 11
 • RFID SCK pin → Arduino pin 13
 • RFID SDA pin → Arduino pin 10

*/


//This library allows you to communicate with SPI devices
#include "SPI.h"
//This library allows you to use RFID reader
#include "MFRC522.h"

//Define RFID reader pins
#define SS_PIN 10
#define RST_PIN 9

//Create MFRC522 instance
MFRC522 mfrc522(SS_PIN, RST_PIN);



//Commands inside void setup run once
void setup()
{
 //Start the serial monitor at 9600 baud rate (9600 bits per second)
 Serial.begin(9600);
 //Initialize spi connection
 SPI.begin();
 //Initiate MFRC522
 mfrc522.PCD_Init();
 //Print to serial monitor
 Serial.println("Approximate your card to the reader...");
 Serial.println();

}

//Commands inside void loop run forever
void loop()
{
 //Look for new cards
 if ( ! mfrc522.PICC_IsNewCardPresent())
 {
   return;
 }

 //Select one of the cards
 if ( ! mfrc522.PICC_ReadCardSerial())
 {
   return;
 }

 //Print to 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();
 //Make sure you change this with your own UID number
 if (content.substring(1) == "8A 21 EC 81")
 {
   //Print to serial monitor
   Serial.println("Authorised access, The gate will open");
   Serial.println();
   //Delay for 3 sec
   delay(3000);
 }

 else   {
   //Print to serial monitor
   Serial.println("Access denied, Please try again");
   //Delay for 3 sec
   delay(3000);
 }
}

Testing it Out

You should also make sure you have chosen the right baud rate (9600) as specified in the code.
know when your plant needs watering

Now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

know when your plant needs watering

Now, as we see in the following image, the serial monitor will print a message that asks you to approximate the tag from the RFID.

know when your plant needs watering

When you scan the correct tag with the RFID reader, a message with the allowed access will be printed.

know when your plant needs watering

If you use another different tag that is not defined in the code, it will print an access denied message.

know when your plant needs watering

Resources

No items found.