Introduction: RFID RC522 (Raspberry Pi)
Basic tutorial of how to setup a RFID reader/writer (RC522) with the Raspberry Pi.
Step 1: Parts
RPI 3 - https://amzn.to/2VA9pQY
4 Amp Power Adapter - https://amzn.to/2CTptWu
16GB micro SD - https://amzn.to/2SFMwd3
120 pcs jumper cable: https://ebay.to/2VAb9cY
RFID Sensor - https://amzn.to/2spaDRt
Step 2: Setup
SDA <--> 24
SCK <--> 23
MOSI <--> 19
MISO <--> 21
IRQ <--> UNUSED
GND <--> 6
RST <--> 22
3.3V <--> 1
1. Enable SPI Interface
sudo raspi-config
2. Reboot
sudo reboot
3. Check if spi_bcm2835 is loaded
lsmod | grep spi
4. Install python2.7-dev
sudo apt-get install python2.7-dev
5. Download Git Project, change directory, and install
git clone https://github.com/lthiery/SPI-Py.git
cd SPI-Py
sudo python setup.py install
6. Install MFRC522-python
git clone https://github.com/mxgxw/MFRC522-python.git
cd MFRC522-python
7. Run script
python Read.py
Step 3: Code
https://github.com/mxgxw/MFRC522-python.git
Reading from RFID card:
https://github.com/mxgxw/MFRC522-python/blob/maste...
Writing to RFID card:
Step 4: Additional Info
Official Website:
10 Comments
2 years ago
Yet another instructable written long ago, but never updated. Insuring many beginners will fail when they try to make it all work.
3 years ago
/home/pi/MFRC522-python/MFRC522.py:133: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(self.NRSTPD, GPIO.OUT)
Traceback (most recent call last):
File "Read.py", line 41, in <module>
MIFAREReader = MFRC522.MFRC522()
File "/home/pi/MFRC522-python/MFRC522.py", line 135, in __init__
self.MFRC522_Init()
File "/home/pi/MFRC522-python/MFRC522.py", line 406, in MFRC522_Init
self.MFRC522_Reset();
File "/home/pi/MFRC522-python/MFRC522.py", line 138, in MFRC522_Reset
self.Write_MFRC522(self.CommandReg, self.PCD_RESETPHASE)
File "/home/pi/MFRC522-python/MFRC522.py", line 141, in Write_MFRC522
spi.transfer(((addr<<1)&0x7E,val))
TypeError: function takes exactly 2 arguments (1 given)
Please do help, and show me how to fix this, as I keep getting this error message and I have no clue how to fix it.
Reply 3 years ago
jloleris,
If you look at the post from Alba below, it has a reply from Tomato997.
Tomato997's reply has an updated MFRC522.py script you can download and replace the existing MFRC522.py in /home/pi/SPI-Py/MFRC522-python.
Once you have this file replaced, try the python Read.py again and it should work.
That's all I did to get mine going.
3 years ago
Hello. Please I have a problem with Raspberry 3. I cannot run Read.py. Please someone can help me?. I need to read UID. Thanks. I have the following error:
Reply 3 years ago
Hey Alba, it is a bit tricky sometimes. are you using python 2.7 or 3? You can try these files from me with python 3. Best regards
Question 3 years ago on Step 3
Sorry, but I feel stupid here.
Step 3 - where do I change/add the code?
And where do I clone the github for reading and writing? Apart from that, everything above works dandy :)
4 years ago
After writing the command: cd MFRC522-python
I'm getting an error as:" bash: cd: MFRC522-python: No such file or directory "
why is this comming and how can i rectify this?
Reply 4 years ago
You are in the SPI-Py directory. Type 'cd ..' to return to the next higher directory, which should be the root directory. Next, type 'ls' to see if the MFRC522-python directory is listed. If so, you can then type 'cd MFRC522-python' to get into that directory. Don't type the ' marks in your command line.
Reply 4 years ago
after commanding 'ls' its showing 'pi', then how to check if MFRC522-python directory is there or not?
Question 4 years ago on Introduction
Will this unit program and read RFID Pills