AndreWicked
-
Posts
16 -
Joined
-
Last visited
Content Type
Forums
Store
Crowdfunding
Applications
Events
Raffles
Community Map
Posts posted by AndreWicked
-
-
Explain it on your fingers, or I do not understand. How can I make my python script run when I turn on my NanoPI, without logging in, without entering a login, password?
-
On 5/7/2018 at 2:07 AM, latze said:
Hi @all,
I currently try to build a door-opener with a NanoPi Neo and a MFRC522 Rfid-Module.
Unfortunately I don't get the SPI working.
I loaded the newest Armbian-Debian from the Website:
uname -r = 4.14.18-sunxi
and downloaded the SPI-library for NanoPi:
https://github.com/wertyzp/WiringNP
By using
armbian-config
I activated "pwm", "sei-add-cs1", "spi-jedec-nor" and "spi-spidev".
The problem:
If I try to activate SPI with
gpio load spi
I get the following error-message:
modprobe: FATAL: Module spi-sun7i not found in directory /lib/modules/4.14.18-sunxi gpio: Unable to load spi-sun7i
So it seems that wiringNp doesn't use "spi-dev" but "spi-sun7i" and I tried to install it from source from:
https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/A20/A20-build-3.4.90/spi-sun7i.c
Unfortunately I can't find out how to write the Makefile so that I can compile the .ko-file and install the driver.
Can you help me writing the Makefile or have another idea how I could solve the problem?
Thanks in advance and greetings,
Latze
Pay attention to the theme I created, I got it and there I brought libraries that used.
https://forum.armbian.com/topic/7635-rfid-mfrc522-on-nanopi-neo/
-
15 minutes ago, martinayotte said:
Still Unbelievable ...
You got proper "dir" with "from pyA20.spi import spi" instead of "from pyA20 import spi" instead of "from pyA20 import spi" but still got that "Segmentation fault".
Do you have set overlays properly ? what does "ls /dev/spidev*" report ?
Still, I don't understand why the "from pyA20.spi import spi" was required, maybe bug introduced since I last fetch that library ...
Just in case, here is my orangepi_PC_gpio_pyH3-master.zip I'm using since Nov 2015 ...
Everything turned out with RPi.GPIO_NP library
https://github.com/chainsx/RPi.GPIO.NP
SPI-Py Library
https://github.com/lthiery/SPI-Py.git
And
https://github.com/BiTinerary/OrangePiZeroMFRC522
On NanoPi Neo, the libraries from OrangePi Zero are completely suitable, even the pinouts are the same.
root@NanoPi-NEO:~/OrangePiZeroMFRC522/MFRC522-python# sudo python Read.py Welcome to the MFRC522 data read example Press Ctrl-C to stop. Card detected Card read UID: 194,86,17,48 Size: 8 Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
You can fix it somewhere, if anyone else needs to implement an RFID reader with NanoPi Neo, since it takes very little space
Thank you for your help!
-
18 minutes ago, AndreWicked said:
I copied your code:
#!/usr/bin/python from pyA20 import spi data = [0x00,0x01,0x02,0x03,0x04,0x05] print dir(spi) spi.open("/dev/spidev0.0") spi.write(data) data = spi.xfer(data, len(data)) spi.close() print data
and run it
root@NanoPi-NEO:/# sudo python test_spi.py ['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__'] Traceback (most recent call last): File "test_spi.py", line 8, in <module> spi.open("/dev/spidev0.0") AttributeError: 'module' object has no attribute 'open'
You had an error in this line.
from pyA20 import spi
I changed to
from pyA20.spi import spi
And got this error
root@NanoPi-NEO:/# sudo python test_spi.py ['__doc__', '__file__', '__name__', '__package__', 'close', 'open', 'read', 'write', 'xfer'] Segmentation fault
-
21 minutes ago, martinayotte said:
Unbelievable !
You must have done a typo somewhere ...
Just to prove that do the following before the "open" :
print dir(spi)
I copied your code:
#!/usr/bin/python from pyA20 import spi data = [0x00,0x01,0x02,0x03,0x04,0x05] print dir(spi) spi.open("/dev/spidev0.0") spi.write(data) data = spi.xfer(data, len(data)) spi.close() print data
and run it
root@NanoPi-NEO:/# sudo python test_spi.py ['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__'] Traceback (most recent call last): File "test_spi.py", line 8, in <module> spi.open("/dev/spidev0.0") AttributeError: 'module' object has no attribute 'open'
-
6 hours ago, martinayotte said:
You're right ! I've mentioned I2C simply because I saw Igor talking about it in his first reply ...
For SPI, you need to add spidev overlay in your /boot/armbianEnv.txt along with proper parameters. (refer to : https://docs.armbian.com/User-Guide_Allwinner_overlays/ )
Then, you can try this small SPI loopback script to verify :
#!/usr/bin/python from pyA20 import spi data = [0x00,0x01,0x02,0x03,0x04,0x05] spi.open("/dev/spidev0.0") spi.write(data) data = spi.xfer(data, len(data)) spi.close() print data
Traceback (most recent call last): File "test_spi.py", line 5, in <module> spi.open("/dev/spidev0.0") AttributeError: 'module' object has no attribute 'open'
-
1 hour ago, martinayotte said:
If you wish to test some gpio pins, here a small flasher script :
#!/usr/bin/python import time from pyA20.gpio import gpio from pyA20.gpio import port gpio.init() gpio.setcfg(port.PA20, gpio.OUTPUT) while True: gpio.output(port.PA20, gpio.LOW) time.sleep(0.25) gpio.output(port.PA20, gpio.HIGH) time.sleep(0.25)
If you wish to send something on I2C port, you will have to study the RFID-MFRC522 datasheet to figure out what to send and what to retrieve...
But here is at least small example how to initialize some other kind of I2C devices, here is another flasher script working with a MCP23017 GPIO expander :
#!/usr/bin/env python import time from pyA20 import i2c i2c.init("/dev/i2c-1") i2c.open(0x20) i2c.write([0x00, 0x00]) i2c.write([0x01, 0x00]) while True: i2c.write([0x12, 0x0F]) i2c.write([0x13, 0x0F]) time.sleep(0.15) i2c.write([0x12, 0xF0]) i2c.write([0x13, 0xF0]) time.sleep(0.15)
Thank you, it worked. Last question, you write that RFID Reader needs to be connected by I2C, and on many forums write about SPI, I'm a little confused. Will you prompt?
-
21 hours ago, martinayotte said:
Since NanoPi-Neo is using H3 SoC, you can use this python library :
https://github.com/duxingkei33/orangepi_PC_gpio_pyH3
It's working, but how I may to check my gpio?
-
1 hour ago, AndreWicked said:
root@nanopineo:/# sudo git clone https://github.com/duxingkei33/orangepi_PC_gpio_pyH3 Cloning into 'orangepi_PC_gpio_pyH3'... remote: Counting objects: 61, done. remote: Total 61 (delta 0), reused 0 (delta 0), pack-reused 61 Unpacking objects: 100% (61/61), done. Checking connectivity... done. root@nanopineo:/# cd orangepi_PC_gpio_pyH3/ root@nanopineo:/orangepi_PC_gpio_pyH3# python setup.py install running install running build running build_py creating build creating build/lib.linux-armv7l-2.7 creating build/lib.linux-armv7l-2.7/pyA20 copying pyA20/__init__.py -> build/lib.linux-armv7l-2.7/pyA20 creating build/lib.linux-armv7l-2.7/pyA20/gpio copying pyA20/gpio/__init__.py -> build/lib.linux-armv7l-2.7/pyA20/gpio running build_ext Detected processor: Allwinner sun8i Family (Probably Allwinner H3) building 'pyA20.gpio.gpio' extension creating build/temp.linux-armv7l-2.7 creating build/temp.linux-armv7l-2.7/pyA20 creating build/temp.linux-armv7l-2.7/pyA20/gpio arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pyA20/gpio/gpio_lib.c -o build/temp.linux-armv7l-2.7/pyA20/gpio/gpio_lib.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pyA20/gpio/gpio.c -o build/temp.linux-armv7l-2.7/pyA20/gpio/gpio.o pyA20/gpio/gpio.c:25:20: fatal error: Python.h: No such file or directory compilation terminated.
Tell me please what is the problem?
Sorry,
apt-get install python-dev
solved the problem.
-
19 hours ago, martinayotte said:
Since NanoPi-Neo is using H3 SoC, you can use this python library :
https://github.com/duxingkei33/orangepi_PC_gpio_pyH3
root@nanopineo:/# sudo git clone https://github.com/duxingkei33/orangepi_PC_gpio_pyH3 Cloning into 'orangepi_PC_gpio_pyH3'... remote: Counting objects: 61, done. remote: Total 61 (delta 0), reused 0 (delta 0), pack-reused 61 Unpacking objects: 100% (61/61), done. Checking connectivity... done. root@nanopineo:/# cd orangepi_PC_gpio_pyH3/ root@nanopineo:/orangepi_PC_gpio_pyH3# python setup.py install running install running build running build_py creating build creating build/lib.linux-armv7l-2.7 creating build/lib.linux-armv7l-2.7/pyA20 copying pyA20/__init__.py -> build/lib.linux-armv7l-2.7/pyA20 creating build/lib.linux-armv7l-2.7/pyA20/gpio copying pyA20/gpio/__init__.py -> build/lib.linux-armv7l-2.7/pyA20/gpio running build_ext Detected processor: Allwinner sun8i Family (Probably Allwinner H3) building 'pyA20.gpio.gpio' extension creating build/temp.linux-armv7l-2.7 creating build/temp.linux-armv7l-2.7/pyA20 creating build/temp.linux-armv7l-2.7/pyA20/gpio arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pyA20/gpio/gpio_lib.c -o build/temp.linux-armv7l-2.7/pyA20/gpio/gpio_lib.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pyA20/gpio/gpio.c -o build/temp.linux-armv7l-2.7/pyA20/gpio/gpio.o pyA20/gpio/gpio.c:25:20: fatal error: Python.h: No such file or directory compilation terminated.
Tell me please what is the problem?
-
9 hours ago, martinayotte said:
Since NanoPi-Neo is using H3 SoC, you can use this python library :
https://github.com/duxingkei33/orangepi_PC_gpio_pyH3
Thanks, I will try.
-
14 minutes ago, Igor said:
We deal with board hardware issues and OS. I rarely use Python and I am sure those libraries can be easily installed but this I don't know. You can also do some search or wait for someone that plays with this.For setting GPIO on and off you don't need any libs http://linux-sunxi.org/GPIO
Now I understand. Thank you very much, I will understand further.
-
26 minutes ago, Igor said:
I2C protocol, which is needed for this device, is supported but disabled by default. Use armbian-config to enable the appropriate I2C port or edit .fex file (decompile-edit-compile) /boot/script.bin if you are using old legacy 3.4.y kernel.
RPi GPIO is on Raspberry Pi.
I am not aware of Python libraries, but officially is this what you get: https://github.com/friendlyarm/WiringNPThanks for the quick response. But can you explain it to me then? http://wiki.friendlyarm.com/wiki/index.php/RPi.GPIO_:_NanoPi_NEO/NEO2/Air_GPIO_Programming_with_Python
As I understand in the official ROMs there is support RPi.GPIO.
-
Hello everybody! Can I read data from the RFID-MFRC522 module with my NanoPi, if so, tell me what python libraries are in Armbian or will it be necessary to install an official ROM and work through RPi.GPIO?
Autostart python scripts
in Beginners
Posted
It turned out to be added to the autorun, thanks, but the problem now is different, if you run the script from the root's folder, Autorun does not work, and if from the user's folder, the information from the reader is not written to the file. How I may to fix this?