How to Interface RFID-RC522 With Raspberry Pi
by sarful in Circuits > Raspberry Pi
6206 Views, 3 Favorites, 0 Comments
How to Interface RFID-RC522 With Raspberry Pi
In this tutorial, I will show you how to interface RFID-RC522 with Raspberry Pi with some simple step,
Make sure that the tags you purchase for your RFID RC522 operate on the 13.56MHz frequency otherwise we will fail to read them
I have divided this tutorial into several parts. I believe that if you continue to work with me, you will be able to create projects.
Let's go
Step-1
First, you need to collect all the materials or components you need for this project and get an idea about this component I will briefly discuss a few here
Equipment List
Step-2
Raspberry pi to RFID-RC522 wiring
- SDA connects to Pin 24.
- SCK connects to Pin 23.
- MOSI connects to Pin 19.
- MISO connects to Pin 21.
- GND connects to Pin 6.
- RST connects to Pin 22.
- 3.3v connects to Pin 1.
Step-3
Some default setting Change
You need to change some default configuration to connect it to Raspberry Pi, By default, the Raspberry Pi has the SPI (Serial Peripheral Interface) disabled, which is a bit of a problem as that is what our RFID reader circuit runs through. So you have to need to Change This.
. l. et's go your Raspberry Pi terminal and write sudo raspi-config
sudo raspi-config
Flow this for Changing your setting
Some default setting Change2. Now you have to need to restart your system
sudo reboot3. Once your Raspberry Pi has finished rebooting, we can now check to make sure that it has in fact been enabled. The easiest way to do this is to run the following command to see if spi_bcm2835 is listed.
lsmod | grep spi
Step-4
Now time to update your system and install a library
and flow this commend
sudo apt-get update sudo apt-get upgrade sudo apt-get install python3-dev python3-pip sudo pip3 install spidev
Now time to install RFID-RC522 library flowing this commend
sudo pip3 install mfrc522
Code
My previous tutorialimport RPi.GPIO as GPIO from mfrc522 import SimpleMFRC522 from time import sleep led=40 GPIO.setwarnings(False) # Ignore warning for now GPIO.setmode(GPIO.BOARD) GPIO.setup(led,GPIO.OUT) GPIO.output(led, GPIO.LOW) reader = SimpleMFRC522() while True: try: id, text = reader.read() print(id) print(type(id)) print(text) sleep(2) if id==872589727: sleep(2) GPIO.output(led, GPIO.HIGH) sleep(1) else: GPIO.output(led, GPIO.LOW) except: GPIO.cleanup()