Arduino RC522 RFID Reader (Read a Card UID): Wiring, Code and Simulator

To build this Arduino RC522 RFID Reader (Read a Card UID) project you need an Arduino Uno and an RC522 RFID reader. The MFRC522 library finds the reader (firmware v2.0) and prints the UID and type of each card you tap. Make the 7 connections in the wiring table, upload the Arduino C++ code, and tap the white card, the blue fob and the NFC sticker from the Modules tab: two 4-byte MIFARE Classic UIDs and one 7-byte NTAG UID.

Open this circuit in the free Arduino Uno simulator

Parts list

QtyPartWhat it does
1Arduino Unothe microcontroller board
1RC522 RFID reader13.56 MHz RFID/NFC reader on SPI: 3.3V, GND, SDA (chip select) and RST to any pins, SCK/MOSI/MISO to the board’s SPI pins. Tap a card from the Modules tab (or set "Card on the reader"): a white MIFARE Classic card, a blue key fob, or an NTAG213 sticker.

Wiring

#FromTo
1Arduino Uno 3.3VRC522 RFID reader 3.3V
2Arduino Uno GNDRC522 RFID reader GND
3Arduino Uno pin 10RC522 RFID reader SDA
4Arduino Uno pin 9RC522 RFID reader RST
5Arduino Uno pin 13RC522 RFID reader SCK
6Arduino Uno pin 11RC522 RFID reader MOSI
7Arduino Uno pin 12RC522 RFID reader MISO

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add an RC522 RFID reader from the parts palette.
  3. Wire 1. Connect Arduino Uno 3.3V to RC522 RFID reader 3.3V.
  4. Wire 2. Connect Arduino Uno GND to RC522 RFID reader GND.
  5. Wire 3. Connect Arduino Uno pin 10 to RC522 RFID reader SDA.
  6. Wire 4. Connect Arduino Uno pin 9 to RC522 RFID reader RST.
  7. Wire 5. Connect Arduino Uno pin 13 to RC522 RFID reader SCK.
  8. Wire 6. Connect Arduino Uno pin 11 to RC522 RFID reader MOSI.
  9. Wire 7. Connect Arduino Uno pin 12 to RC522 RFID reader MISO.
  10. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  11. Run it. Press Run. Tap the white card, the blue fob and the NFC sticker from the Modules tab: two 4-byte MIFARE Classic UIDs and one 7-byte NTAG UID.

Arduino C++ code

// RC522 RFID reader with the MFRC522 library: print each card's UID and type.
// SDA -> 10, SCK -> 13, MOSI -> 11, MISO -> 12, RST -> 9, 3.3V, GND.
#include <SPI.h>
#include <MFRC522.h>

MFRC522 rfid(10, 9);  // SS (SDA), RST

void setup() {
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();
  rfid.PCD_DumpVersionToSerial();
  Serial.println(F("Tap a card on the reader."));
}

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

  Serial.print(F("Card UID:"));
  for (byte i = 0; i < rfid.uid.size; i++) {
    Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(rfid.uid.uidByte[i], HEX);
  }
  Serial.println();
  MFRC522::PICC_Type type = rfid.PICC_GetType(rfid.uid.sak);
  Serial.print(F("Type: "));
  Serial.println(rfid.PICC_GetTypeName(type));

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

What to try

Tap the white card, the blue fob and the NFC sticker from the Modules tab: two 4-byte MIFARE Classic UIDs and one 7-byte NTAG UID.

Frequently asked questions

How do I wire the RC522 RFID Reader (Read a Card UID) project on an Arduino Uno?

Make 7 connections: Arduino Uno 3.3V to RC522 RFID reader 3.3V; Arduino Uno GND to RC522 RFID reader GND; Arduino Uno pin 10 to RC522 RFID reader SDA; Arduino Uno pin 9 to RC522 RFID reader RST; Arduino Uno pin 13 to RC522 RFID reader SCK; Arduino Uno pin 11 to RC522 RFID reader MOSI; Arduino Uno pin 12 to RC522 RFID reader MISO.

What parts do I need for this Arduino project?

An Arduino Uno and an RC522 RFID reader.

Can I simulate this Arduino project online for free?

Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.

What does the code do?

The MFRC522 library finds the reader (firmware v2.0) and prints the UID and type of each card you tap.

Why does my RC522 show firmware version 0x00 or 0xFF?

The Arduino cannot talk to the reader: check the SPI wiring (SDA/SS, SCK, MOSI, MISO), RST, and that it is powered from 3.3 V. A working MFRC522 reports 0x91 or 0x92.

Can the RC522 read NFC stickers?

Yes: NTAG213/215/216 stickers are ISO 14443-A cards with a 7-byte UID; the MFRC522 library reads their UID and pages. It cannot read 125 kHz EM4100 cards.

More Arduino Uno projects