Orange Pi One/Lite (Tutorial): use the GPIO in Python, pinouts

orange pi one lite raspberry gio python
Table of Contents
drapeau france
level advanced
orange pi lite review unboxing

Orange Pi has a 40-pin extension connector (GPIO) compatible with the Raspberry Pi (model B +). In this tutorial, we will install python as well as the pyA20 library adapted to the GPIO of Orange Pi. On paper, the connector is compatible, only flat the call of the pins is different which requires to resume Python programs developed for The Raspberry. This is a bit of a shame but the very attractive price of the Orange Pi range remains a weighty argument.

For this tutorial, I used Armbian installed on an Orange Pi Lite (Wi-Fi version). The GPIO is the same throughout the Orange Pi range except the Orange Pi Zero which has a 26-pin GPIO.

Installing Python and Libraries

Let’s start by preparing the environment by installing Python

sudo apt-get install python-dev

Then install the pyA20 library

sudo pip install pyA20

Now we need to install the library to manage the Orange Pi GPIO. Place yourself in your home folder (eg /home/ft) and then clone the pyH3 library ( This is an adaptation made by Duxingkei Chow of the library “python control orangepi_PC ext GPIO ALLwinner H3” based on the “pyA20 0.2.1” library.

cd /home/pi
git clone

Enter the library directory

cd orangepi_PC_gpio_pyH3

And run the installation (it is better to do the previous command with a sudo if you are not logged in as root).

sudo python install

Correspondence of pins between Orange Pi and Raspberry Pi (model B+)

As I mentioned in the introduction, the expansion slot is compatible with the Raspberry B + (40-pin). However, the location is different.

Raspberry Pi Orange Pi Pin

(Left column)


(Right column)

Orange Pi Raspberry Pi
3V3 1 2 +5V  +5V


PA12 3 4 +5V  +5V


PA11 5 6 GND GND
GPIO4 PA6 7 8 PA13 GPIO14


GND GND 9 10 PA14 GPIO15


GPIO17 PA1  11 12 PD14 GPIO18


GPIO27 PA0  13 14 GND GND
GPIO22 PA3  15 16 PC4 GPIO23
3V3 3V3  17 18 PC7 GPIO24


PC0 19 20 GND GND


PC1 21 22 PA2 GPIO25


PC2 23 24 PC3 GPIO8


GND GND 25 26 PA21 GPIO7




PA19 27 28 PA18 ID_SC


GPIO6 PA8 31 32 PG8 GPIO12
GPIO13 PA9 33 34 GND GND
GPIO19 PA10 35 36 PG9 GPIO16
GPIO26 PA20 37 38 PG6 GPIO20
GND GND 39 40 PG7 GPIO21

Just like the Raspberry Pi, the output voltage is 3.3V.

Finally the last difference (and not least!), The connector is turned 180 degrees compared to that of the Raspberry. Needless to say that it will be necessary to use a connection for breadboard with a flexible cable if you want to connect the Orange to a breadboard (breakout) connection.

Lighting a Python Led

For this first tutorial on the GPIO of Orange Pi, we will not go far. Either way it’s exactly the same as Raspberry. There is only the call of the pins that differs.

Create a new file. For example


Paste the following code and save with Ctrl + X then Y. This code is very simple, it lights for 2 seconds a LED connected to the PG7 pin (equivalent to the Raspberry GPIO21). Connect a LED on pin PG7 (the last one in the right column) to a GND via a 220Ω resistor.

#import the library / Import des librairies
from pyA20.gpio import gpio
from pyA20.gpio import port
from time import sleep

#initialize the gpio module / initialise le GPIO

#setup the port (same as raspberry pi's gpio.setup() function)
#Configure la broche PG7 (equivalent au GPIO21 du Raspberry) comme une sortie
gpio.setcfg(port.PG7, gpio.OUTPUT)

#now we do something (light up the LED)
#Maintenant, on allume la LED
gpio.output(port.PG7, gpio.HIGH)

#turn off the LED after 2 seconds
#Et on eteint après 2 secondes
gpio.output(port.PG7, gpio.LOW)

We make the script executable

chmod +x

If you are not logged in as root, you must preface the python command with a sudo (you will be prompted for the password).

sudo python

If the wiring is correct, the LED must illuminate for 2 seconds.

orange pi one lite raspberry gio python

Click to enlarge

Now you have everything you need to use the Orange Pi GPIO. It’s a shame the calls are different. Existing programs will not be directly usable. Other regret, the rotation of the connector makes the use of HAT boards much less convenient (and compact!)

Orange Pi Comparison Chart

  • Model
  • SoC
  • RAM
  • eMMC storage
  • WiFi
  • Bluetooth
  • GPRS
  • FCC/CE certificated
  • Connector (!not compatible with Raspberry Pi)
  • Misc
  • Best prices


[2017/08/10] – Install pyA20 library manually. Thank’s to Daniel

Click to rate this post!
[Total: 0 Average: 0]

Thanks for your reading

Did you like this project ? Don't miss any more projects by subscribing to our weekly newsletter!

Are you having a problem with this topic?

Maybe someone has already found the solution, visit the forum before asking your question
  1. Reply
    John Alejandro Valero Henao 5 May 2017 at 10 h 12 min

    Hola amigo, configure una Orangepi One nueva con Armbian server, ya lo actualice y sigo tus pasos pero me da este error..
    File “”, line 2
    from pyA20.gpio import gpio from pyA20.gpio import port
    Gracias de antemano por la ayuda.

    • Hi John Alejandro, I had the same problem. First you have to install python-pip to manage python modules

      > sudo apt-get install python-pip
      Then install the module pyA20 to run the sample.

      > sudo pip install pyA20

      Hope it helps,

  2. Can you help me i get a segmentation fault error.

Leave a Reply

Read more
DIY Projects
DIY Projects
%d bloggers like this: