MyRoboPathOpen Robotics Lab
Arduino Uno #9 of 35
Est. 1 Hours
Budget: $4 - $7
Intermediate

MFRC522 13.56MHz RFID Reader & Access Control

Read contactless 13.56MHz MIFARE cards and key fobs over hardware SPI to build a UID-verified access controller.

Explore contactless radio-frequency identification with the MFRC522 reader module. Wire the 3.3V SPI bus carefully to Arduino Uno, inspect unique card UIDs in hexadecimal, authorize trusted tags in firmware, and drive Granted/Denied status indicators.

Arduino Uno R3MFRC522 RFIDSPI Bus (D10-D13)3.3V Logic SafetyAccess Control
MFRC522 13.56MHz RFID Reader & Access Control Blueprint
MFRC522 13.56MHz RFID Reader & Access ControlCAD Blueprint

Key Learning Objectives & Robotics Concepts

By building and programming this project, you will master the following core engineering skills:

1Wire a 4-wire hardware SPI peripheral (MOSI, MISO, SCK, SS) plus RST on Arduino Uno.
2Respect 3.3V voltage rail limits to protect sensitive RF integrated circuits.
3Extract 4-byte or 7-byte Unique Identifiers (UIDs) from MIFARE Classic cards.
4Implement a UID whitelist comparator that triggers access granted/denied actions.

Power Architecture & Voltage Staging

5V / 3.3V Regulated Power

The MFRC522 operates strictly at 3.3V DC (drawing up to 26mA during 13.56MHz antenna excitation). Connect VCC exclusively to the Arduino Uno 3.3V pin—never 5V. CRITICAL: Power MFRC522 strictly from 3.3V—connecting VCC to 5V permanently destroys the RF transceiver IC!

MFRC522 13.56MHz RFID Reader & Access Control Power Architecture Schematic
Figure: Regulated Arduino Uno supply rails, current budget, and component protection.Power Schematic

Bill of Materials (BOM) & Hardware Components

Bill of Materials for MFRC522 13.56MHz RFID Reader & Access Control
ComponentSpecifications & AlternativeQtyApprox Cost
Arduino Uno R3ATmega328P hardware SPI controller1$8.00
MFRC522 RFID Reader Module + Tags13.56MHz ISO14443A SPI module + card & keyfob1$3.50
Green & Red 5mm LEDs + 220Ω ResistorsAccess Granted / Denied visual indicators2$0.30
Breadboard & Jumper Wires10× Male-to-Female / Male-to-Male jumpers1$2.00

Electrical & System Architecture

Wire RC522 VCC to 3.3V, GND to GND, RST to D9, SDA(SS) to D10, MOSI to D11, MISO to D12, and SCK to D13. Optional Green/Red status LEDs connect to D6 and D7 via 220Ω resistors.

Figure: Complete Arduino Uno R3 pin-to-pin wiring schematic for MFRC522 13.56MHz RFID Reader & Access Control.
Figure: Complete Arduino Uno R3 pin-to-pin wiring schematic for MFRC522 13.56MHz RFID Reader & Access Control.Wiring Schematic

Autonomous Behavior & Finite State Machine (FSM)

Deterministic Arduino loop handling RC522 13.56MHz SPI RFID Reader + Cards acquisition, filtering, and real-time output updates.

Figure: Firmware execution flow and state transitions for MFRC522 13.56MHz RFID Reader & Access Control.
Figure: Firmware execution flow and state transitions for MFRC522 13.56MHz RFID Reader & Access Control.Control Algorithm

Step-by-Step Physical Assembly & Wiring Tutorial

Follow each of the 5 sequential milestone stages with technical photos, wiring checks, and pre-flight tests.

1

Double-Check 3.3V Power Pin First

Duration: 5 Mins

Verify the 3.3V header on the Arduino Uno before wiring anything to the RC522 module.

MFRC522 13.56MHz RFID Reader & Access Control hardware layout diagram
Stage 1: RC522 13.56MHz SPI RFID Reader + Cards hardware inspection & pinout overview.Stage 1 Diagram
Step Action Checklist:
  • Solder header pins cleanly onto the RC522 PCB if they came loose.
  • Locate the 3.3V pin on Arduino Uno (next to RESET and 5V).
  • Never connect RC522 VCC to the 5V pin.
Engineering & Tuning Tip: Using a yellow or orange wire for 3.3V (instead of red) is a great lab habit to distinguish 3.3V from 5V.
2

