for all OrangePI users, if you are using plugins (or developing ones) that use GPIO pins to do stuff (like for e.g. you want to attach filament sensor to octoprint https://github.com/arhi/Octoprint-Filament-Reloaded-OrangePi ) till recently OPi.GPIO library had a bad race condition bag that was preventing non-root user to properly access GPIO pins and a hack with adding a pause had to be done for any GPIO access to work. With release v0.3.4 this is finally solved so you can properly use GPIO on OPI boards
To setup OPI boards so that pi user can access the GPIO, the copy of the manual from library:
If you want to be able to use the library as a non root user, you will need to setup a UDEV
rule to grant you permissions first. This can be accomplished as follows:
$ sudo usermod -aG gpio <current_user>
$ sudo nano /etc/udev/rules.d/99-gpio.rules
That should add your user to the GPIO group, create a new UDEV
rule, and open it in the Nano text editor. Enter the following into Nano
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:gpio /sys/class/gpio/export /sys/class/gpio/unexport ; chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'"
SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:gpio /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value ; chmod 660 /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value'"
press ctrl-x
, Y
, and ENTER
to save and close the file. Finally, reboot and you should be ready to use OPi.GPIO
as a non root user.