/MFRC522-python

Python3 library to read/write RFID tags via the MFRC522 RFID module.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

MFRC522-python

Python library to read and write RFID tags via the MFRC522 RFID module.


First Things First

Enable SPI

Open the raspberry pi configuration with: sudo raspi-config.
In the menu that pops up select 5 Interfacing options.
And finally enable SPI by selecting P4 SPI.
For the changes to take effect, reboot the raspberry pi with? sudo reboot.

Wiring the Pins

Connect the RC522's Pins to the RaspberryPi's GPIO pins. No need to connect the IRQ pin.

RC522 GPIO pin
SDA 8
SCK 11
MOSI 10
MISO 9
IRQ -
GND GND
RST 25
3.3V 3.3V

Pin numbers in the table above are based on the GPIO numbering, not the pin numbering. You can check out the following image for more information about how to wire the reader.

GPIO-Pinout-Diagram-2 image source: https://www.raspberrypi.com/


Installation and Setup

You can either simple clone this repository to where you want to use it and import the scripts into your code from there, or install this as a module.

Setup - Clone and Edit

First install the dependencies required to run this code, which are git, python-dev, and spidev. You can do this with the following bash commands.

sudo apt install git python-dev -y
python3 -m pip install spidev

Simply use the following bash commands to clone the repo. Once executed, you're in and ready to go.

cd ~
git clone https://github.com/fintzd/MFRC522-python.git
cd MFRC522-python/

Setup - With setup.py

First install the dependencies required to run this code, which are git & python-dev. You can do this with the following bash commands.

sudo apt install git python-dev -y

Then you can use the setup.py file to set this script up. To do this, use the following commands in the top level directory (or wherever you want to use it). Mind you, that we are using python3 in this repository.

cd ~
git clone https://github.com/fintzd/MFRC522-python.git
cd MFRC522-python/
sudo python3 setup.py install

Setup - As a Python Module

TODO


Just a Simple Use Case

TODO