Reputation: 63
I am attempting to access gpio pin on my Raspberry pi using Node.js + the pi-gpio module but I get the following error:
"Error when trying to open pin 11" "gpio-admin: could not flush data to /sys/class/gpio/ex[prt: device or resource busy"
I've checked that directory, with pin 11 exported or unexported I still get the same error.
In-case it's the code I've attempted to convert from Python to node, here is the code for review:
var gpio = require("pi-gpio");
function motor1(){
gpio.write(7, 1, function(err){
//if err
console.log("sent 1");
});
}
function motor2(){
gpio.write(11, 1, function(err){
console.log("sent...");
});
}
gpio.open(7);
gpio.open(11);
motor1();
motor2();
Upvotes: 4
Views: 4988
Reputation: 181
Have you still got it open from a previous session? I had the same issue when I hadn't closed it before,
Trying running the following at the end of your program, after your motor1 and 2 calls:
gpio.close(pin);
Because they are already open you may still see the error first time you run it, so check on the 2nd run
Upvotes: 3