Wire SPI Bus & Status LEDs

Duration: 15 Mins

Connect all 7 active RC522 pins (IRQ stays unconnected) and wire Green/Red LEDs to D6/D7.

MFRC522 13.56MHz RFID Reader & Access Control breadboard wiring check diagram
Stage 2: Breadboard layout & Arduino Uno pin-to-pin wiring audit.Stage 2 Diagram
Step Action Checklist:
  • Wire 3.3V→3.3V, GND→GND, RST→D9, SDA(SS)→D10.
  • Wire MOSI→D11, MISO→D12, SCK→D13; leave IRQ unconnected.
  • Wire Green LED (+220Ω) to D6 and Red LED (+220Ω) to D7.
Engineering & Tuning Tip: Keep SPI jumper wires under 15cm for reliable 4MHz clock signal integrity.
3

Install MFRC522 Library

Duration: 5 Mins

Install the "MFRC522" library by GithubCommunity via Arduino Library Manager.

MFRC522 13.56MHz RFID Reader & Access Control power rail protection diagram
Stage 3: Supply rail check (Arduino 3.3V Regulated Rail (NEVER 5V!)) and circuit protection verification.Stage 3 Diagram
Step Action Checklist:
  • Open Library Manager and search "MFRC522".
  • Install the standard MFRC522 library by GithubCommunity.
  • Run the Firmware Version diagnostic sketch to verify SPI communication.
Engineering & Tuning Tip: If PCD_DumpVersionToSerial() prints 0x00 or 0xFF, check your SPI wiring before testing cards.
4

Capture Your Card UID & Update Whitelist

Duration: 10 Mins

Scan your white card or blue key fob, copy its hex UID, and paste it into AUTHORIZED_UID.

MFRC522 13.56MHz RFID Reader & Access Control serial telemetry verification diagram
Stage 4: Firmware upload & 115200 baud Serial Monitor verification.Stage 4 Diagram
Step Action Checklist:
  • Upload the production sketch and open Serial Monitor at 115200 baud.
  • Tap the blue fob on the RC522 antenna coil and note the printed UID (e.g., A1 B2 C3 D4).
  • Replace AUTHORIZED_UID in the code with your card's exact hex string and re-upload.
Engineering & Tuning Tip: Always call rfid.PICC_HaltA() after reading so the same card does not re-trigger rapidly.
5

Test Authorized vs. Unauthorized Tags

Duration: 5 Mins

Confirm your registered tag lights the Green LED while unregistered tags trigger Red.

MFRC522 13.56MHz RFID Reader & Access Control live operational logic diagram
Stage 5: Live operational logic flow & calibration verification.Stage 5 Diagram
Step Action Checklist:
  • Tap the whitelisted key fob → Green LED (D6) lights for 1.5 seconds.
  • Tap the unregistered white card → Red LED (D7) flashes Denied.
  • Verify clean range (~2–4cm above the copper spiral antenna).
Engineering & Tuning Tip: Metal desks attenuate 13.56MHz fields—keep the RC522 raised on a plastic breadboard or standoff.

Subsystem Benchtop Verification Scripts

Test each hardware subsystem independently before deploying the full autonomous firmware.

1Bench Diagnostic: RC522 13.56MHz SPI RFID Reader + Cards Hardware Check

Subsystem Diagnostic

Minimal standalone sketch to verify pin wiring and signal response for RC522 13.56MHz SPI RFID Reader + Cards before running the full project firmware.

Arduino IDE Diagnostic ScriptC++ / Arduino
// Diagnostic: Verify RC522 SPI Link & Firmware Version
#include <SPI.h>
#include <MFRC522.h>
MFRC522 rfid(10, 9);
void setup() {
  Serial.begin(115200); SPI.begin(); rfid.PCD_Init();
  rfid.PCD_DumpVersionToSerial();
}
void loop() {}
Expected Output: Firmware Version: 0x92 = v2.0 (confirms healthy SPI wiring).

Complete Production Firmware

Full working C++ source code with pin mappings, non-blocking timers, and FSM avoidance routines.

arduino_uno_rfid_mfrc522_access_control.ino
arduino_uno_rfid_mfrc522_access_control.inoArduino C++
/**
 * Project 9: MFRC522 13.56MHz RFID Access Controller
 * Board: Arduino Uno R3 | SPI: SS=D10, RST=D9, MOSI=D11, MISO=D12, SCK=D13
 * Library: MFRC522 by GithubCommunity
 */
