Python and GPIO in OpenWrt

I'm trying to access GPIO using Python on the Espressobin board. Python is installed and all, but I'm stuck trying to find the right kind of library to address these GPIO pins in Python within OWRT. Most are written for RPi. Any ideas?

python status often very release specific... that said 'finding libraries' is a job for pip search...

1 Like

Thank you. I never tried Pip search, only used it to install packages but that was a good direction.

Found the library gpio4, that works with this board using Linux sysfs interface. Once the pin "index" numbers are figured out, such as Pin 466 on Header J18, here's an example code that works:

>>> from gpio4 import SysfsGPIO
>>> pin_num = 466
>>> pin = SysfsGPIO(pin_num)
>>> pin.export = True
>>> pin.direction = 'out'
>>> pin.value = 1
>>> pin.export = False # clear this pin from sysfs

Install using pip install gpio4

GPIO voltage on Espressobin V7 is 1.8 volts

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.