Relevant MFRC522 RFID Reader Arduino Code

RFID (Radio Frequency Identification) technology has become increasingly popular in various industries. MFRC522 is a widely used RFID reader module that allows communication with RFID cards or tags. In this blog post, we will explore how to use the MFRC522 RFID reader with an Arduino board and present you with a relevant code sample.

The Basics of RFID Technology

RFID technology utilizes electromagnetic fields to wirelessly transfer data between an RFID reader and a nearby RFID tag or card. The MFRC522 reader module, based on the MFRC522 chip, provides an easy-to-use interface for Arduino and other microcontrollers to interact with RFID tags.

Hardware Setup

To get started with the MFRC522 RFID reader, you will need the following hardware:

  • Arduino board
  • MFRC522 RFID reader module
  • Jumper wires

Connect the MFRC522 module to your Arduino board following the wiring diagram provided in the MFRC522 datasheet or the module's documentation.

Installing the Required Libraries

In order to use the MFRC522 reader module, you will need to install the appropriate Arduino libraries. These libraries provide simplified functions to interact with the module.

Here are the steps to install the required libraries:

  1. Open the Arduino IDE.
  2. Navigate to "Sketch" -> "Include Library" -> "Manage Libraries".
  3. In the Library Manager, search for "MFRC522" and click "Install" next to the correct library.
  4. Once the installation is complete, close the Library Manager.

Writing the Arduino Code

With the necessary hardware setup and libraries installed, we can now proceed to write the Arduino code to interact with the MFRC522 RFID reader. Below is a sample code snippet that demonstrates reading RFID card data:

// Include the necessary libraries

// Define the pin connections
#define SS_PIN 10
#define RST_PIN 9

// Create an instance of the MFRC522 reader class
MFRC522 mfrc522(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600); // Initialize serial communication

  SPI.begin(); // Initialize SPI bus
  mfrc522.PCD_Init(); // Initialize MFRC522 RFID reader

  Serial.println("Ready to read RFID cards");

void loop() {
  // Check if a new RFID card is present
  if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) {
    // Read the card's UID (a unique identifier)
    String uid = "";
    for (byte i = 0; i < mfrc522.uid.size; i++) {
      uid.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : ""));
      uid.concat(String(mfrc522.uid.uidByte[i], HEX));

    // Print the UID to the serial monitor
    Serial.print("UID: ");
    mfrc522.PICC_HaltA(); // Halt PICC communication

Explanation of the Code

The provided Arduino code begins by including the necessary libraries, namely SPI and MFRC522. It then defines the required pin connections for the MFRC522 module.

In the setup function, the serial communication is initialized, and the SPI bus and MFRC522 reader are set up.

The loop function continuously checks if a new RFID card is present. If a card is detected, it reads the card's UID and prints it to the serial monitor. The PICC_HaltA() function is called to halt the communication with the card.


In this blog post, we introduced the MFRC522 RFID reader module and explained how to use it with an Arduino board. We provided a relevant code sample that demonstrates reading RFID card data using the MFRC522 library. RFID technology has a wide range of applications, and understanding how to utilize RFID readers can be valuable in various projects and industries.

Handheld Computers

Portable and handheld for multi-domain applications.

Basic Functions, Better Performance

Android 12

Dual SIM card slots


2.4G/5G WiFi 802.11ax Wi-Fi6

Bluetooth 5.1 +BLE

4GB+64GB 6GB+128GB 8GB+256GB (Optional)

MediaTek Dimensity 900

LCD 6-inch IPS

QR / bar code scanner(optional)

Corning GG3 reinforced glass cover

NFC, Magnetic(optional)

Finger Print

B2B Wholesale Kingtop Enterprise PDA

·Powerful, Durable and Enterprise-Ready
·Seamless Device and Data Management
·Rugged and Powerful Handheld Computer for Business
·Cost-Saving Bulk Deals for Large Volume Purchases

Why Choose Us?

We’re here to help tailor our comprehensive business solutions to your specific needs.

5G Fast Connectivity

Our tablet devices are equipped with advanced 5G modules that support various network bands and protocols, which allows you to enjoy fast and stable internet access anytime and anywhere.

Rich Production Experience

We have been focusing on the production of intelligent mobile devices for 15 years, and we have a deep understanding of the industry trends and customer needs. We can provide you with high-quality products that meet your expectations and requirements.

Trouble Shooting

We have a professional and responsive customer service team that can solve any problems you encounter within 24 hours. You can also contact our engineers directly for technical support and guidance.


We can customize your tablet devices according to your specifications and preferences. You can choose the size, color, logo, software, hardware and accessories of your tablet devices. We will offer you the best solution that suits your budget and needs.

Prouduct Selection

We have a wide range of tablet devices for you to choose from, with different features, functions and prices. Our professional sales team will recommend the most suitable and cost-effective products for you based on your needs and preferences.


We have a professional R&D and design team that can develop innovative and unique tablet devices for you. We have 15 years of experience in software and hardware development, and we can create solutions that satisfy your customers and the market.Don’t miss this opportunity to get the best 5G tablet device for your business or personal use. Contact us today and get a free quote and sample!

Which PDA is right for you?

Powerful device management tools.

Talk to us >        SAMPLE TEST >


4G LTE / 5G

2.2 Gigabit Carrier Speed




5mp front, 13mp rear


Removable 4000mAh battery


Android™12.0 System

Full specs→


4G LTE / 5G

2.2 Gigabit Carrier Speed




8mp front, 48mp rear


Removable 5000mAh battery


Android™11.0 System

Full specs→



1Gigabit Carrier Speed




5mp front, 13mp rear


Removable 5000mAh battery


Android™11.0 System

Full specs→