RFID RC522 (Raspberry Pi)

90K5522

Intro: RFID RC522 (Raspberry Pi)

Basic tutorial of how to setup a RFID reader/writer (RC522) with the Raspberry Pi.

STEP 1: Parts

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

STEP 4: Additional Info


10 Comments

Yet another instructable written long ago, but never updated. Insuring many beginners will fail when they try to make it all work.
/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.
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.
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:
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
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 :)
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?
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.
after commanding 'ls' its showing 'pi', then how to check if MFRC522-python directory is there or not?
Will this unit program and read RFID Pills