Pigpio permission bloqued for my actual user on Raspberry-pi

211 Views Asked by At

I am trying to read GPIO port 5 on a Raspberry pi, after trying some packages like onoff I decided to use Pigpio. It does connect to GPIO but the problem is that I dont have permissions for that user. It says:

Sorry, you don't have permission to run this program Try running as root, e.g precede the command with sudo. /home/pi/IsriBruster-service/node_modules/pigpio/pigpio.js:54 pigpio.gpioInitialise();

The code I run for calling gpio is the next one:

const Gpio = require('pigpio').Gpio
const gpio5 = new Gpio(5, {mode: Gpio.OUTPUT});
console.log(gpio5.pwmRead());

Thank you for your help!

1

There are 1 best solutions below

0
SrArkaitz On BEST ANSWER

I tried this with the onoff library and it worked finally:

const Gpio = require('onoff').Gpio;
const gpio5 = new Gpio(24,'out');
io.sockets.emit('gpio',res)