• 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.6k 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.
  • 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
                    • M Offline
                      Mar @cowboysdude
                      last edited by Mar Feb 4, 2017, 7:23 PM Feb 4, 2017, 6:15 PM

                      @cowboysdude Perfect, so I should expect it to shut off by the time the system loads to the prompt.

                      Yes it has two sensors, one for sensitivity and the other for how long to send the active signal. Suppose I’ll just play around a bit. Maybe i’ll try find the logs for wherever it tells you when cron jobs have run. Not having any luck so far. i might be doing the cron part wrong, i’ve never played around with cron jobs before.

                      Im thinking its the pir.py script as I’ve done the cron job right I think.

                      edit: locations of the startup and shutdown script in pir.py need to be updated! Doh!

                      1 Reply Last reply Reply Quote 1
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        6/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