How to use an RFID reader with a Raspberry Pi Pico

How to use an RFID reader with a Raspberry Pi Pico


RFID cards and tags are everywhere! We use them in buildings for access control. Printers and photocopiers can use them to identify staff members. Livestock tagging and pet identification tags all use a form of RFID. The tech to read an RFID device is cheap, for around $5 you can get the reader, and for $4, a Raspberry Pi Pico can read the IDs from the cards / tags.

In this how to, we will learn how to read RFID tags and cards using an MFRC522 reader and a Raspberry Pi Pico, the goal will be to create a fictional RFID access control system that will allow users into a building, or alert security to remove them. Before we can do that, we need to identify the ID of our cards / tags. The first section of this how to will do just that, and then we will insert some code to control two LEDs to simulate the locking mechanism.

For this how to you will need

  • Raspberry Pi Pico running MicroPython
  • MFRC522 RFID reader
  • Large breadboard
  • 11 x Male to male jumper wires
  • Green LED
  • Red LED
  • 2 x 100 Ohm resistors (Brown – Black – Brown – Gold)

Building the Hardware

(Image credit: Tom’s Hardware)

The hardware build is split into two sections. First is the wiring for the MFRC522 RFID reader. The reader uses SPI to communicate with the Raspberry Pi Pico and it requires seven pins to do so. Two are for power (3.3V and GND) and the rest are for SPI.

Swipe to scroll horizontally

MFRC522

Raspberry Pi Pico

Wire Color

SDA

GP1

Blue

SCK

GP2

Orange

MOSI

GP3

Purple

MISO

GP4

Blue

GND

Any GND

Black

RST

GP0

White

3.3

3V3 Out (Physical pin 36)

Red

Pico NFC

(Image credit: Tom’s Hardware)

Second are our outputs. To see if the correct card has been presented, we need to add two LEDs. Red for an incorrect RFID card, green for a correct card. The LEDs connect to a GPIO pin which we control to turn the LED on/off, and to any available GND pin via a 100 Ohm resistor. You can use a 220 or 330 Ohm resistor, I just happened to have some 100 Ohm resistors on my desk. Need to work out the correct resistor? We’ve got a guide for you!

Swipe to scroll horizontally
Header Cell – Column 0

Raspberry Pi Pico

Wire Color

Red LED Anode (+)

GP14

Red

Red LED Cathode (-)

Any GND

Black

Green LED Anode (+)

GP15

Green

Green LED Cathode (-)

Any GND

Black

Pico NFC

(Image credit: Tom’s Hardware)

Before moving on, check that your wiring is correct.

Installing the RFID Reader Software



Source link

Leave a Reply

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