Introduction: Raspberry Pi 3 Model B & MIFARE RC522 RFID Tag Reading

Picture of Raspberry Pi 3 Model B & MIFARE RC522 RFID Tag Reading

*EDIT: This instructable was updated to use the latest raspbian version (2017-04-10)

This instructable is about reading rfid tags using the MIFARE RC522 RFID
module and a Raspberry pi 3 B. I'm not an expert in any way concerning electronics or IoT for that matter so I'm just sharing personal experience and the solution I found after nights of testing every proposed solution I came across the web.

The module I bought is using the SPI Interface. Not all modules support it. You might have bought an identical module that supports UART or some other interface. So before we begin check again that your module supports SPI.

Step 1: Solder the Module Pins

Picture of Solder the Module Pins

IMPORTANT: Some shops ship the module with two pin headers. A straight-one and one in an L shape (90 degrees angle). If your module came with the pin header not soldered onto the module board then solder the module pins or else the module will not work.

This is my first soldering so don't do what I did. I put too much solder on the contacts which resulted in these little shiny balls of solder. For proper soldering, I followed Adafruit Guide To Excellent Soldering

Step 2: Connect the Raspberry Pi GPIO Pins to the Module

Picture of Connect the Raspberry Pi GPIO Pins to the Module

Connect the Raspberry Pi GPIO pins to the module according to the next table:

Pin name Pin

SDA --> 24

SCK --> 23

MOSI --> 19

MISO --> 21

GND --> 6

RST --> 22

3.3V --> 1

I use a breadboard in my project. The connections are implemented in the same way, though. Feel free to connect the Pi's GPIO Pins directly to the module Pins if you have female-to-female jumper cables.

Step 3: Install & Configure the Right Software

Picture of Install & Configure the Right Software
  • When you're done with the installation, open a console and hit


  • Use the interactive menu to enable the SPI Interface.
  • Reboot your PI using:

sudo reboot

  • When you login again check to see that the SPI Interface is enabled

sudo nano /boot/config.txt

Try to find a line that says:


If you see the above line then SPI is enabled

  • Save & Reboot your PI using:

sudo reboot

  • When you login again check to see that the spi_bcm2835 module is loaded

lsmod | grep spi

  • Install python2.7-dev: [thanks Teenage kicks, IngmarV2]

sudo apt-get install python2.7-dev

  • Download and Install SPI-Py executing the following commands:

git clone
cd SPI-Py

sudo python install


NOTE: You can install other python libraries too. This is just for reference.

Step 4: Acknowledgements & Helpful Links


sameera48 (author)2017-09-06

1.As connect to 7" inch LCD used resolution of 800*400 pixel &the capactive touch.HDMI and USB its working properly.

2.while using 2nd link RFID RC522 reader is working properly

3.while join the both RFID unable to Read the Tags

4.what is the steps for I2C to connect the RFID RC522 to raspberrypi which library file was installed in that

can u Checking following list may resolve

the issue.



AlishaD10 (author)2017-06-22

Thanks for the instructable! Followed all the steps but I am getting the following error:

File "", line 47

key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]


SyntaxError: invalid syntax

How can I fix this?

mbellas (author)AlishaD102017-06-23

Hi AlishaD10,

try to clone MFRC522-python from github again. Perhaps you edited the file?


AlishaD10 (author)mbellas2017-06-24

Thanks Michael, the error I now get is

ImportError: No module named spi

I have read about this happening (SPI issues) with the new Raspberry Pi 3...but thought these issues were resolved in the new Rasbian version.

mbellas (author)AlishaD102017-06-25

Have you followed the steps above? It seems that your SPI is not enabled? If the problem continues send me a PM,


AlishaD10 (author)mbellas2017-06-26


I enabled the SPI and double checked with lsmod | grep spi...still no joy.

I managed to get it working using some different code. -

Thanks for your help :)

vjm2 (author)2017-06-21

Thanks for this great tutorial.

I could set up my RC522 pretty fast. But how exactly can I write the RFID tag?

I tried: sudo python

Which somehow writes: Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

to the card.

