Orange Pi One Python GPIO (basic)





Introduction: Orange Pi One Python GPIO (basic)

Here's how to get GPIO working in Python on the Orange Pi One.

Note. The GPIO pins on the Orange Pi One are flipped 180 degrees compared to the Orange Pi PC version or a Raspberry Pi!

check out my other Orange Pi tutorials:

Step 1: Download and Install Python Library

To start you will need the python headers and library installed, if you haven't or aren't sure just type:

sudo apt-get install python-dev

Then download the pyH3 library from:

extract the folder and place in '/home/pi'

from the terminal go into that directory:

cd orangepi_PC_gpio_pyH3

then install it using:

python install

The library is now installed.

Step 2: Test It!

The way the pins are referred to are slightly different to a Raspberry Pi, they are named "ports" & "connectors".

UPDATE 03/05/2016: The new armbian images no longer export the gpios to /gpio_sw. See the above image for the port names. Image Credit:

For example pin 29 (BCM05) is port 'PA7'

To test, connect an LED to pin 29 through a 300ohm resistor then to the ground. (see diagram below)

and created a file called '':

#import the library
from pyA20.gpio import gpio
from pyA20.gpio import port
from time import sleep

#initialize the gpio module

#setup the port (same as raspberry pi's gpio.setup() function)
gpio.setcfg(port.PA7, gpio.OUTPUT)

#now we do something (light up the LED)
gpio.output(port.PA7, gpio.HIGH)

#turn off the LED after 2 seconds
gpio.output(port.PA7, gpio.LOW)

Dont forget to make your test file executable:

chmod +x

and run as root:

sudo su

Step 3: .

That's the basics working, more advanced stuff like i2C should work aswell but I haven't tested.

Credit goes to: Duxingkei Chow and Stefan Mavrodiev (examples in git repository)



    • Paper Contest 2018

      Paper Contest 2018
    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Science of Cooking

      Science of Cooking

    We have a be nice policy.
    Please be positive and constructive.




    Hi there,

    Ive got a problem executing the file.

    I always get the error "cannot import name >gpio<"

    Can someone help me here? Thanks

    Hi Fleder,
    I had the same issue. The cause was I created the file in the same directory ('home/pi' ) as the pyA20 module source.

    Moving the '' file to a different directory resolved the issue.

    Hello dave,

    thank you very much!
    I will try it out and hope it will resolve this issue.
    I have the .py in the same directory, too.

    Thanks and have a nice day!

    hello Fleder,

    when I use python3(#!/usr/bin/env python3),it caused the same issue.

    and when i change to the python2(#!/usr/bin/env python),it works quite well.

    so there is a doubt

    ,"maybe this module is not compatible for python3".

    Hi there,

    I'm having the error "error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1"

    when I'm trying to install the library with "python install"

    Do I need some dependencies?


    Your error tells me that you've probably not installed the python-dev library, which is mentioned in the very first step.

    sudo apt-get install python-dev

    hi, having trouble with the tutorial. when i get to the part where i run the "python intall" i get an error, "permission denied". i have so far followed the steps exactly but i dont know what im doing wrong?


    Thank you for this statement

    Note. The GPIO pins on the Orange Pi One are flipped 180 degrees compared to the Orange Pi PC version or a Raspberry Pi

    been hunting everywhere for a diagram that tells me where Pin1 is in
    relation to actual board (plenty of schematics of pins but not in
    relation to where they are on the physical board). I thought the arrow was probably P1 but unlike RPi where P1 P2... are labelled properly,
    OPi doesn't (and the arrow "P1" is flipped 180 compared to RPi thus my

    Hello, i followed your guide but i stuck in:

    from: can't read /var/mail/pyA20.gpio
    from: can't read /var/mail/pyA20.gpio
    from: can't read /var/mail/time
    ./ line 10: syntax error near unexpected token `gpio.setcfg'
    ./ line 10: `gpio.setcfg(port.PA7, gpio.OUTPUT)'

    Can you help me? I'm absolutely beginner at orangepi pc.

    I had the issue on my Orange Pi lite running Lubuntu solved it by using "python" to execute the script!

    This happens because the default shell will execute it and it will bail out at the from keyword (Incidentally, from is the name of a command line utility which prints names of those who have sent mail to the given username, so that's why it tries to access the mailboxes.

    Hope this helps! :)