Skip to main content

Drop-in replacement for RPi.GPIO supporting Orange Pi and other SBCs

Project description

OPi.GPIO

My attempt at maintaining OPi.GPIO for at least the Orange Pi Zero 2W pin map.

A drop-in replacement library for RPi.GPIO for the Orange Pi Zero and other SBCs. Only the basic GPIO functions are replicated, using sysfs: this allows the GPIO pins to be accessed from user space.

See the documentation for install instructions and detailed API usage. Note: this documentation is not specific to this fork.

Installation

In the virtual environment that you are using for your project, run:

pip3 install OPi.GPIO-ex

OPi.GPIO is now accessible like this:

import OPi.GPIO as GPIO
import orangepi.zero2w

GPIO.setmode(orangepi.zero2w.BOARD)
# or GPIO.setmode(orangepi.zero2w.BCM)

# setup inputs, outputs, event detection etc as per the documentation linked above

Notes

Non-Root Access

OPi.GPIO generally needs root access, but this might be inconvenient in some cases. The official documentation has instructions for non-root access, but this solution did not work correctly for me, so your mileage may vary here.

Running a Python script with sudo does not work correctly when a virtual environment is activated. However, you can run sudo venv/bin/python3 myscript.py which will work correctly. This is my (probably not best-practices) solution for the time being. It does not, however, allow you to run it without root entirely.

Testing

Only tested with my Orange Pi Zero 2W and a e-Paper module (see Waveshare_e-Paper, not finished yet)

Changelog

Version Description Date
0.5.5 Add OrangePi Zero 2W pin mappings 2023/12/26
0.5.4 Add OrangePi Zero3 pin mappings 2023/08/06
0.5.3 Add Radxa Zero pin mappings
Add OrangePi Zero2 pin mappings 2022/06/20
0.5.2 Add full 40-pin header for Orange Pi 4(B) 2021/10/22
0.5.1 Updated Orange Pi 4B mappings 2021/08/19
0.5.0 Add Hardware PWM Control
Add support for the NanoPi M4 family
Add OrangePi 4 & 4B pin mappings
Add rockpi/rockpi s packages added
Fix OrangePi PC BCM Pin map 2021/04/25
0.4.0 Add various new pin mappings for Orange Pi variants 2019/10/21
0.3.6 Expose pullup resistor constants to API users
Add OrangePi Prime pin mappings 2019/01/14
0.3.5 Add OrangePi Lite & One pin mappings 2018/11/10
0.3.4 Add more OrangePi and NanoPi pin mappings 2018/09/16
0.3.3 Add waits for UDEV rules 2018/09/15
0.3.2 Add OrangePi PC pin mappings 2018/03/04
0.3.1 Add NanoPi DUO pin mappings 2018/01/01
0.3.0 Add alternate pin mappings 2017/12/31
0.2.5 sysfs: set output() value to 0 or 1 2017/07/15
0.2.4 Add compatibility for pull up/down and bouncetime params 2017/05/27
0.2.3 Make worker threads daemonic (can't exit otherwise) 2017/05/26
0.2.2 GPIO.setup() catches IOError and re-exports 2017/03/28
0.2.1 Minor bug fixes
Additional tests 2017/03/14
0.2.0 Add edge detection and eventing 2017/03/14
0.1.0 Initial version 2017/03/11

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opi_gpio_ex-0.5.5.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

opi_gpio_ex-0.5.5-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file opi_gpio_ex-0.5.5.tar.gz.

File metadata

  • Download URL: opi_gpio_ex-0.5.5.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for opi_gpio_ex-0.5.5.tar.gz
Algorithm Hash digest
SHA256 f5886b84794108b2534336e7554cac1303f50a39ebd468e1e5569190e3f4eb17
MD5 c848a74442060fdb4c67c78ebe24c786
BLAKE2b-256 1fc069fe66cec4b7f2090673d511174bd604c502d3179857b03d34eff131d8e8

See more details on using hashes here.

File details

Details for the file opi_gpio_ex-0.5.5-py3-none-any.whl.

File metadata

  • Download URL: opi_gpio_ex-0.5.5-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for opi_gpio_ex-0.5.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5451603975331941c75efbd388c03462efc9f52542ccb5e8c8ec38fc41246803
MD5 bf3a9e27d0571d725a24a378edd6e24f
BLAKE2b-256 572b0d6d46ca46c5e7314fc38f738a31803511e5b108a4c6711fe0e8bb723989

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page