RFID-RC-522 Reader
RaspBerry Pi
Er. Manoj S. Kavedia
[Link]
[Link]
9324258878 / 8329988738
Raspberry Pi Pin Out
RFID Reader
The RFID RC522 is a very low-cost RFID (Radio-frequency identification) reader and
writer that is based on the MFRC522 microcontroller.
This microcontroller provides its data through the SPI protocol and works by creating a
13.56MHz electromagnetic field that it uses to communicate with the RFID tags.
SPI
In a computer, a Serial Peripheral Interface (SPI) is an interface that enables the
serial (one bit at a time) exchange of data between two devices, one called a
master and the other called a slave .
An SPI operates in full duplex mode. This means that data can be transferred in
both directions at the same time.
The SPI is most often employed in systems for communication between the
central processing unit ( CPU ) and peripheral devices.
It is also possible to connect two microprocessors by means of SPI.
The term was originally coined by Motorola. National Semiconductor has an
equivalent interface called Microwire.
Circuit Diagram
PIN Details
RFID RC522 there are 8 possible connections on it, these being
SDA (Serial Data Signal) (24),
SCK (Serial Clock) (23),
MOSI (Master Out Slave In) (19),
MISO (Master In Slave Out) (21),
IRQ (Interrupt Request) (Not Used),
GND (Ground Power) (6),
RST (Reset-Circuit) (22) and
3.3v (3.3v Power In) (1).
Note : wire all of these but the IRQ to our Raspberry Pi’s GPIO pins
MOSI (Master Output/Slave Input) – Line for the master to send data to the slave.
MISO (Master Input/Slave Output) – Line for the slave to send data to the master
Setting up Raspbian for the RFID RC522
sudo raspi-config
sudo reboot
lsmod | grep spi
see spi_bcm2835
sudo nano /boot/[Link]
dtparam=spi=on“
Getting Python ready for the
RFID RC522
sudo apt-get update
sudo apt-get upgrade
Install python3-dev, python-pip and git packages
sudo apt-get install python3-dev python3-pip
Install the Python Library spidev to our Raspberry Pi using the python “pip” tool
The spidev library helps handle interactions with the SPI
sudo pip3 install spidev
pip is a package-management system used to install and manage software packages
written in Python. Many packages can be found in the default source for packages
and their dependencies — Python Package Index (PyPI). pip is a recursive acronym
for "Pip Installs Packages".
MFRC522
After Installing the spidev library to our Raspberry Pi we can now now proceed to
installing the MFRC522 library using pip
There are two files that are included within our MFRC522 library that we make
use of:
[Link] which is an implementation of the RFID RC522 interface, this
library handles all the heavy lifting for talking with the RFID over the Pi’s
SPI Interface.
[Link] that takes the [Link] file and greatly simplifies it
by making you only have to deal with a couple of functions instead of
several.
sudo pip3 install mfrc522
Writing with the RFID RC522
mkdir ~/pi-rfid
cd ~/pi-rfid
sudo nano [Link] or any such text Editor
import [Link] as GPIO
from mfrc522 import SimpleMFRC522
reader = SimpleMFRC522()
try:
text = input('New data:')
print("Now place your tag to write")
[Link](text)
print("Written")
finally:
[Link]()
Wiring the RFID RC522
sudo python3 [Link]
pi@raspberrypi:~/pi-rfid $ sudo python3 [Link]
New data:Manoj Kavedia
Now place your tag to write
Written
Reading the RFID RC522
cd ~/pi-rfid
sudo nano [Link] import [Link] as GPIO
from mfrc522 import SimpleMFRC522
reader = SimpleMFRC522()
try:
id, text = [Link]()
print(id)
print(text)
finally:
[Link]()
sudo python3 [Link]
pi@raspberrypi:~/pi-rfid $ sudo python3
[Link]
827843705425
ManojKavedia
Appliction of RFID
Appliction of RFID
Enjoy Security
Er. Manoj S. Kavedia
Contact on Watsapp to join Students Forum : 9324258878