Working with RFID Technology

RFID (Radio Frequency Identification) is a wireless technology that uses radio waves to identify and track objects. You've probably encountered RFID without realizing it: apartment keys, office access cards, parking passes, contactless credit cards, hotel keycards, and toll passes all use RFID technology.

What We'll Build

In this section, we'll use the RC522 RFID Card Reader Module to read data from RFID tags and key fob tags. The RC522 operates at 13.56 MHz and typically comes with MIFARE Classic 1K cards that contain 1KB of memory.

RFID Categories by Frequency

  • Low Frequency (LF): ~125 kHz, short range (up to 10cm), used in access control and livestock tracking
  • High Frequency (HF): 13.56 MHz, range of 10cm to 1m, widely used in access control, payments, and ticketing (we'll use this one)
  • Ultra-High Frequency (UHF): 860–960 MHz, range up to 12m, used in retail inventory and logistics

Active vs Passive RFID

RFID tags are powered in two different ways:

The RC522 Module

The RC522 RFID Card Reader Module is built on the MFRC522 IC designed by NXP. It's affordable, widely available, and perfect for learning. The module supports SPI, UART, and I2C communication protocols.

Module Specifications

Operating Frequency13.56 MHz
Supported StandardsISO/IEC 14443 A / MIFARE
Reading Distance0–50 mm
Operating Voltage3.3V (Do not use 5V!)
Current Draw13–26 mA (operating), 10–13 mA (idle)

MIFARE Classic 1K Memory Structure

The MIFARE Classic 1K card is divided into 16 sectors, each containing 4 blocks of 16 bytes. This gives a total capacity of 1KB (16 sectors × 4 blocks × 16 bytes = 1024 bytes).

Important Memory Blocks

  • Manufacturer Block: Block 0 of Sector 0 contains the UID and manufacturer data (read-only)
  • Sector Trailer: Last block of each sector holds authentication keys (KeyA and KeyB) and access conditions
  • Data Blocks: The remaining blocks store user data

Wiring the RC522 to Pico

We'll use SPI communication for this project. Connect the following pins:

Pico PinRC522 Pin
3.3V3.3V
GNDGND
GPIO 4MISO
GPIO 5SDA (CS)
GPIO 6SCK
GPIO 7MOSI

Projects Covered

⚠️ Important Safety Note

The RC522 module operates at 3.3V only. Using 5V will damage the module. Always double-check your power connections before turning on your circuit. When writing data, be careful not to overwrite sector trailer blocks, as this can make the sector permanently unusable.

Complete code examples using the mfrc522 crate with USB serial communication are available in the project repository. We'll use the rp-hal implementation to keep things straightforward.