RFID RC522 Arduino Basic Code Tutorial

RFID Arduino

RFID RC522 Arduino Code Tutorial – RFID (Radio Frequency Identification) is a device that uses radio waves to identify a code or ID on certain devices without cables.

This RFID device consists of a tag (label) and a reader (reader). This tag contains the chip and antenna in it, and stores the ID number.

Each tag, one after another, has a different ID number. The reader contains an antenna and an ID tag reading system.

How can the reader read the ID from the tag, while the tag has no battery?

How RFID Work?

This working principle is the same as wireless charging on a smartphone. Antenna from Reader will generate and transmit radio waves within a certain distance.

When the tag approaches the beam emitted from the reader, the tag’s antenna receives radio waves and converts them into electrical voltage, which will turn on the chip.

When this chip is active, this chip will generate radio waves that contain ID data. when the reader reads the ID from the tag, the controller will work according to the program ordered.

For example, the parking system uses cards. When the card (tag) is brought close to the reader, the controller will instruct the motor at the gate to lift the entrance bar, so that we can enter the parking area.

One of the popular RFID Readers is the Arduino RFID-RC522. This RFID Reader uses the MFRC522 chip made by NXP Semiconductor. This chip has a direct contactless communication system with a frequency of 13.56 MHz.

To communicate with the controller, the RFID-RC522 has the following features:

  • Working voltage 2.5 – 3.3V
  • Supports ISO/IEC 14443 A/MIFARE and NTAG
  • Supports MF1xxS20, MF1xxS70 and MF1xxS50 encryption in Read/Write mode
  • Supports ISO/IEC 14443 A higher transfer speed communication up to 848 kBd
  • Support MFIN/MFOUT
  • I2C, SPI and Serial UART communication


Now let’s make this device able to read the ID from the tag. To make it, we use a library. If you don’t use libraries on Arduino, programming will be very long. Please download the following RFID-RC522 library:

Download RFID Library RC522

Enter it into your Arduino IDE by doing the following:

  • Open Arduino IDE
  • Click the Sketch menu > Include Library > Add .ZIP Library
  • Select the downloaded library, its name is rfid-master.zip
  • Click OK


Please use the wiring below:

RFID RC522 Arduino Basic Code Tutorial


The program below is a basic program to read the ID from the tag. You can use it as a development program for other programs such as turning on the lights using this ID tag. Please upload to Arduino:

#include <SPI.h> 
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); 
void setup() 

  Serial.println("Bring the RFID Tag (Can be a card or keychain) to the RFID reader");

void loop() 
   if ( ! mfrc522.PICC_IsNewCardPresent()) 
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  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));

After the program is uploaded, open the serial monitor. Bring one of the tags closer to the Arduino RC522 RFID, it will display the ID number of the tag.

For example I put a tag on the RFID RC552 Arduino and I found the ID of my tag is 5A 86 34 00.

Good luck. If this article is useful, you can share the article How to Read an RC522 RFID ID with Arduino Uno with others using the share button provided below this article.

Read more:
> TTP223 Capacitive Touch Sensor Switch
> Display Joystick Value to Processing Software
> Install SimulIDE On Ubuntu Using Terminal (tar.gz)
> TB6560 Stepper Motor Driver, how to use it?
> Download Fritzing 0.9.3b (64bit) exe for Windows
> Save float data to EEPROM STM32
> Control Servo Motor Using Serial Monitor

Similar Posts