Jump to content

Recommended Posts

Posted

Hello,

 

I would like to connect RFID-RC522 to OPI 3 LTS

 

My wiring as bellow

VCC -> Pin 1

GND -> Pin 9

MOSI -> Pin19

MISO -> Pin21

SDA -> Pin24

SCK -> Pin23

RST  None

 

I wired it based on this chart

h6-26p-pi3-649x400.png

 

Then I edit the armbianEnv.txt  added

 

Quote

overlays=spi-spidev
param_spidev_spi_bus=1

 

Reboot .

 

But still not see the /dev/spi 

 

Where am I wrong?

Posted (edited)

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.

Edited by Luc
Posted

I tried the RC522 module with a Raspberry Pi 4 (Raspbian 11, Linux raspberrypi 5.15.32-v7l) and it works without issues.

 

I don't know what I could try next with the Orange Pi 3 LTS.

Posted

The RC522 module works on the OPi 3 LTS with the current Debian Bullseye image from Orange PI (Linux orangepi3-lts 5.16.17-sun50iw6, from http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/service-and-support/Orange-pi-3-LTS.html).

 

To enable SPI I added overlays=spi-spidev1 to /boot/orangepiEnv.txt (adding param_spidev_spi_bus is not needed). Then I used the same steps as I outlined in my post above.

 

Sadly I don't know how to help fix this in Armbian, maybe the solution is somewhere here https://github.com/orangepi-xunlong/orangepi-build/blob/main/external/packages/pack-uboot/sun50iw6/bin/dts/orangepi3-lts-u-boot.dts.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines