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.

    PIR Sensor won't wake up

    Scheduled Pinned Locked Moved Troubleshooting
    22 Posts 7 Posters 9.3k Views 7 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
      Sceetch
      last edited by

      Hi guys,

      i want to install for my Magicmirror project a PIR Sensor (HC-SR501) for switching the monitor automatically on/off.

      i have already tested MMM-PIR-Sensor and MMM-PIR. But both have the same issue.

      After the adjusted delay the monitor switches off. But there is no chance to wake it up again.

      It seems to me that i have installed something wrong in the pins.
      In both modules i need a value for sensorPin:
      That mean the "out"wire of the PIR? thats right. That mean according my Occupancy i have to put “16” into it?
      20210219_213752.jpg

      please help!

      karsten13K D 2 Replies Last reply Reply Quote 0
      • karsten13K Online
        karsten13 @Sceetch
        last edited by

        should be 23 (not 16)

        alt text

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

          Thx. now the table should be clear.
          But the PIR doesn’t work.
          After delay the screen switch off.
          But i can breakdance in front of the sensor. It happend nothing…

          but if i remove the cable from sensorpin 23 the sceen wakes up.

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

            hi.
            There are some news about my Sensor problem.

            i tried to install these steps according this link

            https://teilzeitrebell.de/blog/magicmirror-part-2-bewegungsmelder

            i made two sh-scripts for screen on & off

            monitor_off.sh
            monitor_on.sh

            then i created this phyton

            pir_loop.py

            !/usr/bin/env python
            
            import sys
            import time
            import RPi.GPIO as io
            import subprocess
            
            io.setmode(io.BCM)
            SHUTOFF_DELAY = 10  # seconds
            PIR_PIN = 17        # Pin 11 on the board
            
            def main():
                io.setup(PIR_PIN, io.IN)
                turned_off = False
                last_motion_time = time.time()
            
                while True:
                    if io.input(PIR_PIN):
                        last_motion_time = time.time()
                        sys.stdout.flush()
                        if turned_off:
                            turned_off = False
                            turn_on()
                    else:
                        if not turned_off and time.time() > (last_motion_time + SHUTOFF_DELAY):
                            turned_off = True
                            turn_off()
                    time.sleep(.1)
            
            def turn_on():
                subprocess.call("sh /home/pi/Pir-Sensor/monitor_on.sh", shell=True)
            
            def turn_off():
                subprocess.call("sh /home/pi/Pir-Sensor/monitor_off.sh", shell=True)
            
            if __name__ == '__main__':
                try:
                    main()
                except KeyboardInterrupt:
                    io.cleanup()
            

            i can start this with

            python pir_loop.py
            

            and it seems that it works.

            But in the code i defined a delay of 10 seconds. But after it, it happend nothing.
            the weird thing is, that the screen turn off after exact 2 minutes. If i move in front of the sensor the screen turn on again.
            But if i do nothing or cover the sensor with something the screen turn on after exact one minute.

            does anybody has an idea, whats wrong there?

            ebolisaE 1 Reply Last reply Reply Quote 0
            • ebolisaE Offline
              ebolisa @Sceetch
              last edited by

              @sceetch I’ve, more or less, the same setup but the sh files stored in the MagicMirror folder.

              1 Reply Last reply Reply Quote 0
              • D Offline
                dbg @Sceetch
                last edited by dbg

                @sceetch Which Raspberry Pi board are you using?

                S 1 Reply Last reply Reply Quote 0
                • S Offline
                  Sceetch @dbg
                  last edited by

                  @dbg i’m using Raspberry Pi 3 Modell B Plus (B +)

                  I have no idea whats wrong.
                  I can change the delay time value randomly. There is no effect. After exact 2 minutes the screen turn off.

                  Could it be, there is something activated in the tvservice?

                  S D 3 Replies Last reply Reply Quote 0
                  • S Offline
                    sdetweil @Sceetch
                    last edited by

                    @sceetch off is because the module does this no motion was detected

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      dbg @Sceetch
                      last edited by

                      @Sceetch

                      Hi

                      I installed the MMM-PIR-Sensor last week and I had a similar problem. I just couldn’t get the sensor to work with the module. I spent a lot of time and tried a few different things and nothing worked… in the end I updated the wiringPi GPIO access library (I’m using a Pi 4 Model B).

                      See here:

                      http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/

                      And now it’s working OK. I’m not saying this will fix your problem. It may be that an install I did overwrote the wiringPi files on my Pi or rolled them back in some way, but it worked for me.

                      Regards

                      dbg62

                      1 Reply Last reply Reply Quote 0
                      • S Offline
                        sdetweil @Sceetch
                        last edited by sdetweil

                        @sceetch also i think u need to make sure the sensor actually works

                        https://projects.raspberrypi.org/en/projects/parent-detector/3

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        S 1 Reply Last reply Reply Quote 0
                        • S Offline
                          Sceetch @sdetweil
                          last edited by

                          @sdetweil thx for your comment.

                          I guess the sensor works.
                          If i start this script, the sensor switch after 2 minutes off.
                          If the sensor receives movements, the screen turn on, so i think it works. But i will test your script in the evening.

                          If there is no movement registered from the sensor the screen switch on after 1 minute.

                          I don’t understand why the countdown is 2 min? In the script the delay time is setted by 10 sec.

                          And why the screen turns on after another one minute. If there is no signal from the sensor??

                          S 1 Reply Last reply Reply Quote 0
                          • S Offline
                            sdetweil @Sceetch
                            last edited by

                            @sceetch the sensor must be detecting heat difference. its very sensitive. the dial .ust be set to about 2 minutes, since last movement…

                            there is a jumper on some of the boards that changes how long it holds the signal active since movement.

                            Sam

                            How to add modules

                            learning how to use browser developers window for css changes

                            S 1 Reply Last reply Reply Quote 0
                            • S Offline
                              Sceetch @sdetweil
                              last edited by

                              @sdetweil
                              Hi sdetweil, this was a good hint. I think the problem are the adjustments of the sensor itselfs. the time values in my previous post changed now. But the problem still exists.

                              The reason why the screen wake up without movement is, the overlapping of signals. there is one delay in the script, but also one of the Sensor. If the script turns off the screen and the sensor gives also a signal regarding the time delay a little later, the screen will turn on again. so my opinion.

                              But what is now the best adjustment of it?
                              is it possible to inactivate the time delay of the sensor itself?

                              In what position is the jumper to be set?
                              sensivity of it should be clear. thats a customized value for the different situations.

                              S B 2 Replies Last reply Reply Quote 0
                              • S Offline
                                sdetweil @Sceetch
                                last edited by

                                @sceetch google to answer those questions

                                Sam

                                How to add modules

                                learning how to use browser developers window for css changes

                                1 Reply Last reply Reply Quote 0
                                • B Offline
                                  BravoOscar @Sceetch
                                  last edited by

                                  @sceetch

                                  I just added a PIR sensor, and I have put jumper on “L” and the two potmeteres on low (clockwise) . This works fine.

                                  Here you have som more information on the PIR sensor.

                                  https://lastminuteengineers.com/pir-sensor-arduino-tutorial/

                                  I use this module:
                                  https://github.com/bugsounet/MMM-NewPIR
                                  In the config, I have chaged delay from delay: 2 * 60 * 1000 // 2min to delay: 10 * 60 * 1000 //10min

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

                                    I’m having a similar issue using Mmm-PIR-Sensor

                                    Using a pi 3b+ and it turns the screen off but not back on again…

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

                                      Having tested the commands it looks like
                                      sudo tvservice -p doesn’t work with my monitor. (-o works though which is strange?)

                                      Vcgencmd works perfectly though…

                                      Could this be a reason why it’s not working?

                                      S 1 Reply Last reply Reply Quote 0
                                      • S Offline
                                        sdetweil @jste84
                                        last edited by

                                        @jste84 yes change the command the module uses

                                        Sam

                                        How to add modules

                                        learning how to use browser developers window for css changes

                                        J 1 Reply Last reply Reply Quote 0
                                        • J Offline
                                          jste84 @sdetweil
                                          last edited by

                                          @sdetweil is it this line

                                          sudo chmod u+s /opt/VC/bin/tvservice && sudo chmod u+s bin/chvt
                                          

                                          That I need to change? Would I just change TV service to vcgencmd

                                          S 1 Reply Last reply Reply Quote 0
                                          • S Offline
                                            sdetweil @jste84
                                            last edited by

                                            @jste84 maybe. dont know. you could try

                                            Sam

                                            How to add modules

                                            learning how to use browser developers window for css changes

                                            1 Reply Last reply Reply Quote 0

                                            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
                                            • 1 / 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