I'm also trying to get an RC522 working on a OPi 3 LTS, no luck so far. I'm using Armbian 22.05.4 Bullseye.
The SPI interface seems to work, i enabled it as described above. The loopback test works successfully (https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#loopback-test). When connecting MOSI and MISO:
luc@jb:~/spitest$ sudo ./spidev_test -D /dev/spidev1.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)
FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
DE AD BE EF BA AD
F0 0D
luc@jb:~$ uname -a
Linux jb 5.15.48-sunxi64 #22.05.3 SMP Wed Jun 22 07:33:24 UTC 2022 aarch64 GNU/Linux
I tried various libraries that can be found online. For example, the steps described at https://forum.armbian.com/topic/9730-enable-spi0-on-orange-pi-pc-with-armbian-575.
- cloned https://github.com/lthiery/SPI-Py, sudo python3 setup.py install
- sudo pip3 install OPi.GPIO
- cloned https://github.com/kwanxian/OrangePiPC
I applied the following changes:
luc@jb:~/next/OrangePiPC/SPI/RC522$ git diff -U1
diff --git a/SPI/RC522/MFRC522.py b/SPI/RC522/MFRC522.py
index 7024d2d..89d27e6 100644
--- a/SPI/RC522/MFRC522.py
+++ b/SPI/RC522/MFRC522.py
@@ -24,2 +24,3 @@
import OPi.GPIO as GPIO
+import orangepi.pi3
import spi
@@ -129,7 +130,7 @@ class MFRC522:
- def __init__(self, dev='/dev/spidev0.0', spd=1000000):
+ def __init__(self, dev='/dev/spidev1.0', spd=1000000):
global spidev
spidev = spi.openSPI(device=dev, speed=spd)
- GPIO.setboard(GPIO.PCPCPLUS)
- GPIO.setmode(GPIO.BOARD)
+ #GPIO.setboard(GPIO.PCPCPLUS)
+ GPIO.setmode(orangepi.pi3.BOARD)
GPIO.setup(22, GPIO.OUT)
I connected the RC522 module according to https://github.com/mxgxw/MFRC522-python#pins (same as https://pimylifeup.com/raspberry-pi-rfid-rc522/)
Then running the script
luc@jb:~/next/OrangePiPC/SPI/RC522$ sudo python3 Read.py
Welcome to the MFRC522 data read example
Press Ctrl-C to stop.
... and nothing happens when bringing a tag / card close to the reader.
GPIO seems to work as expected, after starting the script I see
luc@jb:~$ gpio exports
GPIO Pins exported:
13(117): out 1
Next I will try if the RC522 module works with a RPi 4.