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

Scheduled Pinned Locked Moved Troubleshooting
17 Posts 9 Posters 12.0k 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.
  • M Offline
    mab6435 @cruunnerr
    last edited by Jan 7, 2018, 9:42 PM

    @cruunnerr I’m using the correct pin. I made a python script shown below:

    from gpiozero import MotionSensor
    pir = MotionSensor(22)
    while True:
    if pir.motion_detected:
    print(“motion detected”)
    else:
    print(“NOTHING”)

    With this it will print nothing until i wave my hand in front of it then motion detected until i stop. So I know for a fact the PIR sensor is connected and working properly. Also there are no errors when I start magic mirror the only thing that is mentioned about MMM-PIR-Sensor is it says no helper found for module: MMM-PIR-SENSOR. Anyone have any idea

    1 Reply Last reply Reply Quote 0
    • C Offline
      cruunnerr
      last edited by Jan 7, 2018, 9:50 PM

      have u tried to delete the Pir Folder in your modules direction and start a simple new installation of the module?

      or just go into the MMM-PIR-Sensor folder and type npm install again?

      M 1 Reply Last reply Jan 7, 2018, 11:45 PM Reply Quote 0
      • M Offline
        mab6435 @cruunnerr
        last edited by Jan 7, 2018, 11:45 PM

        @cruunnerr I just deleted the entire module and downloaded it again, following the instructions directly from the page.

        To summarize, I know the sensor is working properly and connected to the right pin listed in the config file. I know nothing is wrong with the module i just downloaded it from github. I’ve posted the exact copy of my config file, no one seems to have a problem with that. What else could it be? For some reason the monitor wont shut off.

        Its a Benq monitor connected to the raspberry pi via an hdmi cord.
        Im not sure if this helps but when i type /opt/vc/bin/tvservice -s:
        state 0x12000a [HDMI CEA (16) RGB lim 16:9], 1920x1080 @ 60.00Hz, progressive

        1 Reply Last reply Reply Quote 0
        • C Offline
          cruunnerr
          last edited by Jan 8, 2018, 4:27 AM

          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 Jan 8, 2018, 5:04 PM

            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 Jan 13, 2018, 3:25 PM

              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 Jan 21, 2018, 4:59 PM Jan 21, 2018, 4:55 PM

                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 Jul 14, 2019, 10:08 AM Reply Quote 0
                • O Offline
                  onis_uk @sek_is_back
                  last edited by Jul 14, 2019, 10:08 AM

                  @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