what is the RFID module and how an RFID module works with Arduino

Hello, welcome to another valuable article brought to you by SriTu Hobby. Today we are going to talk about what is RFID module and how an RFID module works with Arduino. We can see this technique in various places. Examples include identifying people in factories, controlling admissions, searching books in libraries, obtaining employee attendance, and security systems. Also, you can use this technology to create security systems and door lock systems.
What is RFID technology?
RFID is simply called Radio Frequency Identification. That is, to identify radio frequencies. Also, the RFID module is designed using this technology. Different types of RFID modules are given below.

These RFID modules consist of two main parts.
RFID tag
RFID reader
How to work the RFID module
We first talked about how this RFID technology works according to radio frequencies. This RFID reader includes a radio frequency module. Also, the antenna coil included here produces a high-frequency electromagnetic field. This RFID tag is made up of an antenna and an electronic microchip. This electronic microchip in the RFID Tag produces a voltage in the antenna coil of the RFID Reader due to the induction of the electromagnetic field generated when it is placed near an RFID Reader. For this reason, an RFID Reader can detect an RFID Tag. I have used the following RFID module for this project.
This RFID tag uses the MIFARE protocol and has 1kb of memory, along with a microchip for logical operations. It operates at a frequency of 13.56 MHz and can be read from a distance of up to 10cm, although this range can vary based on the RFID tag’s antenna. The RFID Reader includes an IC named MFRC522 and communicates with the Arduino board using the SPI protocol.
PIN structure of this RFID module

