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 Senor Test

    Scheduled Pinned Locked Moved Troubleshooting
    3 Posts 2 Posters 2.6k Views 2 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
      shgmongohh
      last edited by

      Hi,

      I have some problems to install the pir sensor to send the monitior to sleep.

      I don´t know, if my sensor is working correct. Has anybody a tutorial, how to connect the pir right and to test the function?

      I think I connect everything right, but it doesn´t work.

      Sebastian

      1 Reply Last reply Reply Quote 0
      • M Offline
        McSorley
        last edited by paviro

        I thought the same for a long time using the because I didnt have a breadboard. I went with the PIR Setup on the raspberry pi website. Managed to use this code to see that it works. You will need gpiozero to run it. Open Python 3. File > New. Paste this code in.

        from gpiozero import MotionSensor
        import os
        
        pir = MotionSensor(4) #4 is the Pin?
        while True:
          if pir.wait_for_motion(timeout=10*60): #10 * 60 Seconds
                os.system("/opt/vc/bin/tvservice -p")
          else:
             os.system("/opt/vc/bin/tvservice -o")
        

        You can if you want edit
        os.system("/opt/vc/bin/tvservice -p")
        to
        print("Motion Detected")
        to test if your PIR Sensor is working ok. After changing it, save it and press Ctrl + F5 to run the code. It will then spam up with motion detect or undetected depending on what you’ve changed.

        S 1 Reply Last reply Reply Quote 1
        • S Offline
          shgmongohh @McSorley
          last edited by

          @McSorley
          Thanks! It works finde

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