MagicMirror² v2.13.0 is available! For more information about this release, check out this topic.

PIR-Sensor with relay

  • Hi all,

    I try to run a relay which is cutting down the power to my lcd monitor. The PIR-Sensor module works fine as long as i don’t use the relayPin command. I get the following error message in the logs:

    { Error: EPERM: operation not permitted, write
    at Object.fs.writeSync (fs.js:707:3)
    at Gpio.writeSync (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/onoff/onoff.js:243:8)
    at Class.activateMonitor (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_helper.js:27:24)
    at /home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_helper.js:124:30
    at gpio._listeners.slice.forEach.callback (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/onoff/onoff.js:135:9)
    at Array.forEach ()
    at pollerEventHandler (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/onoff/onoff.js:134:32) errno: -1, syscall: ‘write’, code: ‘EPERM’ }

    Can somebody tell me what to do?

  • @PottiMc i would guess that you have the wrong pin for the relay

    from the onoff library

    Note that EPERM: operation not permitted, write isn't actually related to permissions. An EPERM error occurs when an operation is not permitted because it doesn't make sense. In this case it looks like the EPERM error occurred because an an attempt was made to write data to an input. Here's an example:
    pi@raspberrypi:~ $ cd /sys/class/gpio/
    pi@raspberrypi:/sys/class/gpio $ echo 17 > export 
    pi@raspberrypi:/sys/class/gpio $ cd gpio17
    pi@raspberrypi:/sys/class/gpio/gpio17 $ echo in > direction 
    pi@raspberrypi:/sys/class/gpio/gpio17 $ echo 1 > value 
    -bash: echo: write error: Operation not permitted
    pi@raspberrypi:/sys/class/gpio/gpio17 $ 
    Errors related to permissions are usually EACCES errors.

  • Thank you. I managed it! The problem was that my start script didn’t switch the gpio to output correctly. You gave me the right direction.

  • @PottiMc awesome… glad it worked out

Log in to reply