gailu Posted February 12, 2017 Posted February 12, 2017 Hi Experts, I am using Readily available MFRC522 NFC reader board. It works fine on Raspberry Pi but we are not able to read card on Orange Pi Zero. I followed steps in the below posts. Both are same and person posted confirmed that it works for him https://forum.armbian.com/index.php/topic/617-wip-orange-pi-one-support-for-the-upcoming-orange-pi-one/page-9#entry5747 http://stackoverflow.com/questions/41350031/dual-rc522-on-orange-pi Person who published the post says that he tested on 5.04 and I am using image Armbian_5.24_Orangepizero_Debian_jessie_3.4.113.img We have checked wiring again and again and wiring looks all OK. read.py runs but when card is touched to the reader I do no see any output from read.py. Any idea what could be the problem?
gailu Posted February 12, 2017 Author Posted February 12, 2017 Tried with Ubuntu Xenial Image but no change in behaviour. NFC Card is not read
gailu Posted February 12, 2017 Author Posted February 12, 2017 Person who published the post says that he tested on 5.04 so I am trying to find image 5.04 to see if SPI is broken between 5.04 and 5.24/5.25. However I am not able to find 5.04 image for Orange Pi Zero. Can someone please provide any direction where could I find 5.04 image for Orange Pi Zero.
gailu Posted February 12, 2017 Author Posted February 12, 2017 I run spidev_test (https://raw.githubusercontent.com/raspberrypi/linux/rpi-3.10.y/Documentation/spi/spidev_test.c) and following is the output. Not sure how to interpret the output. Does below output look ok? spi mode: 0 bits per word: 8 max speed: 500000 Hz (500 KHz) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Igor Posted February 12, 2017 Posted February 12, 2017 There is no 5.04 for Orange Pi Zero since it was added recently and such regression would already be noticed. spidev_test produces O.K. result. Check your python scripts - beware they are not directly RPi compatible.
gailu Posted February 12, 2017 Author Posted February 12, 2017 @Igor, Can you please let me know what is the expected data for spi loopback test i.e. shorting MOSI and MISO pins. I am reading all zeros in loopback test with spidev_test.c (orange pi zero / ubuntu xenial). I would like to ensure that all is fine with SPI on Orange Pi Zero before I debug with external SPI card. For example expected data on Raspberry pi for spi loop back test is as follows as explained in (https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md) wget https://raw.githubusercontent.com/raspberrypi/linux/rpi-3.10.y/Documentation/spi/spidev_test.cgcc -o spidev_test spidev_test.c./spidev_test -D /dev/spidev0.0spi mode: 0bits per word: 8max speed: 500000 Hz (500 KHz)FF FF FF FF FF FF40 00 00 00 00 95FF FF FF FF FF FFFF FF FF FF FF FFFF FF FF FF FF FFDE AD BE EF BA ADF0 0D
zador.blood.stained Posted February 12, 2017 Posted February 12, 2017 @gailu SPI bus 0 on Zero is wired to the SPI flash, and the bus available on the headers is SPI 1 (so it should be /dev/spidev1.0 if it is enabled), so please make sure that you are using the correct SPIdev device.
gailu Posted February 12, 2017 Author Posted February 12, 2017 @zador.blood.stained Thanks for the details. I thinks I was missing this main information that you just provided. Everywhere I read that SPI readily available on OPis and I see /dev/spidev0.0 on plain vanilla image so I thought that this is what I need to use. My bad My loopback test is successful now
gailu Posted February 12, 2017 Author Posted February 12, 2017 This is to confirm that now I can read the NFC card through MFRC-522. @zador.blood.stained You are awesome. Thank you so much.
msev Posted February 12, 2017 Posted February 12, 2017 Gailu can you please describe the exact steps on which commands you need to type that you got this working? Do you use RC-522 in python?
gailu Posted February 12, 2017 Author Posted February 12, 2017 @msev Sure, because of forum help I got it working so its my turn to help others. Yes, I use RC-522 in python. Here are steps. 1. Install Armbian image for orange pi zero. Please use Ubuntu Xenial (not the debian jessie). Reason for Ubuntu Xenial instead of debian jessie is that in debian jessie image by default only spi0 is enabled so you will only see /dev/spidev0.0 while in ubuntu xenial image you will see two entries /dev/spidev0.0 and /dev/spidev1.0 we need /dev/spidev1.0 as explained by zador.blood.stained. If you know how to enable spi1 in debian jessie, you may go for that too (its not available out of the box currently) 2. Make Connection as follows MOSI ——————————> pin 19 MISO ——————————-> pin 21SCLK ——————————-> pin 23SDA ——————————–> pin 24RST ———————————> pin 22IRQ ———————————-> NONE 3. Install all the required stuff as follows a) apt-get update b )apt-get install python-dev c) git clone https://github.com/duxingkei33/orangepi_PC_gpio_pyH3.git d) cd orangepi_PC_gpio_pyH3 e) python setup.py install f) cd .. g) git clone https://github.com/lthiery/SPI-Py.git h) cd SPI-Py i) python setup.py install j) cd .. k) git clone https://github.com/mxgxw/MFRC522-python.git l) cd MFRC522-python 4. Now its time to edit MFRC522.py. I am providing the diff with the original. < import pyA20.gpio as GPIO --- > import RPi.GPIO as GPIO 110c110 < def __init__(self, dev='/dev/spidev1.0', spd=1000000): --- > def __init__(self, dev='/dev/spidev0.0', spd=1000000): 112,114c112,114 < # GPIO.setmode(GPIO.BOARD) < # GPIO.setup(22, GPIO.OUT) < # GPIO.output(self.NRSTPD, 1) --- > GPIO.setmode(GPIO.BOARD) > GPIO.setup(22, GPIO.OUT) > GPIO.output(self.NRSTPD, 1) 384c384 < # GPIO.output(self.NRSTPD, 1) --- > GPIO.output(self.NRSTPD, 1) 5. Now Run Read.py root@orangepizero:~/MFRC522-python# python Read.py Welcome to the MFRC522 data read example Press Ctrl-C to stop. Card read UID: 186,123,162,171 Size: 8 Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 2
GokhanGokce Posted April 23, 2017 Posted April 23, 2017 @gailu I have tried your method on Orange Pi Zero. And it didnt worked. Armbian has 2 version for Orange pi zero (5.25 and 5.24). I also tried both of them and it didnt worked for me. also spi output is always 0. Does anybody advice sth about orange pi zero? thanks
StuxNet Posted June 13, 2017 Posted June 13, 2017 @gailu Quote Sure, because of forum help I got it working so its my turn to help others. Yes, I use RC-522 in python. These directions no longer work as of 3.4.113-sun8i Ubuntu Xenial 16.04 What version of Ubuntu were you running when it worked? I second GokhanGokce, in saying that, "spi output is always 0." Any thoughts are welcome. This is the 2nd SPI/Armbian project that might sit in a drawer for quite awhile.
StuxNet Posted June 13, 2017 Posted June 13, 2017 I got a MFRC522 module working on Orangepi Zero. I could get really long winded about how it took 3-4 tutorials, hopping around between GPIO libraries getting irritated with people for not posting kernel specifics and referring to Orangepi Zero/PC/One simply as 'OrangePi' but I'm not going to. Instead I took the information I gleaned, put it all together in one spot, all nice and tidy for the community. All in all the steps are pretty similar to what I found here, other forums and tutorials. Except uses a better GPIO library specifically for the Orangepi Zero. Not a clone of RPI.GPIO, ported to Orangepi PC, ported to the Zero. So give this guy some credit! https://github.com/rm-hull/OPi.GPIO You can download, install all dependencies and start reading tags with this one line. It goes without saying that it should be executed as root. git clone https://github.com/BiTinerary/OrangePiZeroMFRC522.git && bash ./OrangePiZeroMFRC522/getAllTheStuff.sh All the source of that one liner as well as pinout etc... is available at this repo.https://github.com/BiTinerary/OrangePiZeroMFRC522 1
martinayotte Posted June 13, 2017 Posted June 13, 2017 How this new OPi.GPIO library is related to SPI ?
Recommended Posts