OK, let’s learn how to connect the RFID module to the Arduino step by step. For that, the required components are given below.
- Arduino Nano board x 1 — Our Store / Amazon
- RFID module x 1 — Our Store / Amazon
- LED x 2 — Our Store / Amazon
- Buzzer x 1 — Our Store / Amazon
- 180-ohm resistor x 1 —Our Store / Amazon
- Jumper wires — Our Store / Amazon
- Breadboard — Our Store / Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.
Arduino Nano board
RFID module
LED bulb
Buzzer
180-ohm resistor
Jumper wires
Breadboard
Step 2
Secondly, connect these components. To do this, use the circuit diagram below.
Step 3
Thirdly, let’s scan the UIDs related to the RFID tags. To do this, use the program below.
- MFRC522 library — Download
/*RFID tag scan code
* https://srituhobby.com
*/
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 9
#define SS_PIN 10
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() {
Serial.begin(9600);
while (!Serial);
SPI.begin();
mfrc522.PCD_Init();
delay(4);
mfrc522.PCD_DumpVersionToSerial();
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
Code explanation
Firstly, the SPI bus and MFRC522 libraries are included.
#include <SPI.h>
#include <MFRC522.h>
Secondly, the RST and SDA pins are defined.
#define RST_PIN 9
#define SS_PIN 10
Next, an object is created for this library. Also, it includes the PINs above.
MFRC522 mfrc522(SS_PIN, RST_PIN);
In the setup function, the serial monitor, SPI bus, and RFID library are started. Also, RFID tags information is printed on the serial monitor.
void setup() {
Serial.begin(9600);
while (!Serial);
SPI.begin();
mfrc522.PCD_Init();
delay(4);
mfrc522.PCD_DumpVersionToSerial();
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}
The loop function includes RFID tag read codes.
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
Step 4
OK, now select board and port. Afterward, upload this code to the Arduino board.



Step 5
Next, run your serial monitor and place your RFID tags one by one on the RFID reader. I have used two RFID tags. Next, copy these RFID tag UIDs to another location. These are required for the next program.



Step 6
Now let’s create the main program for this project. It is as follows.
- The complete program of this project – Download
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
#define Buzzer 2
#define LED1 3
#define LED2 4
MFRC522 rfid(SS_PIN, RST_PIN);
byte led1 = 0;
byte led2 = 0;
void setup() {
Serial.begin(9600);
Serial.println("Please put your card..");
SPI.begin();
rfid.PCD_Init();
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(Buzzer, OUTPUT);
}
void loop() {
if ( ! rfid.PICC_IsNewCardPresent())
return;
if ( ! rfid.PICC_ReadCardSerial())
return;
Serial.print("NUID tag is :");
tone(Buzzer, 700);
delay(200);
noTone(Buzzer);
String ID = "";
for (byte i = 0; i < rfid.uid.size; i++) {
Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(rfid.uid.uidByte[i], HEX);
ID.concat(String(rfid.uid.uidByte[i] < 0x10 ? " 0" : " "));
ID.concat(String(rfid.uid.uidByte[i], HEX));
delay(300);
}
Serial.println();
ID.toUpperCase();
if (ID.substring(1) == "" && led1 == 0 ) {
digitalWrite(LED1, HIGH);
Serial.println("LED1 is ON..");
led1 = 1;
} else if (ID.substring(1) == "" && led1 == 1 ) {
digitalWrite(LED1, LOW);
Serial.println("LED1 is OFF..");
led1 = 0;
} else if (ID.substring(1) == "" && led2 == 0 ) {
digitalWrite(LED2, HIGH);
Serial.println("LED2 is ON..");
led2 = 1;
} else if (ID.substring(1) == "" && led2 == 1 ) {
digitalWrite(LED2, LOW);
Serial.println("LED2 is OFF..");
led2 = 0;
} else {
Serial.print("Wrong card!Please put correct card!");
}
}
Code explanation
Firstly, includes the SPI Bus Library and the MFRC 522 Library. Also, RST, SDA, Buzzer, and LED pins are defined.
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
#define Buzzer 2
#define LED1 3
#define LED2 4
Secondly, an object is created for this library. Also, it includes RST and SDA PINs.
MFRC522 mfrc522(SS_PIN, RST_PIN);
In the setup function, the serial monitor, SPI bus, and RFID library are started. Also, the LED and buzzer pins are set as OUTPUT pins.
void setup() {
Serial.begin(9600);
Serial.println("Please put your card..");
SPI.begin();
rfid.PCD_Init();
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(Buzzer, OUTPUT);
}
In loop functions, the main code of this project is included. The first part of this code reads the RFID tag. Then, these RFID tag UIDs are inserted into a string variable.
if ( ! rfid.PICC_IsNewCardPresent())
return;
if ( ! rfid.PICC_ReadCardSerial())
return;
Serial.print("NUID tag is :");
tone(Buzzer, 700);
delay(200);
noTone(Buzzer);
String ID = "";
for (byte i = 0; i < rfid.uid.size; i++) {
Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(rfid.uid.uidByte[i], HEX);
ID.concat(String(rfid.uid.uidByte[i] < 0x10 ? " 0" : " "));
ID.concat(String(rfid.uid.uidByte[i], HEX));
delay(300);
}
Serial.println();
ID.toUpperCase();
Next, the second part of this code tests this UID using the IF condition. Also, we need to paste the previously copied RFID tag UIDs into this code. For that, use your RFID tag UIDs.
if (ID.substring(1) == "15 75 FE 28" && led1 == 0 ) {
digitalWrite(LED1, HIGH);
Serial.println("LED1 is ON..");
led1 = 1;
} else if (ID.substring(1) == "15 75 FE 28" && led1 == 1 ) {
digitalWrite(LED1, LOW);
Serial.println("LED1 is OFF..");
led1 = 0;
} else if (ID.substring(1) == "2A A5 E9 81" && led2 == 0 ) {
digitalWrite(LED2, HIGH);
Serial.println("LED2 is ON..");
led2 = 1;
} else if (ID.substring(1) == "2A A5 E9 81" && led2 == 1 ) {
digitalWrite(LED2, LOW);
Serial.println("LED2 is OFF..");
led2 = 0;
} else {
Serial.print("Wrong card!Please put correct card!");
}
Step 7
Lastly, select the board and port, After, upload this code to the Arduino board.



OK, enjoy this tutorial. The full video guide is given below. So, we will meet in the next tutorial. Have a good day.
what is the RFID module and how an RFID module works with Arduino