MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    MMM-PIR-Sensor tuning

    Scheduled Pinned Locked Moved Troubleshooting
    40 Posts 7 Posters 37.1k Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      shgmongohh @jc21
      last edited by shgmongohh

      @jc21
      Thank you. I don´t have a camera.
      I don´t know if the sonsor works not correct or if I have another issue.

      When I install your module, have I to delete or uninstall the other pir-module?
      I only have renamed the folder.
      If i have to delete it, how is it done?

      Sebastian

      1 Reply Last reply Reply Quote 0
      • S Offline
        shgmongohh
        last edited by

        I have found a python programm, where I can track the sensor in a consolen window. Has anybody an idea how i can safe the data into a document? And how I can autostart my python programm?

        # Import required Python libraries
        import RPi.GPIO as GPIO
        import time
        import datetime
        
        # Use BCM GPIO references
        # instead of physical pin numbers
        GPIO.setmode(GPIO.BCM)
        
        # Define GPIO to use on Pi
        GPIO_PIR = 23
        
        print "Bewegungsmelder Test (CTRL-C zum Beenden)"
        print "========================================="
        
        # Set pin as input
        GPIO.setup(GPIO_PIR,GPIO.IN)      # Echo
        
        Current_State  = 0
        Previous_State = 0
        
        try:
        
          print "%s: Sensor initialisieren ..." % datetime.datetime.now()  
        
          # Loop until PIR output is 0
          while GPIO.input(GPIO_PIR)==1:
            Current_State  = 0    
        
          print "%s: Fertig! Warte auf Bewegung..."  % datetime.datetime.now()    
            
          # Loop until users quits with CTRL-C
          while True :
           
            # Read PIR state
            Current_State = GPIO.input(GPIO_PIR)
           
            if Current_State==1 and Previous_State==0:
              # PIR is triggered
              print " %s: Bewegung erkannt!" % datetime.datetime.now() 
              # Record previous state
              Previous_State=1
            elif Current_State==0 and Previous_State==1:
              # PIR has returned to ready state
              print " %s: Fertig! Warte auf Bewegung..."  % datetime.datetime.now() 
              Previous_State=0
              
            # Wait for 10 milliseconds
            time.sleep(0.01)      
              
        except KeyboardInterrupt:
          print " Exit"
          # Reset GPIO settings
          GPIO.cleanup()
        S 1 Reply Last reply Reply Quote 0
        • S Offline
          shgmongohh @shgmongohh
          last edited by

          It done. I can tune my PIR-Sensor.
          Here is a usefull Link.

          1 Reply Last reply Reply Quote 1
          • O Offline
            open_book
            last edited by open_book

            Hi, I’very been through a lot of the posts on the White Screen issue, and on this thread. I’m close… I can feel it, but I’ve an uncaught exception that I don’t understand.

            [TAILING] Tailing last 10 lines for [mm] process (change the value with --lines option)
            /home/pi/.pm2/logs/mm-error-0.log last 10 lines:
            0|mm | at /home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_helper.js:65:18
            0|mm | at /home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/onoff/onoff.js:27:5
            0|mm | at Array.forEach (native)
            0|mm | at Gpio.pollerEventHandler (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/onoff/onoff.js:26:13)
            0|mm | TypeError: Cannot read property ‘writeSync’ of undefined
            0|mm | at Class.activateMonitor (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_helper.js:21:17)
            0|mm | at /home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_helper.js:59:18
            0|mm | at /home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/onoff/onoff.js:27:5
            0|mm | at Array.forEach (native)
            0|mm | at Gpio.pollerEventHandler (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/onoff/onoff.js:26:13)

            link to screengrab.

            Anyone offer any tips as to what might be causing this?

            I’m on a Pi3 Model B v2.
            Have only installed the standard mirror module, and the MMM-PIR module. The mirror is working fine and the PIR module is loading, but the screen isn’t switching off.

            sudo insert motivational.quote

            J 1 Reply Last reply Reply Quote 0
            • J Offline
              jc21 @open_book
              last edited by

              @open_book Few things,

              1. What version of Raspbian are you using? The onoffnpm module has issues with some releases.
                Hint: cat /etc/os-release
              2. What does your config look like for the pir module, exactly?
              O 1 Reply Last reply Reply Quote 0
              • O Offline
                open_book @jc21
                last edited by open_book

                @jc21
                1.
                PRETTY_NAME=“Raspbian GNU/Linux 8 (jessie)”
                NAME=“Raspbian GNU/Linux”
                VERSION_ID=“8”
                VERSION=“8 (jessie)”
                ID=raspbian
                ID_LIKE=debian

                              {
                		module: 'MMM-PIR-Sensor',
                		config: {
                			sensorPIN: 3,
                			powerSaving: true,
                			}
                		},
                

                sudo insert motivational.quote

                J 1 Reply Last reply Reply Quote 0
                • J Offline
                  jc21 @open_book
                  last edited by

                  @open_book Very strange, it seems the module is trying to activate/deactive the monitor using the Relay, but you haven’t specified a relay to use.

                  I have noticed however, that sensorPIN of 3 shouldn’t work. This variable is incorrectly named, it is not actually the pin number of the header, but the GPIO number instead. Refer to this Pi 3 image showing which “pins” correspond to “gpio” numbers. You should be using one of 4, 5, 6, 12, 13, 18, 22, 23, 24, 25, 26 or 27.

                  For example, a sensorPIN of 4 would require the PIR io cable plugged in to pin header 7.

                  O 1 Reply Last reply Reply Quote 0
                  • O Offline
                    open_book @jc21
                    last edited by open_book

                    @jc21 hi again, thanks for your input so far.

                    I’ve had the sensorPIN at 22 previously. And tested it using the python script shared on a few other threads:

                    ´´´python
                    from gpiozero import MotionSensor
                    import os

                    pir= MotionSensor(22)
                    while True:
                    if pir.wait_for_motion(timeout=10*60):
                    print(“It lives”)
                    else:
                    os.system(“/opt/vc/bin/tvservice -0”)
                    ´´´
                    The result spammed “It lives”. Which I understand to mean that the sensor is working… If I change the if to “os.system(”/opt/vc/bin/tvservice -p")" the screen shutsdown.

                    The reason I changed it was based on the results of “gpio readall”. I currently have power in pin 1 (3.3v), ground in pin 6 and data in pin 15

                    gpio readall tells me that physical 15 = BCM 22 = GPIO 3 so I decided to try sensorPin: 3.

                    I’ve changed it back to 22 now, but the result is still the same.

                    Other possible vectors are:

                    I’m forcing HDMI output because I’m using a HDMI -> DVI converter and so it seemed like a safe choice.

                    With dev tools open I can see that USER_PRESENCE is not being logged anywhere in the console.

                    I followed this post and ran:

                    “Run npm rebuild --runtime=electron --target=1.3.4 --disturl=https://atom.io/download/atom-shell --abi=49”
                    in the MMM-PIR-Sensor folder,

                    sudo insert motivational.quote

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      jc21
                      last edited by

                      Sounds like you’re on top of that then.

                      Just fyi, the latest code for the original pir sensor module will rebuild the compiled dependencies for you as part of the npm install command in the module. There should be no reason to run npm rebuild manually unless you get those pesky “expected version xx but got xx” errors.

                      O 1 Reply Last reply Reply Quote 0
                      • O Offline
                        open_book @jc21
                        last edited by

                        @jc21 just for closure here I found the issue. After running the python script again I realised that the PIR was always HIGH even with the sensitivty dialled right down.

                        So I checked the leads going into the pi and found that, despite checking it many times, I’d mixed up GND and VCC :(

                        The lesson for any other idiots out there when testing is, run this Python script and make sure that the PIR stops broadcasting “Motion Detected!” when you cover it with something:

                        from gpiozero import MotionSensor
                        import os
                        
                        pir= MotionSensor(22) //the gpio pin PIR OUT is connected to
                        while True:
                                       if pir.motion_detected:
                                       print (“Motion Detected!”)
                        

                        Code from this site

                        With some further adjustments for sensitivity it’s now working great!

                        sudo insert motivational.quote

                        1 Reply Last reply Reply Quote 1
                        • J Offline
                          jc21
                          last edited by jc21

                          Great stuff. People shouldn’t discount a faulty PIR either. The one I had on the shelf for ages wasn’t detecting quite right so I ordered another one and the difference in detection is huge. I’m not sure if these have a shelf life or what but yeah, that was my recent experience.

                          1 Reply Last reply Reply Quote 2
                          • O Offline
                            ostfilinchen
                            last edited by

                            Hi all,

                            i have an issue with the PIR Sensor. I get alltime this error:

                            1|mm | at bindings (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/bindings/bindings.js:76:44)
                            1|mm | (node:1714) DeprecationWarning: sys is deprecated. Use util instead.
                            1|mm | WARNING! Could not load config file. Starting with default configuration. Error found: Error: Module version mismatch. Expected 50, got 49.
                            1|mm | App threw an error during load
                            1|mm | Error: Module version mismatch. Expected 50, got 49.
                            1|mm | at Error (native)
                            1|mm | at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
                            1|mm | at Object.Module._extensions…node (module.js:583:18)
                            1|mm | at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
                            1|mm | at Module.load (module.js:473:32)
                            1|mm | at tryModuleLoad (module.js:432:12)
                            1|mm | at Function.Module._load (module.js:424:3)
                            1|mm | at Module.require (module.js:483:17)
                            1|mm | at require (internal/module.js:20:19)
                            1|mm | at bindings (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/bindings/bindings.js:76:44)
                            1|mm | Error: Module version mismatch. Expected 50, got 49.
                            1|mm | at Error (native)
                            1|mm | at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
                            1|mm | at Object.Module._extensions…node (module.js:583:18)
                            1|mm | at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
                            1|mm | at Module.load (module.js:473:32)
                            1|mm | at tryModuleLoad (module.js:432:12)
                            1|mm | at Function.Module._load (module.js:424:3)
                            1|mm | at Module.require (module.js:483:17)
                            1|mm | at require (internal/module.js:20:19)
                            1|mm | at bindings (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/bindings/bindings.js:76:44)

                            It’s equal if i have the original from @paviro or the modification.

                            Can anybody help me?

                            Regards Daniel

                            yawnsY 1 Reply Last reply Reply Quote 0
                            • yawnsY Offline
                              yawns Moderator @ostfilinchen
                              last edited by yawns

                              @ostfilinchen

                              1. please run npm list and find out your version number of electron
                              2. change into the MMM-PIR-Sensor folder cd ~/MagicMirror/modules/MMM-PIR-Sensor
                              3. run npm rebuild --runtime=electron --target=ELECTRONVERSION --disturl=https://atom.io/download/atom-shell --abi=50 and replace ELECTRONVERSION with the version number you found in step 1
                              O 1 Reply Last reply Reply Quote 2
                              • O Offline
                                ostfilinchen @yawns
                                last edited by

                                @yawns. Is it possible that my Version is 1.4.13?

                                1 Reply Last reply Reply Quote 0
                                • yawnsY Offline
                                  yawns Moderator
                                  last edited by

                                  Yes, that is possible. When I had to run this command last time I was using 1.4.0 …
                                  Just give it a try. Worst case is you have to delete the MMM-PIR-Sensor folder and git clone it again.

                                  O 1 Reply Last reply Reply Quote 0
                                  • O Offline
                                    ostfilinchen @yawns
                                    last edited by

                                    @yawns now i get this error

                                    pi@raspberrypi:~/MagicMirror/modules/MMM-PIR-Sensor $ sudo npm rebuild --runtime=electron --target=1.4.13 --disturl=https://atom.io/download/atom-shell --abi=50

                                    epoll@0.1.20 install /home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll
                                    node-gyp rebuild

                                    gyp ERR! clean error
                                    gyp ERR! stack Error: EACCES: permission denied, unlink ‘build/Makefile’
                                    gyp ERR! System Linux 4.4.38-v7+
                                    gyp ERR! command “/usr/local/bin/node” “/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
                                    gyp ERR! cwd /home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll
                                    gyp ERR! node -v v7.0.0
                                    gyp ERR! node-gyp -v v3.4.0
                                    gyp ERR! not ok

                                    npm ERR! Linux 4.4.38-v7+
                                    npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “rebuild” “–runtime=electron” “–target=1.4.13” “–disturl=https://atom.io/download/atom-shell” “–abi=50”
                                    npm ERR! node v7.0.0
                                    npm ERR! npm v3.10.8
                                    npm ERR! code ELIFECYCLE
                                    npm ERR! epoll@0.1.20 install: node-gyp rebuild
                                    npm ERR! Exit status 1
                                    npm ERR!
                                    npm ERR! Failed at the epoll@0.1.20 install script ‘node-gyp rebuild’.
                                    npm ERR! Make sure you have the latest version of node.js and npm installed.
                                    npm ERR! If you do, this is most likely a problem with the epoll package,
                                    npm ERR! not with npm itself.
                                    npm ERR! Tell the author that this fails on your system:
                                    npm ERR! node-gyp rebuild
                                    npm ERR! You can get information on how to open an issue for this project with:
                                    npm ERR! npm bugs epoll
                                    npm ERR! Or if that isn’t available, you can get their info via:
                                    npm ERR! npm owner ls epoll
                                    npm ERR! There is likely additional logging output above.

                                    npm ERR! Please include the following file with any support request:
                                    npm ERR! /home/pi/MagicMirror/modules/MMM-PIR-Sensor/npm-debug.log
                                    pi@raspberrypi:~/MagicMirror/modules/MMM-PIR-Sensor $

                                    1 Reply Last reply Reply Quote 0
                                    • yawnsY Offline
                                      yawns Moderator
                                      last edited by

                                      why are you running it with sudo??

                                      1 Reply Last reply Reply Quote 0
                                      • O Offline
                                        ostfilinchen
                                        last edited by

                                        without sudo i get the same error

                                        1 Reply Last reply Reply Quote 0
                                        • O Offline
                                          ostfilinchen
                                          last edited by

                                          After a few New Installations now the mm starts and the PIR works.

                                          1 Reply Last reply Reply Quote 1

                                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                          With your input, this post could be even better 💗

                                          Register Login
                                          • 1
                                          • 2
                                          • 2 / 2
                                          • First post
                                            Last post
                                          Enjoying MagicMirror? Please consider a donation!
                                          MagicMirror created by Michael Teeuw.
                                          Forum managed by Sam, technical setup by Karsten.
                                          This forum is using NodeBB as its core | Contributors
                                          Contact | Privacy Policy