#include <SPI.h>
#include <MFRC522.h>

const uint8_t SS_PIN = 10;
const uint8_t RST_PIN = 9;
const uint8_t LED_GRANTED = 6;
const uint8_t LED_DENIED = 7;

// Replace with your own card UID printed on first scan
const char* AUTHORIZED_UID = "A1 B2 C3 D4";

MFRC522 rfid(SS_PIN, RST_PIN);

String formatUid() {
  String out = "";
  for (byte i = 0; i < rfid.uid.size; i++) {
    if (rfid.uid.uidByte[i] < 0x10) out += "0";
    out += String(rfid.uid.uidByte[i], HEX);
    if (i < rfid.uid.size - 1) out += " ";
  }
  out.toUpperCase();
  return out;
}

void setup() {
  Serial.begin(115200);
  pinMode(LED_GRANTED, OUTPUT);
  pinMode(LED_DENIED, OUTPUT);
  SPI.begin();
  rfid.PCD_Init();
  Serial.println(F("RFID Access Controller Ready. Tap 13.56MHz card..."));
}

void loop() {
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) return;

  String scanned = formatUid();
  Serial.print(F("Scanned UID: "));
  Serial.println(scanned);

  if (scanned == AUTHORIZED_UID) {
    Serial.println(F("=> ACCESS GRANTED"));
    digitalWrite(LED_GRANTED, HIGH);
    delay(1500);
    digitalWrite(LED_GRANTED, LOW);
  } else {
    Serial.println(F("=> ACCESS DENIED"));
    for (int i = 0; i < 3; i++) {
      digitalWrite(LED_DENIED, HIGH); delay(150);
      digitalWrite(LED_DENIED, LOW);  delay(150);
    }
  }

  rfid.PICC_HaltA();
  rfid.PCD_StopCrypto1();
}

Firmware Architecture Explanation:

  • Initializes hardware SPI at default safe clock speed and polls for ISO14443A transponders.
  • Formats variable-length UID bytes into uppercase zero-padded hexadecimal strings for clear comparison.
  • Properly halts card crypto state (PICC_HaltA + PCD_StopCrypto1) to prevent duplicate reads.

Operational Verification & Pin State Matrix

1Double-check all 7 Arduino Uno pin connections against the wiring schematic before plugging in USB.
2Upload the Bench Diagnostic sketch first and confirm Serial Monitor at 115200 baud matches: Firmware Version: 0x92 = v2.0 (confirms healthy SPI wiring).
3Upload the complete production sketch and verify every condition in the operational truth table below.

Input Signal vs. System Output Truth Table:

Operational truth table for MFRC522 13.56MHz RFID Reader & Access Control
Input / StatePin / SignalDetected ConditionExpected Output
UID == WhitelistSPI Read OKAuthorized KeycardGreen LED (D6) ON 1.5s
UID != WhitelistSPI Read OKUnknown CardRed LED (D7) 3× Rapid Blink

Engineering Troubleshooting Matrix

Engineering troubleshooting matrix for MFRC522 13.56MHz RFID Reader & Access Control
ProblemLikely CauseDiagnostic CheckEngineering Solution
Version check returns 0x00 or 0xFFLoose SPI jumper or cold solder joint on RC522 headerInspect D10–D13, RST(D9), and 3.3V voltageRe-seat all SPI leads and verify header pins are soldered cleanly.
Version reads OK but card never detectsUsing a 125kHz RFID tag instead of 13.56MHz MIFARE tagTest with the bundled blue fob / white cardEnsure tags are 13.56MHz ISO14443A compatible.
Module gets hot immediatelyConnected to 5V instead of 3.3VUnplug USB and inspect VCC wireMove VCC strictly to 3.3V (damaged units must be replaced).

Engineering Challenges & Upgrades

Take your build to the next level with these progressive engineering upgrades:

Level 1Multi-User Whitelist Array

Store 3 authorized UIDs with user names and greet each user by name over Serial.

Level 2Smart RFID + Servo + OLED Door Lock

Unlock an SG90 servo deadbolt and display "Welcome" on an SSD1306 OLED on valid scan.

Level 3Master Card Enrollment Mode

Scan a master admin card to temporarily register a new guest fob in EEPROM.