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

Cant seem to get MMM-PIR-Sensor working



  • Using a rp3 and have a Dell monitor plugged in with a HDMI to DVI connector as this monitor doesnt have hdmi. I have tested that my pir sensor is pulling high on the gpio pin but MagicMirror will not start and throws an error. Even the MMM-PIR module I cant get to work. This is the error im seeing.

    /home/pi/MagicMirror/node_modules/electron/dist/electron js/electron.js: symbol lookup error: /home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll/build/Release/epoll.node: undefined symbol: _ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE
    npm ERR! code ELIFECYCLE
    npm ERR! syscall spawn
    npm ERR! file sh
    npm ERR! errno ENOENT
    npm ERR! magicmirror@2.9.0 start: `sh run-start.sh`
    npm ERR! spawn ENOENT
    npm ERR!
    npm ERR! Failed at the magicmirror@2.9.0 start script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /home/pi/.npm/_logs/2019-10-22T20_34_24_379Z-debug.log
    

    Also my module config is super basic as I dont need extra options right now.

    		{
    			module: 'MMM-PIR-Sensor',
    			config: {
    				// See 'Configuration options' for more information.
    			}
    		}
    

    Could anyone think of anything I could check with whats going on?



  • @mkono87 did u do

    npm install
    

    in the MMM-PIR_Sensor folder?

    it is required



  • @sdetweil said in Cant seem to get MMM-PIR-Sensor working:

    @mkono87 did u do

    npm install
    

    in the MMM-PIR_Sensor folder?

    it is required

    Of course just like the instructions said. I do get one warning though.

    npm WARN lifecycle Magic-Mirror-Module-PIR-Sensor@1.1.0~postinstall: cannot run in wd Magic-Mirror-Module-PIR-Sensor@1.1.0 electron-rebuild -e ../../node_modules/electron (wd=/home/pi/MagicMirror/modules/MMM-PIR-Sensor)
    


  • I never got that module working reliably. Here’s what I wrote instead:

    #!/usr/bin/python3
    
    # Imported Modules
    from time import sleep
    import subprocess
    import RPi.GPIO as GPIO
    
    
    # initialize GPIO
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)
    GPIO.cleanup()
    GPIO.setup(22, GPIO.IN)
    
    PIR = 22
    display_on = True
    
    while True:
    
        if display_on and not GPIO.input(PIR):
            subprocess.run("vcgencmd display_power 0 > /dev/null 2>&1", shell=True)
            display_on = False
    
        if not display_on and GPIO.input(PIR):
            subprocess.run("vcgencmd display_power 1 > /dev/null 2>&1", shell=True)
            display_on = True
            sleep(30)
    
        sleep(0.5)
    

    Save this in your home directory as pir.py . Note that you will need to change PIR=22 to whichever pin your sensor is on.

    Run: python3 pir.py and you should be up and running

    To have it run at every boot, type crontab -e and add

    @reboot python3 /home/pi/pir.py
    

    Hope this helps!


  • Project Sponsor Module Developer

    Been using this for over 3 years… I made it, it’s simple and directions are clear…
    https://github.com/cowboysdude/Pir-Sensor


Log in to reply