RFID RC522 (Raspberry Pi)

Introduction: RFID RC522 (Raspberry Pi)

About: the Raspberry Pi is Awesome!

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

2 People Made This Project!

Recommendations

  • The 1000th Contest

    The 1000th Contest
  • Battery Powered Contest

    Battery Powered Contest
  • Hand Tools Only Challenge

    Hand Tools Only Challenge

9 Discussions

0
jloleris
jloleris

6 months 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.

0
JodyLNC
JodyLNC

Reply 5 months 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.

0
Alba Esther
Alba Esther

9 months 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:

20200115_121947.jpg
1
Tomato997
Tomato997

Reply 9 months 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

0
Osquar
Osquar

Question 1 year 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 :)

0
KschitaXino
KschitaXino

1 year 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?

temp.JPG
0
ChadR1
ChadR1

Reply 1 year 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.

0
bhakti_dhongade
bhakti_dhongade

Reply 1 year ago

after commanding 'ls' its showing 'pi', then how to check if MFRC522-python directory is there or not?

0
kaltax
kaltax

Question 1 year ago on Introduction

Will this unit program and read RFID Pills