2 months ago, I configured my raspberry to use GPIO. I don't remember exactly what I did, but I do remember needing to configure something to enable GPIO. It worked great.

2 months later and multiple reboots, the code fails on the first 2 line. I'm at a loss to figure out why this is failing. I am suspecting the GPIO are no longer enabled.

I could use some pointer being that I'm a newbie.

var fs = require('fs'),
var valuefd = fs.openSync('/sys/class/gpio/gpio5/value', 'r'),

I run this code with sudo node xxxx and the following error is produced

ENOENT: no such file or directory, open 'sys/class/gpio/gpio5/value'

When I do a sudo ls /sys/class/gpio, I get the following:

export gpiochip0 unexport

I don't see gpio5

When i do a sudo ls /sys/class/gpio/gpio5, I get the following:

ls: cannot access /sys/class/gpio/gpio5: No such file or directory

Any help or suggestions where to poke next would be appreciated.

I'm running the OS that came with the raspberry pi. I believe this is Debian.


While I am not using pi-gpio, I did experiment with pi-gpio. It would appear a side effect of using pi-gpio.open is to create an entry in /sys/class/gpio/gpio5

I ran sudo node

require('pi-gpio').open(29, 'input', function(err){console.log(err)})

then magically the entry appeared in /sys/class/gpio/gpio5 and my program started working.

  • Because pins manipulated via sysfs must be exported before they can be used: kernel.org/doc/Documentation/gpio/sysfs.txt I.e., you can accomplish the same thing by writing 5 (plus a newline) to /sys/class/gpio/export.
    – goldilocks
    Aug 22 '16 at 18:31
  • 1
    This question has been bumped to the homepage as its been inactive for a while without an answer being marked as correct. If what you outlined in your answer solved your problem, please mark it as correct.
    – Darth Vader
    Feb 5 '17 at 12:14

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.