2
$ echo "1" > /sys/class/gpio/gpio17/value
echo: write error: Operation not permitted

Doing sudo -i to log in as root ends up the same.

$ ls -ll /sys/class/gpio/gpio17/
-rwxrwx--- 1 root gpio 4096 Okt  7 18:05 active_low  
lrwxrwxrwx 1 root gpio    0 Okt  7 18:05 device -> ../../../gpiochip0  
-rwxrwx--- 1 root gpio 4096 Okt  7 18:05 direction  
-rwxrwx--- 1 root gpio 4096 Okt  7 18:05 edge  
drwxrwx--- 2 root gpio    0 Okt  7 18:05 power  
lrwxrwxrwx 1 root gpio    0 Okt  7 18:05 subsystem -> ../../../../../../../class/gpio  
-rwxrwx--- 1 root gpio 4096 Okt  7 18:05 uevent  
-rwxrwx--- 1 root gpio 4096 Okt  7 18:42 value

The user pi is a member of this groups:

$ grep 'pi' /etc/group
adm:x:4:pi
dialout:x:20:pi,openhab
cdrom:x:24:pi
sudo:x:27:pi
audio:x:29:pi
video:x:44:pi
plugdev:x:46:pi
games:x:60:pi
users:x:100:pi
input:x:105:pi
netdev:x:109:pi
pi:x:1000:openhab
spi:x:999:pi
i2c:x:998:pi
gpio:x:997:pi,openhab
openhab:x:114:pi

This problem occurs from time to time and after a reboot it is gone. Can someone help me fix this so this issue doesn't reoccur?

Update: Now it also happends on pin 4, 25

5
  • You need to show us the permissions when the write fails. In particular your user (whoami), your groups (groups), the command you issue and the response, and the listing of the directory.
    – joan
    Commented Oct 7, 2019 at 16:58
  • 1
    Is that GPIO configured to be an output? If it's an input, this error appears. # echo out >/sys/class/gpio/gpio17/direction
    – Janka
    Commented Oct 7, 2019 at 21:21
  • 1
    @Janka, you are right that was the problem. Thank you very much. Commented Oct 7, 2019 at 21:59
  • Nice answer. Perhaps @Janka can modify his comment to an answer, and #echo out accepts the perfect answer. Then future newbies/ninjas can learn one more trap/trick.
    – tlfong01
    Commented Oct 8, 2019 at 2:32
  • It was only a lucky guess, but I made it an answer now we found it was correct.
    – Janka
    Commented Oct 8, 2019 at 2:40

1 Answer 1

1

Is that GPIO configured to be an output? If it's an input, this error appears.

Try

# echo out >/sys/class/gpio/gpio17/direction

to make GPIO17 an output.

If you have this problem only sometimes, there may be another program running mangling your GPIOs.

1
  • Yes this seams to be a problem with the gpio binding of openhab. Commented Oct 8, 2019 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.