2

How do I set the pullup using /sys/class/gpio/gpio$PIN/

echo 1 > /sys/class/gpio/gpio$PIN/value

does not seem to work.

6

I'm not sure that you can set the internal pull-up/pull-downs via the sysfs interface. I have never done so, but I don't often use sysfs.

From the command line there are many methods. The following examples assume Broadcom gpio 4.

pigpio

pigs pud 4 u # up
pigs pud 4 d # down
pigs pud 4 o # off

raspi-gpio

raspi-gpio set 4 pu # up
raspi-gpio set 4 pd # down
raspi-gpio set 4 pn # off

wiringPi

gpio -g mode 4 up # up
gpio -g mode 4 down # down
gpio -g mode 4 tri # off
  • Correct, you can't set the pull-ups or any alt functions via /sys. You can only set the direction and check/set the value. – goldilocks Sep 20 '15 at 11:50
  • I have created a script using gpio, which works, but I was hoping there was a method not dependant on installing other software. There seems to be a dearth of documentation on the /sys interface. – Milliways Sep 21 '15 at 4:40
  • Documentation for the generic kernel GPIO interface in /sys is in the vanilla source tree, [src]/Documentation/gpio/sysfs.txt (also online). It's not specific to the pi, which is why it doesn't include stuff like the pull-ups or alt functions. The people responsible for the rpi kernel could have elaborated upon this and created a kernel driver for the pi, but AFAIK they didn't and neither did anyone else -- there is just the various userspace libraries. – goldilocks Sep 21 '15 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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