Arduino Projects

Arduino MFRC522 RFID module Pinout, Interfacing, & how to read RFID

Arduino MFRC522 RFID Module, Overview:

Arduino MFRC522 RFID Module Pinout, Interfacing, and how to Read RFID TagsMFRC522 RFID Module is no doubt an amazing and most commonly used RFID reader. I have used it in so many intermediate and advanced level projects e.g. “RFID Bike Anti-theft control System”, “Talking RFID System for Sports Bike”, “Students Attendance System with Firebase Database”, “RFID and IoT, Remote Door Lock Access”, “RFID Servo Control”, RFID and Raspberry Pi based Home Automation”,  “RFID and GSM based Attendance System”, and so many other RFID based projects which you can check out by simply typing RFID in search box.

Today, I am writing this article especially for the beginners, although I have used the MFRC522 RFID module with Arduino and Nodemcu ESP8266, but still people ask me about the most basic things, which I believe I should have explained. But anyways, today, I will explain the very basic things that will help you to easily get started with the Arduino and MFRC522 RFID Module.

In this article, I will explain, the MFRC522 Pinout, how to Interface the MFRC522 with the Arduino? How to read the RFID Tags? And then how to use those RFID tags to perform specific tasks by the Arduino?

Without any further delay, let’s get started!!!


 

Amazon Links:

Arduino Nano USB-C Type (Recommended)

12v Adaptor:

MFRC522 RFID module with tags:

Other Tools and Components:

ESP32 WiFi + Bluetooth Module (Recommended)

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

RFID MFRC522 Pinout:

Arduino MFRC522

This is the MFRC522 RFID module that we will be using with the Arduino Uno. RFID Means Radio frequency identification. RFID uses electromagnetic fields to transfer data over short distances. You can use an RFID system to open a door, It can be used to make a student attendance system, It can be used to control a machine; it can be used in cars and bikes for Anti-theft protection. Some of the projects links I have already shared above.

The first pin is the vcc and this will be connected with 3.3v of the Arduino.

Pin number 2 is the RST or reset.

Pin number 3 is the ground.

While the MISO pin, MOSI PIN, SCK pin and the SS or SDA pin, these four pins are the SPI pins and will be connected with the Arduino SPI pins.

In Arduino the SPI pins are,

Arduino MFRC522

Pin number 13 is the SCK

Pin number 12 is the MISO

Pin number 11 is the MOSI and

Pin number 10 is the SS or SDA.



 

What is SPI?

SPI stands for “Serial Peripheral Interface”. It is a synchronous serial data bus, data can travel in both directions at the same time, as opposed to (for example) the I2C bus that cannot do so. To allow synchronous data transmission, the SPI bus uses four wires. They are called:

MOSI: Master-out, Slave-in. This line carries data from our Arduino to the SPI-controlled device(s);

MISO: Master-in, Slave out. This line carries data from the SPI-controlled device(s) back to the Arduino;

SS: Slave-select. This line tells the device on the bus we wish to communicate with it. Each SPI device needs a unique SS line back to the Arduino;

SCK: Serial clock.

While the last pin IRQ is not used.

MFRC522 Arduino Wiring, Circuit Diagram:

Arduino MFRC522

 

The interfacing is really easy, as this module has male header pin’s, so we can use male to female type jumper wires to connect this RFID module with Arduino.

First of all, connect the VCC of the MFRC 522 RFID module with 3.3v of the Arduino

Now connect the reset pin of the MFRC 522 RFID module with pin 9 of the Arduino

Now connect the Ground pin of the MFRC 522 RFID module with the ground of the Arduino

Now connect the MISO pin of the MFRC 522 RFID module with pin 12 of the Arduino

Now connect the MOSI pin of the MFRC 522 RFID module with pin 11 of the Arduino

Now connect the SCK pin of the MFRC 522 RFID module with pin 13 of the Arduino

And now finally connect the SS or SDA pin of the MFRC 522 RFID module with pin 10 of the Arduino. So that’s all about the interfacing.


 

How to Read RFID Tags?

Arduino MFRC522

Usually the MFRC522 RFID Reader comes with two RFID Key chains and one white color RFID Card. The RFID Number or the Identity number is not printed on the key chains and RFID cards, so this is the reason majority of the beginners get confused.  Before you can use your RFID key chains and RFID cards to mark attendance or control something, first, you will need to find the identity numbers of the RFID key chains and RFID Cards using a simple Arduino sketch. While your Arduino is connected with the MFRC522 RFID Module as per the circuit connections explained above. Connect your Arduino with the Laptop or Computer through a USB cable and upload the code given below.

Arduino MFRC522 Code:

The purpose of this program is to find the Identity numbers of the RFID key chains and RFID cards. So, after you have uploaded the program. Open the Serial Monitor, select any RFID Tag and bring it near the RFID Module.

Arduino MFRC522

As you can see it successfully read the RFID CARD. I also tested the key chain.

Card identity: 192 47 254 121

Key chain: 00 47 115 137

Now, I have these two Identity numbers which I can use in MFRC522 Arduino codes to control different things. As this is a basic tutorial, so I am not going to make it complicated. Next, I am planning to use both the RFID identity numbers to print some text on the Serial Monitor. Let’s just do it. One more thing, the hardware connections remains exactly the same. You don’t need to change anything. The changes are only on the code side.


MFRC522 RFID Arduino Code:


Arduino MFRC522 Code Explanation:

The purpose of this Arduino MFRC522 Code is to print two text messages on the Serial monitor, when the card is detected, it prints “Card Detected” and when the key chain is detected then it prints “Key chain”

if( (mfrc522.uid.uidByte[0] == 192) && (mfrc522.uid.uidByte[1] == 47) && (mfrc522.uid.uidByte[2] == 254) && (mfrc522.uid.uidByte[3] == 121) )

{

Serial.println(“Card detected”);

}

else

if( (mfrc522.uid.uidByte[0] == 00) && (mfrc522.uid.uidByte[1] == 47) && (mfrc522.uid.uidByte[2] == 115) && (mfrc522.uid.uidByte[3] == 137) )

{

Serial.println(“Key chain”);

}

You can clearly see how these two identity numbers are used. You can replace these RFID identity numbers with yours. Anyways, I uploaded the code above and I successfully detected with the RFID Tags.

Arduino MFRC522

Then I tested my RFID Key Chain Tag

Arduino MFRC522

I printed messages on the Serial monitor, but you can modify the code to control the Onboard LED. You can simply turn ON and turn OFF the LED using your RFID tags. So, that’s all for now. If you have any questions, let me know in a comment.

 

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button