Orange Pi GPIO. Digital input/output for most Pi computers
Control I/O for Digital Pins
There are two nodes, one for output and one for input. These are Node-RED nodes that interface GPIO pins on Orange Pi boards as well as on other Pi's.
These nodes are using the great onoff library, which includes the pins via the sysfs filesytem. Therefore, it should work on all platforms that support sysfs.
To check out, if everything is working correctly, first you should make a short test as user root. In order to use GPIO also as a standard user without root rights, some conditions have to be fulfilled.
- The user group
gpiomust exist and the user must belong to this group.
- The kernel must map gpio access to the user space, but this is not necessarily always the default behaviour.
To meet these requirements for user
pi, run this commands as root:
Check if user
pi belongs to
$ groups pi
Otherwise, run this:
$ addgroup gpio $ usermod -a -G gpio pi
pi is not allowed to use GPIO now, additional steps are required:
Create a new file:
$ touch /etc/udev/rules.d/99-com.rules
copy this text to the file:
KERNEL=="gpio*", RUN="/bin/sh -c 'chgrp -R gpio /sys/%p /sys/class/gpio && chmod -R g+w /sys/%p /sys/class/gpio'"
$ service udev restart
or better do a reboot.
This is tested on Orange Pi PC. Compared to the solution, which is provided for Raspberry Pi, this way is much more efficient. The whole code runs direct in Node.js and uses kernel live support. But Raspberry Pi I/O nodes create for each pin an own shell and run a not so lightweighted Python process in it...