But how can I add a specific value, for example my name and a number, could not find any example on google, maybe you have a good link/tutorial ?

mbellas (author)vjm22017-06-22

Ι haven't tried to write on a tag before but concerning what it does is that it writes data on the card and then deletes it (replacing it with zeros).

data = []

# Fill the data with 0x00

for x in range(0,16):


print "Now we fill it with 0x00:"

MIFAREReader.MFRC522_Write(8, data)

print "\n"

My point is that this script already writes data to your tags. Perhaps you can adapt it to your needs,


meier_jrg (author)2017-05-12

I got everythink to work with the standard tag and card (the ones that came with the RFID-RC522 module). I also have different tags (NTAG216 888 Byte) that I want to use with the module but I get authentication errors. Can you help me?

ChaitraN1 (author)2017-04-25

i followed all the steps you mentioned above but i am getting only these two lines as output. i updated and upgraded also.

Welcome to the MFRC522 data read example

Press Ctrl-C to stop.

i am not getting any uid's.

mbellas (author)ChaitraN12017-04-25

Hi ChaitraN1,

I can't give you an answer if you don't provide any info. i.e. What is your module? What version of raspbian are you using? etc


mbellas (author)mbellas2017-04-25

Hi ChaitraN1,

In the meantime I updated the instructable to use the latest raspbian version (2017-04-10). Please see if it resolves the issues you had.


DorianW4 (author)mbellas2017-04-29

I got exactly the same problem.

Followed the instruction, tripple checked the wiring, all I get is:

Welcome to the MFRC522 data read example

Press Ctrl-C to stop.

SPI Module is the spi_bcm2835

DorianW4 (author)DorianW42017-04-29

The RC522 Kit I use is this one:

DorianW4 (author)DorianW42017-05-06

Got mine to work, was a broken RC522 module.

Thanks to mbellas for the help. :)

dharris451 (author)2016-12-19

Great article mbellas.

I followed the steps of the project and now I have a raspberry (B) with connected RC522; using the example snippet I can obtain the ID code of a NFC tag (four integers, eg formatted as follows:

However, I need to read and write the contents of the tag, for instance a brief text string to be read and spoken out with text to speech software (I use Festival, correctly working on my raspberry).

The problem is that I only can read the tag ID and not other tag contents; any hint to solve this problem?

fiorenunzio (author)2016-10-24

Why it's mandatory to solder the headers in your opinion?

mbellas (author)fiorenunzio2016-10-24

Hi fiorenunzio, I think that's because the chip has a minimun voltage and current that needs to function, and if the header is not soldered the loose contacts cannot provide this. Would be great if someone could share some knowledge on the subject.


IngmarV2 (author)2016-10-05

Great article, so thank you!

Two minor additions:

* Before running git, it needs to be installed: sudo apt-get install git

* Before install SPI-py you need to install python2.7-dev: sudo apt-get install python2.7-dev

mbellas (author)IngmarV22016-10-05

Hi, IngmarV2, thanks for reporting this. I will schedule an installation from scratch to confirm the steps you and Teenage Kicks mentioned, probably missed them.


KryptonKollector (author)2016-10-03

Hi i followed all the steps i get following erroe

ImportError: No module named spi

mbellas (author)KryptonKollector2016-10-03

Hi KryptonKollector,

My guess it that the cause of this error could be hardware related. Check again that you have enabled correctly the SPI on your raspberry by hitting lsmod | grep spi.


Teenage Kicks (author)2016-09-28

Hi, Truly excellent guide, i had to make 1 change which may be worth adding, I was getting an error when I tried to install SPI-Pi with

sudo python install

i simply added python-dev with

sudo apt-get install python-dev

and everything ran perfectly

thanks for a great write up

mbellas (author)Teenage Kicks2016-09-29

Teenage Kicks, thank you for your comment. My guess is that probably you needed some python header file. I didn't have any errors in running but perhaps I already had that package installed in my Raspi.


About This Instructable




More by mbellas:Raspberry Pi 3 Model B & MIFARE RC522 RFID Tag Reading
Add instructable to: