Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to get wiring Pi Python libraries on Orange PI with armbian

Overview

Use my fork of the Wiring-Pi Python library which checks out the WiringOP fork of the WiringPi library as a submodule to build everything. yes that's a little confusing

The WiringPI library is the original C library that RaspGPIO is somewhat based on. WiringPi was built to replicate arduino GPIO functions

In Raspberry Pi Land there are 2 normal python paths for GPIO. One is Raspi.GPIO and the other is WiringPI

Known Success

I built this on an Orange Pi One running Armbian Jessie

Pieces

WiringOP C library

WiringOP is a fork of the Banana Pi fork of the WiringPI Library

https://github.com/zhaolei/WiringOP

WiringPi-Python Library

WiringPi-Python is python binding to the C library. The github release uses a submodule and checks out the WiringPi library directly. My fork updates the submodule ot the wiringOP library, and removes a few incompatible includes that keeps the python library from building

https://github.com/lanefu/WiringPi-Python-OP

Install

Build / Install Commands

# install build requirements
sudo apt-get install python-dev python-setuptools swig -y

# download my fork of the wiringpy-python build that contains submodile to wiringOP library
git clone --recursive https://github.com/lanefu/WiringPi-Python-OP.git

# build C and install both Wiring Pi C library and Python
cd WiringPi-Python-OP
cd WiringPi/
sudo ./build
cd ..
export CFLAGS="-lwiringPi -lwiringPiDev"
swig2.0 -python wiringpi.i
sudo python setup.py install

# enable gpio kernel module
sudo sed -i 's/\#gpio_sunxi/gpio_sunxi/g' /etc/modules
sudo modprobe gpio_sunxi
@marksev1

This comment has been minimized.

Copy link

@marksev1 marksev1 commented Jul 27, 2016

So it would be really nice if you could provide some examples of use (maybe geared to iot) for example stdin from some terminal app display on a i2c lcd display (with that pcf i2c backpack)?

What about that smbus python package which is meant for i2c, does that work on orange-pi? How do I know when I see a python project dealing with hardware that I know it works with orange pi? The ones with "import RPi.GPIO as GPIO" all are incompatible right? How do I port WiringOPI to them?

@lanefu

This comment has been minimized.

Copy link
Owner Author

@lanefu lanefu commented Jul 29, 2016

All i've done with GPIO is make lights blink.. I was just really determined to get Python libraries working for GPIO.. You're probably more qualified to make such examples .. anyway there are 2 flavors of libaries for GPIO for Pi (See top of doc) One is The RPi.GPIO and the other is WiringPi...

There's another python library http://orange314.com/Orange_Pi_GPIO_Python_Library that's suppose to be easier to port RPi.GPIO stuff

@visionimpaired

This comment has been minimized.

Copy link

@visionimpaired visionimpaired commented Sep 18, 2016

Hi - I am using this library on my M1. I can use it with all of the pins (ports) starting with A - like port.PA8,port.PA21,port.PA20,port.PA19
But I can't get it to work with pin 7 (G11) or 19 (C0). Can you help me with the syntax or other ways to use it? Thanks.

@thk4711

This comment has been minimized.

Copy link

@thk4711 thk4711 commented Nov 5, 2016

Hi,
i have managed to install a wiring Pi version for my Orange Pi lite following this tutorial. The basic examples with inputs and outputs are working fine. Since I want to use a rotary encoder and not loose any steps I want to use a interrupt driven callback. There is an example as well but that does not work.
I get: wiringPiISR: unable to open /sys/class/gpio/gpio25/value: No such file or directory
Anything I could do here ?
Thanks - Thomas

@marksev1

This comment has been minimized.

Copy link

@marksev1 marksev1 commented Nov 16, 2016

Will there be also a version for Orange Pi Zero please? From zhaolei and from you lanefu. Lanefu do you maybe know how I could contact zhaolei to ask him regarding version for Orange Pi Zero?

@DaniyalGeek

This comment has been minimized.

Copy link

@DaniyalGeek DaniyalGeek commented Dec 12, 2016

@marksev1

did it work on your zero ?

@infeeeee

This comment has been minimized.

Copy link

@infeeeee infeeeee commented Feb 25, 2017

Change the requirements line pls, swig to swig2.0.
sudo apt-get install python-dev python-setuptools swig2.0 -y

@eadmaster

This comment has been minimized.

Copy link

@eadmaster eadmaster commented Dec 11, 2017

Hi, is it possible to control the GPIO pins as a regular user (without sudo)?
I've tried commenting the root check in wiringpi.c, and now it fails because it cannot access /dev/mem.

EDIT: i had a better luck with the gpio command + setuid, so i've made a wrapper library for it.

@abstract17

This comment has been minimized.

Copy link

@abstract17 abstract17 commented May 9, 2019

Does it work for Orange Pi 2g-Iot board??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.