Built-in project · Arduino Uno R3

RC522 RFID reader (SS 10, RST 9), on an Arduino Uno

An RC522 RFID reader on the SPI pins with SDA (SS) on pin 10 and RST on pin 9: hold a card to it and the MFRC522 library prints the card’s ID. The whole build, an Arduino Uno and 1 more part, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Teaching? Assign it to your class in one click.

Beginner Runs in your browser. Free, and no account needed.

RC522 RFID reader (SS 10, RST 9) · Arduino Uno R3live0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · Arduino Uno R3
// RC522 RFID reader: hold a card to it and see its ID.
//
//   RC522 SDA (SS) -> pin 10    RC522 SCK  -> pin 13
//   RC522 MOSI     -> pin 11    RC522 MISO -> pin 12
//   RC522 RST      -> pin 9     RC522 3.3V -> 3.3V   GND -> GND
//
// The reader talks SPI, the bus on pins 11, 12 and 13 that every SPI part on
// an Uno shares. SDA is the chip-select line that picks this reader. Every
// card carries a serial number, its UID, which the reader can read without
// knowing anything else about the card.
//
// The RC522 runs on 3.3 V. Never wire its supply to 5 V.
//
// Click the reader and pick a card to hold to it.

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

const int SS_PIN = 10;
const int RST_PIN = 9;

MFRC522 reader(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600);
  SPI.begin();
  reader.PCD_Init();
  Serial.println("Mokxi Uno: RC522 on SS 10 and RST 9. Hold a card to the reader.");
}

void loop() {
  if (!reader.PICC_IsNewCardPresent()) return;
  if (!reader.PICC_ReadCardSerial()) return;
  Serial.print("Card UID:");
  for (byte i = 0; i < reader.uid.size; i++) {
    Serial.print(reader.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(reader.uid.uidByte[i], HEX);
  }
  Serial.println();
  reader.PICC_HaltA();
}

Parts list

3 parts, plus the jumper wires. Every one is in the editor's parts bin.

How it is wired

7 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • Ground: Arduino Uno R3 pin GND; RFID reader, MFRC522 pin GND
  • Arduino Uno R3 pin 13; RFID reader, MFRC522 pin SCK
  • Arduino Uno R3 pin 12; RFID reader, MFRC522 pin MISO
  • Arduino Uno R3 pin 11; RFID reader, MFRC522 pin MOSI
  • Arduino Uno R3 pin 10; RFID reader, MFRC522 pin SDA
  • Arduino Uno R3 pin 9; RFID reader, MFRC522 pin RST
  • Arduino Uno R3 pin 3V3; RFID reader, MFRC522 pin 3.3V

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.