Skip to main content

rfid_rc522

RC522 RFID reader for 13.56MHz MIFARE card and tag identification.

Overview

The rfid_rc522 node interfaces with the MFRC522 RFID reader module via SPI to read and write 13.56MHz MIFARE Classic and Ultralight cards and tags. Commonly used for access control, inventory tracking, attendance systems, and interactive IoT projects requiring contactless identification.

13.56MHz
Operating Frequency
~5cm
Read Range
MIFARE
Card Types
1KB
Card Storage

Properties

Property Type Required Default Description
spiBus number No 0 SPI bus number
spiDevice number No 0 SPI chip select (CE0=0, CE1=1)
spiSpeed number No 1000000 SPI clock speed in Hz (max 10MHz)
resetPin number No 25 GPIO pin for hardware reset (-1 to disable)
antennaGain select No "48dB" Antenna gain: "18dB", "23dB", "33dB", "38dB", "43dB", "48dB"

Inputs

Trigger Scan
{
  "payload": {
    "command": "scan"
  }
}
Read Block Data
{
  "payload": {
    "command": "read",
    "block": 4,
    "key": "FFFFFFFFFFFF"
  }
}

Outputs

Card Detected
{
  "uid": "A1:B2:C3:D4",
  "type": "MIFARE 1KB",
  "size": 1024,
  "data": null,
  "timestamp": "2025-01-15T10:30:00.000Z"
}
Block Read Response
{
  "uid": "A1:B2:C3:D4",
  "type": "MIFARE 1KB",
  "size": 1024,
  "data": [72, 101, 108, 108, 111, 0, 0, 0,
           0, 0, 0, 0, 0, 0, 0, 0],
  "timestamp": "2025-01-15T10:30:01.000Z"
}

Wiring Diagram

RC522 to Raspberry Pi

  RC522 Module           Raspberry Pi
  +------------+        +--------------+
  | SDA (CS)   |--------| CE0   (Pin 24)|
  | SCK        |--------| SCLK  (Pin 23)|
  | MOSI       |--------| MOSI  (Pin 19)|
  | MISO       |--------| MISO  (Pin 21)|
  | IRQ        |--------| (not connected)|
  | GND        |--------| GND   (Pin 6) |
  | RST        |--------| GPIO25(Pin 22)|
  | 3.3V       |--------| 3.3V  (Pin 1) |
  +------------+        +--------------+

Wiring Notes

3.3V power only (module is NOT 5V tolerant)

SDA is the SPI chip select (CS/SS) line

RST hardware reset, set to -1 to tie to 3.3V

IRQ optional, not required for polling mode

Note: Enable SPI on your Pi: sudo raspi-config then Interface Options, then SPI, then Enable.

Example Use Cases

Door Access Control System

Scan RFID cards and check against an authorized list to unlock a door.

rfid_rc522 function (check auth) gpio-out (relay)
[
  {
    "id": "rfid-scan",
    "type": "rfid_rc522",
    "spiBus": 0,
    "spiDevice": 0,
    "resetPin": 25,
    "antennaGain": "48dB"
  },
  {
    "id": "check-auth",
    "type": "function",
    "name": "Check Authorized Cards"
  },
  {
    "id": "door-relay",
    "type": "gpio-out",
    "pin": 18,
    "initialState": 0
  }
]

Attendance Logging System

Log RFID card scans with timestamps to a SQLite database and display on dashboard.

rfid_rc522 sqlite table
[
  {
    "id": "rfid-reader",
    "type": "rfid_rc522",
    "antennaGain": "48dB"
  },
  {
    "id": "log-attendance",
    "type": "sqlite",
    "sql": "INSERT INTO attendance (uid, scan_time) VALUES (?, datetime('now'))"
  },
  {
    "id": "display-table",
    "type": "table",
    "name": "Recent Scans"
  }
]

Inventory Tracking

Read RFID tags on items and update inventory in a MongoDB database.

[
  {
    "id": "rfid-item",
    "type": "rfid_rc522",
    "antennaGain": "43dB"
  },
  {
    "id": "lookup-item",
    "type": "mongodb",
    "operation": "findOne",
    "collection": "inventory"
  },
  {
    "id": "update-status",
    "type": "mongodb",
    "operation": "updateOne",
    "collection": "inventory"
  }
]

Common Use Cases

Access Control

RFID card-based door and gate entry systems

Attendance Systems

Employee and student check-in/check-out logging

Inventory Tracking

Tag and track assets with RFID labels

Interactive Projects

NFC-triggered actions, games, and educational kits

Related Nodes