RFID reader for safe pass gate 🔐
Have you used an access card before to enter a building or a parking space where you tap your card to pass through? The technology that is used to make this happen is called RFID.
This tutorial will show you how you can use the RFID module with the Arduino.
Overview
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.
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
For this project you will need the following components, you can buy them from our store.
Wiring it up
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.

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
Coding
The purpose of this sketch is to read the tag ID using an RFID reader and compare it to the one stored on the code. If the ID is correct, it will print a message on your computer indicating that you have security access; otherwise, it will display an access denied message.
In order for the code to work correctly, you need to download the sensor library. Libraries are files that you can download and copy to the Arduino IDE software files so the Arduino can recognize different sensors. You can download the library files from the resources section and then install it by following this tutorial.
After adding the MFRC522 library to your Arduino IDE, you will need to know the tag ID so that you can use it on your code. There is now an existing example in the Arduino IDE that will allow you to achieve that, just follow the coming steps!
Open File menu→ MFRC522→DumpInfo

And then upload this sketch to your Arduino board!
After that, open the serial monitor from your Arduino IDE, A message that asks you to scan the tag with the RFID reader will appear, and now it will read the tag ID and print it directly to your computer as in the image below.
Note: make sure to choose the right baud rate (9600).

Just copy the card UID. We will need to include it in the next code.
/*
Voltaat learn (https://www.voltaat.com/pages/voltaat-learn)
Link for full tutorial: https://bit.ly/3ESFIDD
RFID reader library: https://bit.ly/3S9q9KN
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

Now you must have correctly wired the RFID reader to the Arduino as we explained in the wiring section, as well as uploaded the code to your Arduino board.
You may now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

The serial monitor is a great tool that can facilitate communication between the computer and the Arduino. It can allow us to send and receive different commands as well as view information directly from the Arduino.
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.

You should also make sure you have chosen the right baud rate (9600) as specified in the code.
When you scan the correct tag with the RFID reader, a message with the allowed access will be printed.

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

Related Tutorials
In your daily life, you deal with many devices that have an LCD display. These LCDs help the user to interact with these devices and use them more easily.
There are various types of motion sensors, each of which varies according to the ring and sensitivity. PIR sensors are commonly used in security systems since they may trigger an alert when someone enters a room.
A servo motor is just a simple DC motor with certain modifications. When you look at it, you'll notice that it has several gears and an electronic circuit.