RC522 RFID Reader Module interfacing with Raspberry Pi Pico

Introduction

In this project, we will know the step-by-step process of how to interface the RC522 RFID module with the Raspberry Pi Pico board. Nowadays the most popular RFID module is RC522 which operates at 13.6MHz and with SPI communication. So, we will use the RC522 module to interface with the Raspberry Pi Pico board.

Again, we will start with a step-by-step process to read the RFID tag/card using an RFID reader then we will process the tag/card numbers using a Raspberry Pi Pico board to build an RFID access control system where we will make use of a 0.96″ OLED screen to display the authentication message on the OLED display.

Hardware Requirements

Disclaimer: It may contains Amazon affiliate links. which means I can get a small commission on the sale. This might be your indirect help to me. Thank You 🙏
  • Raspberry Pi Pico (HERE)
  • 0.96″ I2C OLED Display (HERE)
  • Micro USB Cable (HERE)
  • RC522 RFID with Card (HERE)
  • Connecting Wires (HERE)
  • Breadboard (HERE)

Software Requirements

  • Thonny IDE (Download HERE)
  • SSD1306 library code  (Download HERE)
  • OLED library code  (All files are in the same folder)
  • RC522 library code  (All files are in the same folder)

About RFID RC522 Module


It is a low-cost transceiver module for contactless communication that works at 13.6 MHz. It is based on the NXP MFRC522 chip, which is a highly integrated reader/writer IC for contactless communication at 13.56 MHz. It can read and write Mifare Classic 1K and Mifare Classic 4K cards, as well as other card types that comply with the ISO 14443A standard. The RC522 module is low-cost and can be used in a wide variety of RFID projects. It is also a popular RFID module in school and college projects. This can be used to build many applications, such as access control, attendance systems, inventory management, etc. In the local market, you will get mainly two types of RFID readers. One with SPI communication and the other one with serial communication.

In this tutorial we will use RC522 RFID Module.

This RC522 RFID reader basically comes with an RFID card and a key tag. It has 1KB of memory and the memory contains the tag message or the tag ID. The RC522 RFID module creates a 13.6MHz electromagnetic field to communicate with the tag or the card and transceive the data. This RFID can be used to interface with any of the microcontrollers such as PIC, AVR, Arduino, and Raspberry Pi over SPI. SPI is a type of UART communication protocol that uses 4 wires to communicate. It can communicate up to 10Mbps with the host in SPI mode.

Specification

  • Integrated MF RC522 chip
  • Operating current: 13-26mA/ DC 3.3v
  • Low cost, low voltage small in size
  • 13.6MHz contactless communication
  • Data transfer rate: Maximum 10Mbps
  • Supported card types: mifare1 S50, mifare1 S70 MIFARE Ultralight, mifare Pro, MIFARE DESFire

RC522 RFID module pinout

Pin description

  • SDA and SCL are the data and clock pins.
  • SS, SCK, MOSI, & MISO are the SPI communication pins.
  • TX & RX are UART pins for serial communication.
  • GND is the common ground pin needed to connect with the GND pin of Raspberry Pi Pico.
  • RST is the reset pin of the module.
  • VCC is a 3.3v supply pin of the module needed to connect with the 3.3v VCC pin of Raspberry Pi Pico.

Interface RFID RC522 module with Raspberry Pi Pico

Now we will build the circuit as per the below circuit diagram. Please go through the circuit diagram and build your circuit carefully. Follow the table for the circuit explanation.

Circuit Explanation

Build the circuit as shown in the circuit diagram and follow the below table for Raspberry Pi Pico and RC522 RFID modules.

RC522 ModuleRaspberry Pi Pico
SSGP5
SCKGP2
MOSIGP7
MISOGP4
IRQNC
GNDGND
RSTGP18
VCC3.3v

The below table is for Raspberry Pi Pico and 0.96″ OLED display modules.

OLED ModuleRaspberry Pi Pico
SCLGP17
SDAGP16
VCC5v
GNDGND

Source Code Explanation

MicroPython Code: The code is divided into four different parts. Please follow the steps one after another.

  • The SSD1306 library code
  • The OLED library code.
  • The RC522 library code.
  • The main code that runs and checks the authentication

The SSD1306 library code:(ssd1306.py)
Download all the codes from the given link. Now create a new file and open the downloaded ssd1306.txt file, then copy and paste all the code from the ssd1306.txt file to the new file and then save the file as ssd1306.py file in the Raspberry Pi Pico board.

The OLED library code: (oled need to install from Thonny IDE)
To install oled library follow the steps. In Thonny IDE go to Tools-> Manage Packages-> search “oled” for the library find the “micropython-oled” library from the search items by the author: Yeison Cardona and you can find an Install button below, just click and install it. It will be installed inside the Raspberry Pi Pico. So, no need to check, It will work.

The RCC522 library code:(mfrc522.py)
Again create a new file and copy/paste the mfrc522.txt file code to the new file and save the file as a mfrc522.py file in the Raspberry Pi Pico board.

The main code:
Before using the main code you can run and test the testCode.txt file code. This will display the fetched card data in the serial monitor. Now create a new file and copy/paste the code from the mainCode.txt file and save the file as main.py in the Raspberry Pi Pico board.

Why the main.py file name?
You can name the file as you like, but if you want to run the project automatically on boot. You have to name the file main.py then only the Raspberry Pi Pico board will automatically detect the main file and run the code.

Video Tutorial

Download Source Code

Download the complete source code: click here

Leave a Comment