Easy GPIO Python Library

I’m looking for a GPIO library in the style of the RPi.GPIO library. It seems that the standard for controlling GPIO pins on the libre hardware is libgpiod library. The only wrappers I’ve found for this don’t do much to improve the ease-of-use of this library. I was wondering if anyone has already written a direct replacement for the RPi.GPIO using libgpiod in the backend. With hardware like the Le Potato being sold as an alternative for Raspberry Pis, I think it would make sense to have such a thing. If that doesn’t exist, would anyone be willing to contribute to such a project?

1 Like

The problem is that I don’t know Python. A GPIO library is pretty stupid simple. Maybe will learn Python and hack together a library with static lookups.

There were a few options bounced around in the Armbian forums some time ago, the only one currently worked on is Java, GitHub - sgjava/javauio: Java UIO provides high performance Java interfaces for Linux Userspace IO.

Previously I had helped a tiny bit with pyGPIO - A 'more general' python GPIO library - Reviews, Tutorials, Hardware hacks - Armbian Community Forums

I’m not sure it even uses modenr methods for accessing the GPIO though, I can’t remember.

1 Like

Just put a wrapper around the gpio.maps in libretech-wiring-tool and save some handles to reduce grepping through the file. This should be pretty simple.

What a disappointment this card, they promise something and it is the least that can be used, there is no way to make the GPIOs work

libgpiod is the modern, easy, upstream python library. We even provide a lookup tool to covert headers to GPIO chip/line. Your statement has no basis.

the base that I have is that it simply does not work, I had to finally buy orangepi and raspberry cards and they work. They should make things easier and not so mysterious or complicated.

This is already covered here: How to control GPIO via Python 3

There is nothing mysterious or complicated about libgpiod. This is the de-facto library for upstream Linux.

A few easy alternatives are mentioned in the comments in the link @librecomputer posted. I have used Adafruit Blinka and the board digitalio modules to good effect. I also just took the time to dig into libgpiod, and its not as scary as it seems. It’s worth learning for portabilty reasons and to better understand the hardware.

Examples of simple blink scripts in using lipgpiod and digitaio are in the aforementioned comments.

There is Adafruit Blinka which is basically circuit python but for SBC’s and the Le Potato is supported, and you can use circuit python libraries with it, i have tested DisplayIO which is a driver for a bunch of display types, to give you an idea on how easy it is, here is a blink example:

import time
import board
import digitalio

PIN = board.P22

led = digitalio.DigitalInOut(PIN)
led.direction = digitalio.Direction.OUTPUT

while True:
    led.value = True
    time.sleep(0.5)
    led.value = False
    time.sleep(0.5)