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!
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)