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

Pass Through Secure Gate with RFID Reader

The RFID reader module reads a unique number from a tag or a card when it’s close by, enabling identification of the cardholder.

Project Video

Overview

In this tutorial, you will learn how to use the RFID reader with Arduino to read the card data and display it on your computer, indicating if access is permitted or denied.

Getting the Items

No items found.

Steps

Wiring it Up

It's important to be aware that the RFID reader module runs on 3.3V, not 5V. Therefore, it should be connected to the 3.3V pin.

Connect the wires between the RFID reader and the Arduino as shown in the image below.



 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: Tap and Go: Pass Through Secure Gate with RFID Reader

 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);

//Authorized UID variable
String authorizedUID = "8A 21 EC 81"; // Change this to your own authorized UID

//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();

 //Compare with authorized UID
 if (content.substring(1) == authorizedUID)
 {
   //Print to serial monitor
   Serial.println("Authorized 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

know when your plant needs watering

Once you’ve connected the RFID reader to the Arduino and uploaded the code, open the serial monitor by clicking on its icon.

know when your plant needs watering

The serial monitor will ask you to scan the card using the RFID reader.

know when your plant needs watering

When you scan the correct card with the RFID reader, it will display a message with allowed access.

know when your plant needs watering

If you use a different card that is not defined in the code, it will display an access denied message.

know when your plant needs watering

Resources

No items found.