All RFID Product

How to Connect an RC522 RFID Module to Raspberry Pi: A Beginner’s Guide​

he RC522 RFID module is a favorite among Raspberry Pi hobbyists—it’s affordable, easy to use, and perfect for projects like keyless entry systems or inventory trackers. But wiring and coding it can trip up first-timers. Follow this foolproof guide to get your RFID system up and running in under 30 minutes.

Raspberry Pi connected to an RC522 rfid module on a breadboard.

​What You’ll Need​

  • Raspberry Pi (3/4/Zero) with Raspberry Pi OS
  • RC522 RFID Module (≈ $5 online)
  • Jumper Wires (Female-to-Female)
  • Breadboard (optional)
  • RFID Tags/Cards (included with most RC522 kits)

​Step 1: Wire the RC522 to Your Raspberry Pi​

The RC522 uses SPI communication. Connect the pins as follows:

​RC522 Pin​​Raspberry Pi Pin​
SDA (SS)GPIO 8 (Pin 24)
SCKGPIO 11 (Pin 23)
MOSIGPIO 10 (Pin 19)
MISOGPIO 9 (Pin 21)
GNDGND (Pin 6)
RSTGPIO 25 (Pin 22)
3.3V3.3V (Pin 1)

​Pro Tip​​: Double-check connections—mixing up MOSI and MISO is a common mistake!

Step 2: Enable SPI on Raspberry Pi​

  1. Open the terminal and run:

bash
sudo raspi-config

  1. Navigate to ​​Interfacing Options​​ > ​​SPI​​ > ​​Yes​​ to enable SPI.
  2. Reboot:

bash

sudo reboot

Step 3: Install Required Libraries​

  1. Update your Pi:

bash

   sudo apt update && sudo apt upgrade -y  

2.Install Python libraries:

Install Python libraries

2.Paste this code:

Paste this code

4.Hold an RFID tag near the RC522. If successful, the tag’s ID and data will display.

Terminal window showing successful RFID tag detection.

Step 5: Customize Your Project​

Now that it works, tweak the script for your needs:

  • ​Access Control​​: Add a list of authorized tag IDs and trigger a relay/servo.
  • ​Data Logging​​: Write tag data to a CSV file with timestamps.
  • ​Smart Inventory​​: Integrate with a database like MySQL to track items.

​Example​​: Cykeo’s warehouse team used a similar setup to log tools checked out by employees, cutting loss rates by 30%.

​Troubleshooting Common Issues​

  • ​No Tag Detected​​:
    • Ensure the RC522 is powered via 3.3V (NOT 5V!).
    • Check SPI is enabled and wires are secure.
  • ​GPIO Errors​​:
    • Run sudo python3 instead of python3 for permission fixes.
  • ​Weak Read Range​​:
    • The RC522 has a short range (2–5 cm). Adjust tag placement or consider a UHF module for longer scans.

​Beyond Basics: Advanced Tips​

  • ​Multiple RC522 Modules​​: Use additional GPIO pins (e.g., GPIO 7, 18) for more readers.
  • ​Network Integration​​: Send scan data to a cloud server via MQTT or HTTP.
  • ​Security​​: Encrypt tag data to prevent cloning.

​Takeaway​​: The RC522 and Raspberry Pi are a match made for DIY magic. Whether you’re building a coffee machine that activates with RFID stickers or a library book tracker, this combo delivers. Just follow the steps, test often, and remember: even pros mix up wires sometimes.

PgUp: PgDn:

Relevance

View more