RFID RadioFrequencyIdentification

Z2M Part: EMC-00005-A

Read RFID cards using MFRC522 (RC522) module.

Circuit Diagram
Circuit diagram for RFID RadioFrequencyIdentification
Wire Connections & Pin Configuration

Wire Color Connections:

Yellow/Orange → Pins 9–13 to RC522 RST, SDA, MOSI, MISO, SCK
Red → 3.3V to RC522 VCC
Black → GND to RC522 GND

Pin Configuration:

Arduino Digital Pin 9 → RC522 RST
Arduino Digital Pin 10 → RC522 SDA
Arduino Digital Pin 11 → RC522 MOSI
Arduino Digital Pin 12 → RC522 MISO
Arduino Digital Pin 13 → RC522 SCK
Arduino 3.3V → RC522 VCC
Arduino GND → RC522 GND
Arduino Code
Edit
#include <SPI.h>
#include <MFRC522.h>

// Set pin numbers for SDA (SS) and RST of RFID module
#define SDA_PIN 10
#define RST_PIN 9

MFRC522 mfrc522(SDA_PIN, RST_PIN); // Create MFRC522 instance

void setup() {
  // Initialize serial communication, SPI bus, and MFRC522 module
  Serial.begin(9600);
  while (!Serial); // Wait for Serial (for boards that need it)
  SPI.begin();
  mfrc522.PCD_Init();
  Serial.println(\"Scan a card near the reader...\");
  Serial.println();
}

void loop() {
  // Look for new cards
  if (!mfrc522.PICC_IsNewCardPresent()) {
    return;
  }

  // Select one of the cards
  if (!mfrc522.PICC_ReadCardSerial()) {
    return;
  }

  // Show UID on Serial Monitor
  Serial.print(\"UID tag :\");
  String content = \"\";
  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));
  }
  Serial.println();
  Serial.print(\"Message : \");
  content.toUpperCase();
  Serial.println(content);

  // Check authorized UID(s) - change the string below to match your card's UID
  if (content.substring(1) == \"8D 97 E7 2B\") {
    Serial.println(\"Authorized access\");
    Serial.println();
    delay(3000);
  } else {
    Serial.println(\"Access denied\");
    delay(3000);
  }

  // Halt PICC (optional) and stop encryption on PCD
  mfrc522.PICC_HaltA();
  mfrc522.PCD_StopCrypto1();
}

Instruction Details

Wiring: Connect RC522 SDA to Digital Pin 10, RST to Pin 9. Connect SCK to 13, MOSI to 11, MISO to 12 (SPI). Connect VCC to 3.3V and GND to GND.
Library: Sketch → Include Library → Manage Libraries → search "MFRC522" → Install.
Upload Code: Tools → Board → Arduino Uno. Tools → Port → select your COM port. Click Upload button.
View Output: Open Serial Monitor (Tools → Serial Monitor) at 9600 baud. Scan RFID card/tag to see UID. Authorized/denied message displays.

How to Use

  1. Connect the required components as per the Pin Configuration above
  2. Open Arduino IDE and create a new sketch
  3. Copy and paste the code above
  4. Select your Arduino board and COM port from Tools menu
  5. Click the Upload button to upload the code to your Arduino
  6. Open Serial Monitor (if applicable) to see the output

Components Required

  • Arduino Uno
  • MFRC522 RC522 RFID Reader Module
  • RFID Cards or Tags
  • Breadboard
  • Jumper Wires

Category: Communication