In this post we will go over how to use the RC522 RFID Module with Arduino. We’ll focus on basics, module pins, how to connect to Arduino, programming in Arduino IDE, and testing. The main focus will be around reading an RFID tag’s UID (Unique ID).
What is RFID?
RFID stands for “Radio-frequency identification” and its use consists mainly of two components: the RFID tag or tags (which contains some information) and the RDIF reader (which reads the information). Normally, the tag is not powered, while the reader is powered (i.e. battery).

RC522 RFID Module
As mentioned earlier, an RFID system contains an RFID reader. The RC522 is a simple and low cost option for DIY projects. The RC522 supports I2C, SPI, and UART communication.
Module Specs:
Read Distance Range: Min: Direct contact, Max: ~2in (50mm)
Input Voltage: 2.5V – 3.3V (Make sure to NOT connect to the 5V pin of the Arduino)
Current: 13mA – 26mA
Working Frequency: 13.56 MHz
RC522 Module Pins
SDA – Used as SDA for I2C communication.
SCK – Serial Clock.
MOSI – SPI communication pin (Master Out Slave In).
MISO – SPI communication pin (Master In Slave Out).
IRQ – Interrupt Pin to wake up the Arduino when an RFID tag is read.
GND – Ground pin that must be connected to Arduino ground.
RST – Reset pin to reset or power down the RC522 module.
3.3V – Power input pin (please don’t connect to 5V).
Downloading the RFID Arduino Library for RC522
This example requires use of the Arduino RC522 RFID Library from Miguel Balboa. You can download the library from GitHub on this link: github.com/miguelbalboa/rfid

Installing the library
Once the Zip library has been downloaded, you need to import it within the Arduino IDE. To do this, go to the top menu, then click Sketch, Include Library, Add .Zip Library… Then, find the Zip file in the folder in which you downloaded it to, then select the Zip file and click open to import into Arduino IDE.
Arduino Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
//Arduino Code - RC522 Read RFID Tag UID #include <SPI.h> #include <MFRC522.h> #define SS_PIN 10 #define RST_PIN 7 MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class MFRC522::MIFARE_Key key; void setup() { Serial.begin(9600); SPI.begin(); // Init SPI bus rfid.PCD_Init(); // Init RC522 } void loop() { // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle. if ( ! rfid.PICC_IsNewCardPresent()) return; // Verify if the NUID has been readed if ( ! rfid.PICC_ReadCardSerial()) return; MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak); Serial.print(F("RFID Tag UID:")); printHex(rfid.uid.uidByte, rfid.uid.size); Serial.println(""); rfid.PICC_HaltA(); // Halt PICC } //Routine to dump a byte array as hex values to Serial. void printHex(byte *buffer, byte bufferSize) { for (byte i = 0; i < bufferSize; i++) { Serial.print(buffer[i] < 0x10 ? " 0" : " "); Serial.print(buffer[i], HEX); } } |
Run Arduino Code – Testing RFID Arduino Reader


Components used in this example
*As an Amazon & Ebay Associate I earn from qualifying purchases.
Component | Link |
Arduino UNO | https://amzn.to/3uYVAMC https://ebay.us/veZdKX |
RC522 RFID Reader Kit | https://amzn.to/3mT5YD1 https://ebay.us/CmJGs8 |
Excellent, thank you a lot for the code man
I really appreciate…
Have you been successful in using the IRQ pin to wake the arduino when a tag is presented?
Worked for me, thanks!
do you know, how card is sense by the mfrc522? , is there any command for that?