Raspberry Pi Pico ProjectsRaspberry Pi Projects

MFRC522 RFID Module With Raspberry Pi Pico Using MicroPython

Introduction

The MFRC522 RFID sensor is a great way to add RFID to your Raspberry Pi Pico. In this project, we will be using the MFRC522 RFID sensor with the Raspberry Pi Pico to create an easy RFID reader. We will be using MicroPython to code the Raspberry Pi Pico and the MFRC522 RFID Module.

In this tutorial, we will be using MicroPython to control the MFRC522 Module, we will use it to read the UID of the card that we are using. We will then print this UID to the Thonny Shell. Check MFRC522 RFID Sensor With Arduino Tutorial

This is a basic tutorial on how to use the MFRC522 RFID Module with the Raspberry Pi Pico. You can use this module to add an extra layer of security to your projects.



Required Material

You will need the following materials to complete this tutorial:

RFID Reader Module

A Brief Note on RC522 RFID Module

RFID is a technology that uses radio waves to identify and track objects.

An MFRC522 RFID Module is a small device that uses radio frequency identification (RFID) technology to read and write data on RFID tags. RFID is a type of automatic identification and data capture (AIDC) technology that uses radio waves to identify and follow objects.

The MFRC522 RFID module is used in a wide variety of applications such as access control, identification, and payment systems. In this tutorial, we will use the MicroPython programming language to interface with the MFRC522 RFID module.

Features:

  • MFRC522 chip-based board
  • Operating frequency: 13.56MHz
  • Supply Voltage: 3.3V
  • Current: 13-26mA
  • Read Range: Approx 3cm with supplied card and fob
  • SPI Interface
  • Max Data Transfer Rate: 10Mbit / s

MFRC522 RFID module is an Affordable and absolutely popular module for reading and writing RFID cards working on 13.56MHz (A/MIFARE, MF1xxS20, MF1xxS70, MF1xxS50).

RFID Module Pinout

RFID Pinout



Raspberry Pi Pico

The Raspberry Pi Pico Rp2040 is a new microcontroller board from Raspberry Pi. It’s their smallest and most affordable board yet, at just $4 USD It is based on the powerful Cortex-M0+ processor. It’s small, affordable, and easy to use. With its capabilities, the Pico is perfect for projects like home automation, robotics, and more.  Check also Getting Started Raspberry Pi Pico – Pinout, Specs – Beginner Guide

Raspberry Pi Pico Pinout

raspberry_pi_Pico-Pinout-



Wiring Diagram RFID Module With Raspberry Pi Pico

The VCC and GND pins of the RFID module are connected to the 3.3V and GND pins of Raspberry pi pico respectively. The Reset pin is connected to the GP22 and SCK, MISO, MOSI, and CS pins are connected to the GPIO6, GPIO4, GPIO7, and GPIO5 pins of the Raspberry Pi PIco respectively.

 

MFRC522 RFID Module With Raspberry Pi Pico Using MicroPython

Raspberry Pi Pico MFRC522 RFID module
GP5 SDA
GP6 SCK
GP7 MOSI
GP4 MISO
IRQ
GND GND
GPIO22 RST
3.3V 3.3V

Raspberry Pi Pico RGB LED Module Wiring

Raspberry Pi Pico RGB LED Module
GND GND
12 RED
11 GREEN
10 BLUE

Note – the module power supply, is done through the 3.3V pin of the Pico.

MFRC522 Micropython Code & Librarries

We will be programming the Raspberry Pi Pico with MicroPython Code to communicate with RFID MFRC522 Module to the pico board. Getting Started With Raspberry Pi Pico With Thonny IDE

The code has diverged into 3 parts:
1. mfrc522.py which is the library for the MRC522 Module
2. tag_read.py which is the code to read the RFID Tags
3. RGB_Control.py which is used to match the RFID Tag and control the RGB LED

mfrc522.py

Copy the following code and save it to Raspberry Pi Pico with the name mfrc522.py


tag_read.py

Copy the following code and save the file with the name tag_read.py in Raspberry Pi Pico. You need to run the file to read the codes of the RFID Tags.

Both of the above codes and you are ready to check the RFID Tag numbers. In my case, I will be reading the tag number of 3 RFID Cards.

Raspberry pi pico RFID reading

Whenever the card is scanned, the RFID Tag number is displayed on the Python Shell. You can copy and note down the RFID Tag number as it will be used in the next code. in my case, the first card is 495155827 The RFID Tag number for the second card is 3588359545.

RFID with raspberry pi pico using Micropythons


RGB_Control.py 

We read the RFID tag number already. Now we can compare the tag number to our own Access Control System. We need two card numbers that we store in the two lines of code to follow. We should replace both of the Original Tag numbers with the tag number that we copied with the previous code.

Please replace both the RFID Tag numbers with the Tag numbers you copied before.

Now you can add the following code and save it to Raspberry Pi Pico with the name RGB_Control.py.

Conclusion

After running, scan the RFID Cards now. When you scan the individual tags, the Blue LED and Green LED will turn on according to the assigned colour.

You may also like to read:

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Ad
Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker