JamesBarwell / rpi-gpio.js

Control Raspberry Pi GPIO pins with node.js
MIT License
657 stars 116 forks source link

EACCES error on fresh installation #104

Open IonicaBizau opened 4 years ago

IonicaBizau commented 4 years ago

I have a fresh installation of Ubuntu Mate 20.04 and I installed rpi-gpio and ran the following:

const GPIO = require("rpi-gpio").promise                     
const BULB_PIN = 15;                                         

(async () => {                                               
        await GPIO.setup(BULB_PIN, GPIO.DIR_OUT)             
        console.log(await GPIO.read(BULB_PIN))                // => false
        await GPIO.write(BULB_PIN, true)                     // This errors
})()                                                         

UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, open '/sys/class/gpio/gpio22/value'

Running node v10.19.0 installed via apt-get and the npm installation finished successfuly.

Also, using a similar Python script works fine without root privileges.

How can I run rpi-gpio without root privileges?