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 not working

    Scheduled Pinned Locked Moved Troubleshooting
    17 Posts 9 Posters 13.1k 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.
    • cruunnerrC Offline
      cruunnerr
      last edited by

      i can switch off and on my display by simply typing sudo tvservice -o and sudo tvservice -p

      1 Reply Last reply Reply Quote 0
      • B Offline
        barnosch
        last edited by

        why are you using a MM module?
        This is not related to the mirror itself. Use @cowboysdude (how funny is that in this context ;) ) script.
        You can find it in his github respository. By the way, this dude creates really cool stuff, so its worth to have a closer look to it.

        If your PIR is cabled well, it should work easily.

        1 Reply Last reply Reply Quote 0
        • D Offline
          davide
          last edited by

          mba , I had the same issue but only because you have to force one detection, just the first time after you start magic mirror software. Then everything should be ok and working. So, after magic mirror is up and running, try to pass an hand in front of the sensor, then wait to see if it will turn off.

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

            I had the same problems and I dont know why. So I searched for another solution. Now it works perfect.
            I wrote one bash script for the power off and one for the power on.

            Script Power on:
            vcgencmd display_power 1

            Script Power off:
            vcgencmd display_power 0

            than I used this Pyhton for the PIR

            #!/usr/bin/env python
            
            import sys
            import time
            import RPi.GPIO as io
            import subprocess
            
            io.setmode(io.BCM)
            SHUTOFF_DELAY = 300  # seconds
            PIR_PIN = 25        # 22 on the board
            LED_PIN = 16        # 36 on the board
            
            def main():
                io.setup(PIR_PIN, io.IN)
                io.setup(LED_PIN, io.OUT)
                turned_off = False
                last_motion_time = time.time()
            
                while True:
                    if io.input(PIR_PIN):
                        last_motion_time = time.time()
                        io.output(LED_PIN, io.LOW)
                        print ".",
                        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()
                        if not turned_off and time.time() > (last_motion_time + 1):
                            io.output(LED_PIN, io.HIGH)
                    time.sleep(.1)
            
            def turn_on():
                subprocess.call("sh /home/pi/MagicMirror/pir/monitor_on.sh", shell=True)
            
            def turn_off():
                subprocess.call("sh /home/pi/MagicMirror/pir/monitor_off.sh", shell=True)
            
            if __name__ == '__main__':
                try:
                    main()
                except KeyboardInterrupt:
                    io.cleanup()
            

            I tryed to upload but not enough privileges

            O 1 Reply Last reply Reply Quote 0
            • O Offline
              onis_uk @sek_is_back
              last edited by

              @sek_is_back hi know this is old but where do you save the scripts to, to make them function?

              1 Reply Last reply Reply Quote 0
              • 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