• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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 is turning off the screen when it detects user?

Scheduled Pinned Locked Moved Troubleshooting
12 Posts 3 Posters 7.4k Views 3 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.
  • M Offline
    Mar
    last edited by Jopyth Feb 4, 2017, 1:40 PM Feb 4, 2017, 1:00 PM

    Ive managed to get the PIR Sensor installed, but when I trip the sensor it shuts off my screen. I see in the pm2 logs that MMM-PIR-Sensor is sending a USER_PRESENCE notification.

    Wondering if anyone has seen this before, or how I can reverse this?

    J 1 Reply Last reply Feb 4, 2017, 1:43 PM Reply Quote 0
    • J Offline
      Jopyth Moderator @Mar
      last edited by Jopyth Feb 4, 2017, 1:44 PM Feb 4, 2017, 1:43 PM

      @Mar If it is doing the reverse of what you want, swap the comparison of value == 1 and value == 0 of this section in the node_helper.js.

      Helpful sticky: How to troubleshoot

      M 1 Reply Last reply Feb 4, 2017, 4:51 PM Reply Quote 2
      • M Offline
        Mar
        last edited by Mar Feb 4, 2017, 4:26 PM Feb 4, 2017, 4:24 PM

        Thanks not sure this worked, looks like the screen shuts off still. Looked through the code and found that “/opt/vc/bin/tvservice -o” shuts off my monitor correctly, but “/opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 7” does not turn it back on. When i try it on the command line it says “Powering on HDMI with preferred settings” but it doesnt turn back on.

        Also I’m not even sure its shutting down on its own but cant really test that as i dont have a reliable PIR on/off function yet.

        edit: well it does look like that command turns the monitor back on as the light stops blinking and stays on, but the screen is just blank

        1 Reply Last reply Reply Quote 0
        • M Offline
          Mar @Jopyth
          last edited by Feb 4, 2017, 4:51 PM

          @Jopyth
          On this line

          /opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 7
          

          changing the 7 to 2 fixed being able to turn the screen back on.

          /opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 2
          

          The only issue im having with this now seems to be that on a reboot the screen stays on if the sensor is not detecting anyone. Tested with a small script to show the sensor is sending a 0. Then when I trigger the sensor after a boot it shuts off the screen but then everything starts working properly.

          C 1 Reply Last reply Feb 4, 2017, 4:55 PM Reply Quote 0
          • C Offline
            cowboysdude Module Developer @Mar
            last edited by Feb 4, 2017, 4:55 PM

            @Mar This is why when I had mine running I ran outside the mirror…

            https://github.com/cowboysdude/Pir-Sensor

            The commands for on and off could be replaced with the ones I used then I just ran it at Raspberry pi startup… worked great!

            M 2 Replies Last reply Feb 4, 2017, 5:16 PM Reply Quote 0
            • M Offline
              Mar @cowboysdude
              last edited by Feb 4, 2017, 5:16 PM

              @cowboysdude Thanks for the tip, it does seem like a lot less hassle.

              1 Reply Last reply Reply Quote 0
              • M Offline
                Mar @cowboysdude
                last edited by Feb 4, 2017, 5:57 PM

                @cowboysdude Trying to give this a shot, cloned it into /home/pi/Pir-Sensor/ and changed the shutdown/startup files and confirmed they work, running with sh.

                /opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 2
                
                #! /bin/bash
                /opt/vc/bin/tvservice -o
                

                In my crontab I have:

                @reboot python cd /home/pi/Pir-Sensor/pir.py &
                

                but it doenst look like its doing anything on reboot, ive confirmed the sensor is working correctly and i’ve run the chmod commands.

                C 1 Reply Last reply Feb 4, 2017, 6:04 PM Reply Quote 0
                • C Offline
                  cowboysdude Module Developer @Mar
                  last edited by cowboysdude Feb 4, 2017, 6:05 PM Feb 4, 2017, 6:04 PM

                  @Mar I kept it really simple on mine… no directories just put the files directly into the root directory… that way didn’t have to figure out paths and such.

                  Also this has to match how your’s is setup… in the pir.py file:

                  io.setmode(io.BCM)
                  SHUTOFF_DELAY = 20  # seconds
                  PIR_PIN = 17        # Pin 11 on the board
                  
                  M 1 Reply Last reply Feb 4, 2017, 6:09 PM Reply Quote 0
                  • M Offline
                    Mar @cowboysdude
                    last edited by Feb 4, 2017, 6:09 PM

                    @cowboysdude Great i’ll move it across and keep it simple. And yes my sensor is installed to your default pin. Just so I can get an idea if its working, when would the screen shut off? Is this before MM loads or after?

                    C 1 Reply Last reply Feb 4, 2017, 6:11 PM Reply Quote 0
                    • C Offline
                      cowboysdude Module Developer @Mar
                      last edited by Feb 4, 2017, 6:11 PM

                      @Mar Because it’s not mirror related it will shut off and turn on if the mirror is running or not … :)

                      Hang in there it took me a bit to get it working … not being sure how the PIR sensor is setup [should be two screw settings on the sensor one is timing the other is sensitivity]…

                      M 1 Reply Last reply Feb 4, 2017, 6:15 PM Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        5/12
                        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