loading

*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 on 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

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

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

  • When you're done with the installation, open a console and hit

raspi-config

  • 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:

dtparam=spi=on

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 https://github.com/lthiery/SPI-Py.git
cd SPI-Py

sudo python setup.py install

python Read.py

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

<p>i followed all the steps you mentioned above but i am getting only these two lines as output. i updated and upgraded also.</p><p><strong>Welcome to the MFRC522 data read example</strong></p><p><strong>Press Ctrl-C to stop.</strong></p><p><strong>i am not getting any uid's.</strong></p>
<p>Hi ChaitraN1,</p><p>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</p><p>Michael</p>
<p>Hi ChaitraN1, </p><p>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.</p><p>Michael </p>
<p>Great article mbellas.</p><p>I followed the steps of the project and now I have a raspberry (B) with connected RC522; using the example snippet Read.py I can obtain the ID code of a NFC tag (four integers, eg formatted as follows: 136.34.54.67). </p><p>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). </p><p>The problem is that I only can read the tag ID and not other tag contents; any hint to solve this problem?</p>
<p>Why it's mandatory to solder the headers in your opinion?</p>
<p>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.</p><p>Michael</p>
<p>Great article, so thank you!</p><p>Two minor additions:</p><p>* Before running git, it needs to be installed: sudo apt-get install git</p><p>* Before install SPI-py you need to install python2.7-dev: sudo apt-get install python2.7-dev</p>
<p>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.</p><p>Michael</p>
<p>Hi i followed all the steps i get following erroe </p><p>ImportError: No module named spi</p>
<p>Hi KryptonKollector,</p><p>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.</p><p>Michael</p>
<p>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 </p><p>sudo python setup.py install</p><p>i simply added python-dev with </p><p>sudo apt-get install python-dev</p><p>and everything ran perfectly</p><p>thanks for a great write up</p>
<p>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 setup.py but perhaps I already had that package installed in my Raspi. </p><p>Michael</p>

About This Instructable

13,976views

18favorites

License:

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