[Solved] The GPIO channel has not been set up as an OUTPUT

What is the problem?
Can't use any plugin using GPIO
What did you already try to solve it?


Running Octopi as root
Logs (octoprint.log, serial.log or output on terminal tab, ...)

2019-07-08 22:26:31,111 - octoprint.plugins.enclosure - INFO - Setting GPIO mode to BCM
2019-07-08 22:26:31,117 - octoprint.plugins.enclosure - INFO - Setting GPIO pin 26 as OUTPUT with initial value: 1
2019-07-08 22:26:31,285 - octoprint.plugins.enclosure - WARNING - An exception of type RuntimeError occurred on write_gpio when writing on pin 26. Arguments:
('The GPIO channel has not been set up as an OUTPUT',)

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, ...)
Latest firmware, Raspberry Pi 2

You might try running this manually using sudo from the command prompt.

# Temporarily elevate our rights to become root
sudo -i
# Export pin 26 so that it appears in the device tree
echo "26" > /sys/class/gpio/export
# Set GPIO 26 as an output port
echo "out" > /sys/class/gpio/gpio26/direction
# Exit from our elevated rights shell
exit

Working great, any way for making it permanent (on reboot ect...) ?

Let's see... I think the pin export is persistent; it will continue to report the pin status to the device tree after a reboot. And I see no reason why the direction wouldn't persist. Why not reboot it and do a cat /sys/class/gpio/gpio26/direction to verify that it's still set to out?

cat: /sys/class/gpio/gpio26/direction: No such file or directory

after reboot.

root@octopi:~# echo "26" > /sys/class/gpio/export
root@octopi:~#
root@octopi:~# cat /sys/class/gpio/gpio26/direction
in

Wow, it looks like something changed in Raspbian so that the device tree state doesn't persist between boots.

Try this:

sudo nano /etc/rc.local
...and add this:

echo "26" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio26/direction

And then reboot with sudo reboot. In theory, rc.local runs as root so you wouldn't need to sudo inside that.

I did what you said, after a week and multiple reboot, everything hold up, thanks !

1 Like