MagicMirror² v2.4.1 is available! For more information about this release, check out this topic.
Please read the release notes carefully since this update requires adjustments to your Raspberry Pi configuration!

PIR-Sensor detecting motion even when there's no movement


  • Module Developer

    Hi All

    I’ve just hooked up my PIR sensor to my Pi3

    I ran a variant of this, and it was constantly detecting movement even when I was covering it up, so nothing should have been detected.

    Is there an issue with my sensor? Or is that standard? Or can I turn down the sensitivity in some way?

    import RPi.GPIO as GPIO
    import time
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(3,GPIO.OUT)     #Define pin 3 as an output pin
    
    while True:
            GPIO.output(3,1)   #Outputs digital HIGH signal (5V) on pin 3
            time.sleep(1)      #Time delay of 1 second
    
            GPIO.output(3,0)   #Outputs digital LOW signal (0V) on pin 3
            time.sleep(1)      #Time delay of 1 second
    

    Edit from admin: Please use Markdown on code snippets!


  • Moderator

    I don’t have a PIR sensor to fiddle with … however, why are you setting pin 3 HIGH, and as an OUTPUT? If it’s to power the PIR sensor board, don’t, use either pin 1 or 17, those have a constant 3v3 on them (or if you know your sensor can tolerate 5V, use pins 2 or 4). If it’s to read from the PIR sensor, it needs to be set as an INPUT pin so it can detect when the sensor triggers it.