pythonrfidpi

MFRC522 RFID Python3 Script won't start: No such file or directory


I have the problem that the Python Scripts for the MFRC522 RFID-Reader won't start. I couldn't find any solution to this problem

I tried following this tutorial: https://pimylifeup.com/raspberry-pi-rfid-rc522

when starting the script I get this error:

pi@pi-d339203c:~/pi-rfid $ python3 Read.py
Traceback (most recent call last):
  File "Read.py", line 5, in <module>
    reader = SimpleMFRC522()
  File "/usr/local/lib/python3.5/dist-packages/mfrc522/SimpleMFRC522.py", line 14, in __init__
    self.READER = MFRC522()
  File "/usr/local/lib/python3.5/dist-packages/mfrc522/MFRC522.py", line 131, in __init__
    self.spi.open(bus, device)
FileNotFoundError: [Errno 2] No such file or directory

Solution

  • I had the same issue - turns out I had SPI disabled - it's required for the MFRC522. If you're using Raspbian, run

    sudo raspi-config
    

    and enable it in there under Interfacing options -> SPI then reboot.

    To check if spi is indeed enabled, run

    lsmod | grep spi
    

    the output should look something like this:

    spidev                 20480  0
    spi_bcm2835            20480  0
    

    If you get no output, then spi is not enabled. I believe you can also enable it by editing /boot/config.txt