Orange ft One / Lite (tutorial): use the GPIO in Python, pins (pinout) [Exclusive Guide]
Orange Pi for an extension connector ( GPIO ) 40 pin compatible with that of the Raspberry Pi (model B +). In this tutorial, we will install python so that the bookstore pyA20 adapted to the GPIO of Orange Pi. On paper, the connector is compatible, only flat call of the pins is different what needed to resume the Python programs developed for the Raspberry. It’s a shame but the very attractive price of the Orange IP range remains a strong argument.
Let’s start by preparing the environment by installing Python
sudo apt – get install python – dev
now we need to install the library that allows to manage the GPIO of Orange Pi. Place you in your Home (for example/home/pi) folder and then clone the library pyH3 ( https://github.com/duxingkei33/orangepi_PC_gpio_pyH3 ). It is an adaptation by Duxingkei Chow of the ‘python control orangepi_PC ALLwinner H3 ext GPIO’ library based on the bookstore “pyA20 0.2.1.
cd / home / pi
git clone https://github.com/duxingkei33/orangepi_PC_gpio_pyH3
enter the directory of the library
and start the installation (it is preferable to previous order by a sudo if you are not connected as root).
sudo python setup . py install
as I mentioned in the introduction, the expansion slot is compatible with that of the Raspberry models B + (40 pins). The location, however, is different.
|Raspberry Pi||Orange Pi|| pin
|Orange Pi||Raspberry Pi|
|3V3||1||2||+ 5V||+ 5V|
|PA12||3||4||+ 5V||+ 5V|
I2C EEPROM ID
I2C EEPROM ID
just like on the Raspberry Pi, the output voltage is 3, 3V.
finally last difference (!) and the connector is turned 180 degrees compared with the Raspberry. Mean will necessarily be required to a sign for breadboard with a tablecloth flexible If you want to connect the Orange to a breadboard (breakout) of connection
for this first tutorial on the GPIO of Orange Pi, we’re not going very far. Anyway it is exactly the same as for the Raspberry. It’s the call of the pins that differs.
create a new file. For example test.py
, paste the following code and save with Ctrl + X then Y. This code is very simple, it turns on for 2 seconds a Led connected to pin PG7 (equivalent to the GPIO21 of the Raspberry). Connect a Led on pin PG7 (the last of the right column) to a GND through 220Ω resistance.
#import the library / Import des librairies
from pyA20 . gpio import gpio
from pyA20 . gpio import port
from time import sleep
#initialize the gpio module / Initializes the GPIO
gpio . init ()
#setup the port (same as raspberry pi’s gpio.setup () function)
#Configure PG7 (equivalent to the GPIO21 of the Raspberry) pin as an output
gpio . setcfg (port.[) PG7 , gpio . OUTPUT )
#now we do something (light up the LED)
#Maintenant, we light the LED
gpio . output (port.[) PG7 , gpio . HIGH )
#turn off the LED after 2 seconds
#Et we turned off after 2 seconds
gpio . output (port.[) PG7 , gpio . LOW )
we make the script executable
you not logged as root, should precede the python of a sudo command (the password you will be asked).
if the wiring is correct, the Led should light for 2 seconds.
that is, you have now all what you need to use the GPIO of Orange Pi. It is a pity that the calls are different. Existing programs are not directly usable. Another regret, the rotation of the connector that makes use of the cards much less convenient (and compact!) HAT