This is how to do it in OrangePi Zero 3, pin 8 PH2:
In Bash as root:
# addgroup --system gpio
# chown root:gpio /dev/gpiochip0
# chmod 660 /dev/gpiochip0
# nano /etc/udev/rules.d/61-gpio-tools.rules
{add line SUBSYSTEM=="gpio",KERNEL=="gpiochip*", GROUP="gpio", MODE="0660"}
# usermod -a -G gpio myusername
# apt install python3-dev
# reboot
In a new folder for your Python script, as normal user:
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install gpiod
Create script (example in https://pypi.org/project/gpiod/ with one fix):
$ nano blink_pin.py
import time
import gpiod #needed in example
from gpiod.line import Direction, Value
#Calculating PH2 "line" number
#H=8
#2=2
#line=(8-1)x32+2=226
#also shown in https://github.com/rm-hull/OPi.GPIO/issues/79
LINE = 226
with gpiod.request_lines(
"/dev/gpiochip0",
consumer="blink-example",
config={
LINE: gpiod.LineSettings(
direction=Direction.OUTPUT, output_value=Value.ACTIVE
)
},
) as request:
while True:
request.set_value(LINE, Value.ACTIVE)
time.sleep(1)
request.set_value(LINE, Value.INACTIVE)
time.sleep(1)
Run script:
$ python3 blink_pin.py
When done working with your project:
$ deactivate
Pin 8 PH2 turns ON and OFF 😄
I haven't tested the other pins yet