RC522 RFID Reader connected to Pi 4b does not want to read my card or tags

66 Views Asked by At

I'm at my wits end, I've been trying to connect my RC522 module to my RPI 4b, running Debian GNU/Linux 11 (bullseye). I've been trying to use a loopback test on my SPI and it works, but the code below provided by ChatGPT here doesn't seem to work when I try to send data over SPI using spidev.

Expected output is supposed to be:

Received: [0xAA]
Received: [0xAA]
Received: [0xAA]
...

Actual output:

Received: [0]
Received: [0]
Received: [0]
...

The code:

import spidev
import time

spi = spidev.SpiDev()
spi.open(0, 0)  # Open SPI bus 0, device 0

try:
    while True:
        data = spi.xfer2([0xAA])  # Send 0xAA over SPI
        print("Received:", data)
        time.sleep(1)

except KeyboardInterrupt:
    pass

finally:
    spi.close()

I've been following the Pi My Life Up tutorial on how to connect the RC522 with a Pi here. The reader does not want to read my RFID card and RFID tag at all. I've tried 3 different tags already to no avail.

My SPI is enabled and I can see the "spi_bcm2835" on my pi's lsmod.

0

There are 0 best solutions below