2


Yesterday I bought the famous RC552 RFID read/write module to use with my Raspberry Pi 2B (I've also got an Arduino in the mail right now) and I've been trying to get it to work but I just can't. I started by installing python-dev. I then installed SPI-PY by downloading it from GitHub (https://github.com/lthiery/SPI-Py) and used sudo python setup.py install to install it. I then connected the module to my Pi using this diagram: enter image description here

Then, I downloaded this library from GitHub (https://github.com/mxgxw/MFRC522-python) and ran the Read.py example application to try it out. Upon doing so, I got the following message: can't open device: no such file or directory. The program then halted. I tested to see if it was a line of code causing the problem, by placing the command print "Test" at the top of the document. I saw the following:

Test
can't open device: no such file or directory

I definitely know it's something in the code now. I moved my print command down the document, until it was under this line:

MIFAREReader = MFRC522.MFRC522()

Once it was under this, I only saw the error message. So I know it's this line.
I decided to try a different project, so I downloaded this one (https://github.com/ondryaso/pi-rc522). I ran the Read.py, but got the same message.
What's going on? Did I do something wrong? Your help would be greatly appreciated.

Apologies for putting the links as code, the editor said I couldn't post more than 2 links because my rep is below 10.

  • 1
    At a guess the SPI devices aren't present so leading to can't open device: no such file or directory. Could you edit your question and add the result of "ls -l /dev/spi*" without the quotes. Similarly add the result of "uname -a" and "cat /etc/os-release". – joan Oct 6 '15 at 8:50
  • Also, can you double-check your wiring? The diagram you use has the correct wiring, but a simple mistake can be enough for SPI to not recognize a device. Make sure you have the orientation of the GPIO header correct - pin 1 is located close to where the SD card goes, with pin 40 close to the USB ports. Early rPi's (model A/B) had a marking on the board next to P1 but this has been dropped on the rPi 2 model B. – Phil B. Oct 6 '15 at 12:34
  • joan - the result of ls -l /dev/spi tells me that /dev/spi doesn't exist. Maybe that's where the error is coming from? uname -a gives Linux raspberrypi 4.1.7-v7+ #817 SMP PREEMPT Sat Sep 19 15:32:00 BST 2015 armv7l GNU/Linux and cat /etc/os-release gives PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs" – techhead287 Oct 9 '15 at 1:41
  • I have found this to be a great related article ... raspmer.blogspot.de/2015/07/… – Kolban Jan 21 '16 at 15:50
4

Make sure the SPI Interface is enabled:

Edit the file /boot/config.txt and add the following two lines:

device_tree_param=spi=on
dtoverlay=spi-bcm2708

Reboot the Pi and check if the SPI Interface software is running:

$ dmesg | grep spi

You should see something like:

[    8.577659] bcm2708_spi 20204000.spi: master is unqueued, this is deprecated
[    8.578491] bcm2708_spi 20204000.spi: SPI Controller at 0x20204000 (irq 80)

You can also check:

$ lsmod

which should list:

spi_bcm2708             5429  0

I found this solution here and it worked for me.

0

To get this working, the easiest is to fire up the graphical environment and go to menu->Preferences->Raspberry Pi configuration and there enable in the interface tab the spi line....

the diagram you show is for the old raspberries, the new one have 40pins, not 25

  • 1
    Hello and welcome to rpi.se. Most of this is probably better suited as a comment than as an answer. Answers should not be used for requesting additional information from the questioner - that is better suited as a comment, nor to open a discussion about possible solutions - that is better suited as a chat. Consider editing your answer so that it is an answer to the question, and move the other parts. – Bex Jan 11 '16 at 8:37

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.