I need some major help with setting up and MFRC522 RFID reader with my Raspberry Pi 4 (Rpi4). I have been trying for many days to get it to work correctly and have been unsuccessful. I would describe myself as a beginner working with the Rpi4. I apologize in advance if the formatting of my post is not up to standard. Please feel free to give advice as to how I can organize this post better.
I am currently (desperately!) trying to execute the following code. It is found here: https://github.com/ondryaso/pi-rc522/bl ... es/Read.py. Here is the code as I personally have copied it:
Code: Select all
#!/usr/bin/env python
import signal
import time
import sys
from pirc522 import RFID
run = True
rdr = RFID()
util = rdr.util()
util.debug = True
def end_read(signal, frame):
global run
print("\nCtrl+C captured, ending read.")
run = False
rdr.cleanup()
sys.exit()
signal.signal(signal.SIGINT, end_read)
print("Starting...")
while run:
rdr.wait_for_tag()
(error, data) = rdr.request()
if not error:
print("\nDetected: " + format(data, "02x"))
(error, uid) = rdr.anticoll()
if not error:
print("Card read UID: " + str(uid[0]) + "," + str(uid[1]) + "," + str(uid[2]) + "," + str(uid[3]))
print("Setting tag...")
util.set_tag(uid)
print("\nAuthorizing...")
#util.auth(rdr.auth_a, [0x12, 0x34, 0x56, 0x78, 0x96, 0x92])
util.auth(rdr.auth_b, [0x74, 0x00, 0x52, 0x35, 0x00, 0xFF])
print("\nReading...")
util.read_out(4)
print("\nDe-authorizing...")
util.deauth()
time.sleep(1)
Upon executing this code, I receive the following error in the terminal window:
Code: Select all
Traceback (most recent call last):
File "Final_Boss.py", line 10, in <module>
rdr = RFID()
File "/usr/local/lib/python3.7/dist-packages/pirc522/rfid.py", line 47, in __init__
self.spi.open(bus, device)
FileNotFoundError: [Errno 2] No such file or directory
------------------
(program exited with code: 1)
Press return to continue
To try and give you some more information, here are the outputs of some terminal commands:
pi@raspberrypi:/ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
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"
pi@raspberrypi:/ $ lsmod | grep spi
spi_bcm2835 20480 0
pi@raspberrypi:/ $ dmesg | grep spi
[ 7.780193] ads7846 spi0.1: spi0.1 supply vcc not found, using dummy regulator
[ 7.780296] ads7846 spi0.1: Linked as a consumer to regulator.0
[ 7.787201] ads7846 spi0.1: touchscreen, irq 57
[ 7.787700] input: ADS7846 Touchscreen as /devices/platform/soc/fe204000.spi/spi_master/spi0/spi0.1/input/input8
[ 8.375316] graphics fb1: fb_ili9486 frame buffer, 480x320, 300 KiB video memory, 32 KiB buffer memory, fps=33, spi0.0 at 16 MHz
pi@raspberrypi:/ $ sudo nano /boot/config.txt
# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on
pi@raspberrypi:/ $ lsmod
Code: Select all
Module Size Used by
rfcomm 49152 4
bnep 20480 2
hci_uart 40960 1
btbcm 16384 1 hci_uart
serdev 20480 1 hci_uart
bluetooth 389120 29 hci_uart,bnep,btbcm,rfcomm
ecdh_generic 28672 1 bluetooth
fuse 110592 3
8021q 32768 0
garp 16384 1 8021q
stp 16384 1 garp
llc 16384 2 garp,stp
ads7846 24576 0
fb_ili9486 16384 1
fbtft 45056 1 fb_ili9486
syscopyarea 16384 1 fbtft
sysfillrect 16384 1 fbtft
sysimgblt 16384 1 fbtft
fb_sys_fops 16384 1 fbtft
joydev 20480 0
evdev 24576 18
brcmfmac 311296 0
brcmutil 16384 1 brcmfmac
sha256_generic 20480 0
cfg80211 614400 1 brcmfmac
rfkill 28672 6 bluetooth,cfg80211
snd_bcm2835 24576 2
bcm2835_codec 36864 0
snd_pcm 102400 1 snd_bcm2835
raspberrypi_hwmon 16384 0
i2c_bcm2835 16384 0
hwmon 16384 2 raspberrypi_hwmon,ads7846
v4l2_mem2mem 24576 1 bcm2835_codec
bcm2835_v4l2 45056 0
snd_timer 32768 1 snd_pcm
bcm2835_mmal_vchiq 32768 2 bcm2835_codec,bcm2835_v4l2
v4l2_common 16384 1 bcm2835_v4l2
snd 73728 7 snd_timer,snd_bcm2835,snd_pcm
videobuf2_dma_contig 20480 1 bcm2835_codec
videobuf2_vmalloc 16384 1 bcm2835_v4l2
videobuf2_memops 16384 2 videobuf2_dma_contig,videobuf2_vmalloc
videobuf2_v4l2 24576 3 bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem
videobuf2_common 45056 4 bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
videodev 200704 6 bcm2835_codec,v4l2_common,videobuf2_common,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
spi_bcm2835 20480 0
media 36864 2 videodev,v4l2_mem2mem
argon_mem 16384 0
vc_sm_cma 36864 1 bcm2835_mmal_vchiq
uio_pdrv_genirq 16384 0
uio 20480 1 uio_pdrv_genirq
fixed 16384 0
i2c_dev 20480 0
ip_tables 24576 0
x_tables 32768 1 ip_tables
ipv6 450560 24pi@raspberrypi:~ $ pip freeze
Code: Select all
appdirs==1.4.3
asn1crypto==0.24.0
astroid==2.1.0
asttokens==1.1.13
automationhat==0.1.0
beautifulsoup4==4.7.1
blinker==1.4
blinkt==0.1.2
buttonshim==0.0.2
Cap1xxx==0.1.3
certifi==2018.8.24
chardet==3.0.4
Click==7.0
colorama==0.3.7
colorzero==1.1
cookies==2.2.1
cryptography==2.6.1
cycler==0.10.0
Cython==0.29.10
decorator==4.3.0
docutils==0.14
drumhat==0.1.0
entrypoints==0.3
envirophat==1.0.0
ExplorerHAT==0.4.2
Flask==1.0.2
fourletterphat==0.1.0
gpiozero==1.5.1
guizero==0.6.0
html5lib==1.0.1
idna==2.6
ipykernel==4.9.0
ipython==5.8.0
ipython-genutils==0.2.0
isort==4.3.4
itsdangerous==0.24
jedi==0.13.2
Jinja2==2.10
jupyter-client==5.2.3
jupyter-core==4.4.0
keyring==17.1.1
keyrings.alt==3.1.1
Kivy==1.11.1
Kivy-Garden==0.1.4
kiwisolver==1.0.1
lazy-object-proxy==1.3.1
logilab-common==1.4.2
lxml==4.3.2
MarkupSafe==1.1.0
matplotlib==3.0.2
mccabe==0.6.1
microdotphat==0.2.1
mote==0.0.4
motephat==0.0.2
mypy==0.670
mypy-extensions==0.4.1
nudatus==0.0.4
numpy==1.16.2
oauthlib==2.1.0
olefile==0.46
pantilthat==0.0.7
parso==0.3.1
pexpect==4.6.0
pgzero==1.2
phatbeat==0.1.1
pi-rc522==2.2.1
pianohat==0.1.0
picamera==1.13
pickleshare==0.7.5
picraft==1.0
piglow==1.2.4
pigpio==1.42
Pillow==7.0.0
prompt-toolkit==1.0.15
psutil==5.5.1
pycairo==1.16.2
pycodestyle==2.4.0
pycrypto==2.6.1
pyflakes==2.0.0
pygame==1.9.4.post1
Pygments==2.3.1
PyGObject==3.30.4
pyinotify==0.9.6
PyJWT==1.7.0
pylint==2.2.2
pyOpenSSL==19.0.0
pyparsing==2.2.0
pyperclip==1.6.4
pyserial==3.4
python-apt==1.8.4
python-dateutil==2.7.3
pyxdg==0.25
pyzmq==17.1.2
qtconsole==4.3.1
rainbowhat==0.1.0
requests==2.21.0
requests-oauthlib==1.0.0
responses==0.9.0
roman==2.0.0
RPi.GPIO==0.6.5
RTIMULib==7.2.1
scrollphat==0.0.7
scrollphathd==1.2.1
SecretStorage==2.3.1
semver==2.0.1
sense-emu==1.1
sense-hat==2.2.0
simplegeneric==0.8.1
simplejson==3.16.0
six==1.12.0
skywriter==0.0.7
sn3218==1.2.7
soupsieve==1.8
SPI-Py==1.0
spidev==3.4
ssh-import-id==5.7
thonny==3.1.0
thonny-pi==1.1
tornado==5.1.1
touchphat==0.0.1
traitlets==4.3.2
twython==3.7.0
typed-ast==1.3.1
uflash==1.2.4
unicornhathd==0.0.4
urllib3==1.24.1
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.14.1
wrapt==1.10.11I am pretty sure that I have correctly enabled the SPI interface on the Rpi4, and I am also pretty sure that the physical wire connections from the RFID to the Rpi4 are correct (meaning, they are correctly made as instructed on the GitHub website above). And I am completely sure that the RFID itself is functioning correctly, as I am able to use it to turn on/off an LED when I connect it to my Arduino Uno. I am also pretty sure that I have correctly downloaded/installed all the relevant libraries. If you would like me to double-check so you can verify, please tell me how and I will do it.
If someone could help me I would be extremely grateful, as I have been trying for days to get this to work, and I am now completely lost as to why I cannot.
Thank you for your help.
EDIT: Changes made to this post to decrease it's physical length (put terminal outputs in "code" format, instead of original "quote" format).