Raspberry Pi Pico And RFID Tag Reader

You know it is good when you don’t need to touch for turning on any light or opening any door. So you can use RFID cards for this touchless scenario. In this post I’m gonna give you MicroPython code for this project. First what you need

PN532 RFID Card Reader

1xRaspberry Pi Pico

1xPn532 RFID Card Reader

1xRFID Card

1xLED

1×220 Ohn Resistor

Jumber Cables and MicroUsb Cables.

First connect PN532 SDA and SCL pins to Raspberry Pi Pico GPIO pin 8 and pin 9. Also connect LED with resistor to pin 17.

After that open Thonny Editor and paste code below.

import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522

reader = SimpleMFRC522()
led_pin = 17 # change this to the pin number connected to the LED

# set up the GPIO pin for the LED
GPIO.setmode(GPIO.BCM)
GPIO.setup(led_pin, GPIO.OUT)

try:
    while True:
        id, text = reader.read()
        print(id)
        print(text)
        # turn on the LED
        GPIO.output(led_pin, GPIO.HIGH)
finally:
    # turn off the LED and clean up the GPIO pins
    GPIO.output(led_pin, GPIO.LOW)
    GPIO.cleanup()

As you can see code you need to install mfrc522 library. You can install this with pip. Every time you read your RFID card, LED will open. And if you take your card away from PN532 card reader LED will turn off.

Leave a Reply

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