กลับหน้าหลัก
views
Getting Started with Arduino and RFID RC522 Module
Last updated on

Getting Started with Arduino and RFID RC522 Module


Getting Started with Arduino and RFID RC522 Module

The RFID RC522 module operates at 13.56MHz and is commonly used with Arduino for card-based identification projects. This guide covers wiring, library installation, and basic code to read card UID values.

Required Components

  • Arduino UNO R3 with USB cable
  • RFID RC522 13.56MHz Module Card Reader
  • MB-102 Breadboard (830 points)
  • Jumper wires: Male-to-Male, Male-to-Female, Female-to-Female (20cm each, 40 pieces)
  • Power Adapter 9V 2A (for additional power supply)
All components laid out on a table including Arduino UNO, RC522 module, breadboard, and jumper wires

Wiring Diagram: RFID RC522 to Arduino UNO

The module uses SPI Interface via Arduino’s digital pins as shown below.

Arduino UNORFID RC522
3.3V3V3
GNDGND
Pin 9RST
Pin 10SDA
Pin 11MOSI
Pin 12MISO
Pin 13SCK
Wiring diagram showing connections between Arduino UNO and RFID RC522 with labeled pins and wire colors

Installing MFRC522 Library

  1. Open Arduino IDE
  2. Go to Sketch > Include Library > Manage Libraries
  3. Search for “MFRC522”
  4. Install the MFRC522 library by Github社区

After installation, the library will be available in Documents/Arduino/libraries folder.

Arduino Code to Read RFID Card UID

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN  9    // RST pin connected to pin 9
#define SS_PIN   10   // SDA pin connected to pin 10

MFRC522 rfid(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(115200);
  SPI.begin();
  rfid.PCD_Init();
  Serial.println("RFID RC522 Ready - Tap card on module");
}

void loop() {
  // Check for new card present
  if (!rfid.PICC_IsNewCardPresent()) {
    return;
  }

  // Read card data
  if (!rfid.PICC_ReadCardSerial()) {
    return;
  }

  // Display UID
  Serial.print("Card UID: ");
  for (byte i = 0; i < rfid.uid.size; i++) {
    Serial.print(rfid.uid.uidByte[i], HEX);
    Serial.print(" ");
  }
  Serial.println();

  // Halt reading
  rfid.PICC_HaltA();
}

Upload and Test Steps

  1. Open Serial Monitor in Arduino IDE
  2. Set Baud Rate to 115200
  3. Tap RFID card or tag on RC522 module
  4. View UID displayed in Serial Monitor
Serial Monitor window showing card UID values in hexadecimal format

Important Notes

  • Arduino’s 3.3V pin provides sufficient power for the RC522 module during testing. For extended use or multiple card operations, use a Power Adapter to supply Arduino
  • Each card has a unique UID value. You can use this UID to identify and authenticate different cards

Summary

The RFID RC522 module communicates via SPI Interface and requires the MFRC522 library. Wiring is straightforward with just 7 connections. Upload the code and tap any card on the module to read its UID immediately.

อยากทำโปรเจคแบบนี้?

รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน

If you need Arduino project service or urgent IoT development, see full service details on the home page

จ้างทำโปรเจคเลย

ความคิดเห็น

Verified user reviews

รีวิวและความคิดเห็นจากผู้ใช้จริง

ล็อกอินด้วยบัญชีบนเว็บนี้แล้วให้คะแนนหรือคอมเมนต์ได้เลย ระบบเก็บผ่าน Supabase ไม่ต้องใช้ GitHub แล้ว

กำลังโหลดรีวิว...