I'm trying to have a python script access GPIO pins on an Odroid XU4, which requires sudo. I want to simply blink a GPIO pin from off to on, then back off again. The python script is fine, but it asks for a password when I run it.
I've edited my sudoers file using visudo
to not require passwords, for GPIO access. From previous blogs I've found that the order of the sudoers directives are important and have taken that into consideration. My current sudoers file is as follows:
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
username ALL=NOPASSWD: /sys/class/gpio/export
username ALL=NOPASSWD: /sys/class/gpio/gpio174/direction
username ALL=NOPASSWD: /sys/class/gpio/gpio174/value
Why am I still being prompted to enter a password when trying to access the GPIO pin 174? I've added the NOPASSWD directives after the %admin
and %sudo
lines just as other posts have suggested.