Skip to main content

Hello GPIO

We are flooded with GPIO information from RaspberryPi. Then we learned that OrangePi GPIO pin layout is compatible with RaspberryPi, but with some subtle difference in naming convention. If you are RaspberryPi fans, you will find it more difficult to use OrangePi GPIO, not only the naming is different, but you have to use another set of library calls. Also, the pin layout is upside down.

This is how I setup GPIO in Python 3.

First, prepare the Python environment,

$ sudo apt-get install python3-setuptools
$ sudo apt-get install python3-dev

Then, install the pyA20 library,

$ sudo pip3 install pyA20

Now install the library to manage the Orange Pi GPIO.

$ cd
$ git clone https://github.com/duxingkei33/orangepi_PC-gpio_pyH3
$ cd orangepi_PC_gpio_pyH3
$ sudo python3 setup.py install

Here is the test program to turn LED ON/OFF every second,

#!/usr/bin/env python3

# Turn LED On/Off with PA
# Kevin Lee 31 Dec 2019

# Connect LED to OpiZ pin 25 (GND) & 26 (PA10)

from pyA20.gpio import gpio
from pyA20.gpio import port
from time import sleep

gpio.init()
gpio.setcfg(port.PA10, gpio.OUTPUT)
while True:
    gpio.output(port.PA10, gpio.HIGH)
    print('ON')
    sleep(1)
    gpio.output(port.PA10, gpio.LOW)
    print('OFF')
    sleep(1)



This is the pinout of Orange Zero Pi,


Lee Sir,
31 December 2019
Hong Kong.



Reference:

Orange Pi One/Lite (Tutorial): use the GPIO in Python, pinouts, 15 January 2017, https://diyprojects.io/orange-pi-onelite-tutorial-use-gpio-python-pinouts/#.XgsDjvwRXIV


Update 28 March 2020:

Sad to say this library only works for 32bit sunxi processors, 64 bits SoCs like OrangePi Lite 2, are not supported.

Comments

Popular posts from this blog

Install/Setup Xfce and TightVNC to Armbian OrangePi

Following https://www.instructables.com/id/The-OrangePi-Lite/ , the next instruction after network started is usually VNC server setup. Many Internet resources suggested TightVNC, an open source software for this purpose. However, Armbian distribution for OrangePi does not include any X window desktop, therefore install TightVNC itself is just half of the journey. This is how I complete the work. 1. Make sure Armbian is updated: sudo apt-get update sudo apt-get upgrade 2. Install XFont used by TightVNC server sudo apt-get install xfonts-base 3. Install TightVNC server sudo apt-get install tightvncserver 4. Create a user dedicate for this service. I use user ID 'vnc' sudo adduser vnc gpasswd -a vnc sudo 5. Setup this user for VNC server, vncserver :1 We need to assign a password. No need to specify a view-only password. Use the command to confirm the server is running and the default options applied ps -ef | grep Xtightvnc 6. VNC Client can now conn...

Configure OrangePi Lite WiFi

There are many websites and Youtube videos show you how to install Armbian to OrangePi with a SD-card. There are many ways to connect to the initial console of the device. Most of them tell you to utilize the LAN interface. This is a quick and easy method, however, my OrangePi Lite simply lacks a LAN interface. We need to setup Wifi before we can use it for console connection. But without the console how can we setup Wifi connection? Finally I used a USB to TTL device. With only 3 wires I connected the device to OrangePi: Rx-Tx, Tx-Rx, and GND-GND. Then I can use PuTTY to bring up the console thru SSH. Up to this point basically I am following this website: https://www.instructables.com/id/The-OrangePi-Lite/ . I continued with the instructions and successfully connect to WiFi, but puzzle why I have do that with so many manual editings. Especially when I edit the /etc/network/interface file, it has a remark say "# Network is managed by Network manage". My question is can N...

Setup USB Camera to work in Octoprint

This passage summerize the website "Orange Pi Zero and Webcam for Octoprint", https://www.iot-experiments.com/orange-pi-zero-and-webcam-for-octoprint/, aimed to make my life easier. Check the USB webcam present, octoprint@orangepizero:~$ lsusb Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 002: ID 046d:0826 Logitech, Inc. HD Webcam C525 Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 007 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub To discover webcam information, (octoprint@orangepizero:~$sudo apt-get install hwinfo) octoprint@ora...