Before you tell me answers for my issue already exist I'd like to mention that I have checked previous answers and where similar issues have occurred I have tried to use their approved answer. So far no luck.

Ok, so I got a cheap PIR sensor set it up as all the instructables tutorials told me to do. Copy + paste the script. The usual (making sure my pin was the correct one used in the python script, using GPIO 7 at the moment), just to see if it would work.

Problem: 1. Everytime I run the script there are no errors however it instantaneously registers detection.

Attempted Solutions 1. To start with I thought it was maybe too sensitive so turned the sensitivity of the sensor anticlockwise in a hope to lower it. 2. Next I tried using different pins, moved from pin 4 to 7, no difference. 3. Next I thought I would try eliminate any possible movement or heat source so moved the sensor into a cool drawer and when run again the same issue is occurring.

Is their something which I am missing? Do I have a faulty sensor?

Heres what I got:

import RPi.GPIO as GPIO
import time



print("Setup complete...")
print("Starting script")

    while True:
        if GPIO.input(PIR_PIN):
            print("Motion Detected")
except KeyboardInterrupt:

All I get out is: "Motion detected" "Motion detected" "Motion detected" "Motion detected" "Motion detected" "Motion detected"

Untill I interrupt program.

Edit: I have been asked to show setup so images below added.

PIR sensor setup

  • What happens when you use pull down resistor? GPIO.setup(PIR_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
    – Sebraponi
    Commented May 13, 2018 at 22:59
  • however their contexts do not apply why not? Commented May 13, 2018 at 23:20
  • 3
    We need a photo of the connections you have made. I do not trust narratives or pointers to tutorial or diagrams which may or may not have been followed correctly.
    – joan
    Commented May 14, 2018 at 7:16
  • @Sebraponi I have tried what you suggested and sadly no further luck. It still continuously prints Motion Detected even when placed in an isolated environment.
    – Nathaniel
    Commented May 18, 2018 at 18:55

1 Answer 1


First of all, PIR sensors are very sensitive. When you first activate your script, you should add a 30-45 second delay at the beginning to wait for the pir to initialize itself - to "learn" its environment. During that delay, move out of the room or at least move away from the pir sensor(you can also cover the pir sensor up with something) and don't move until the 30-45 seconds is up. When you start your program or plug the pir in, it will most likely activate for a few seconds, then, once it is used to its (non-moving) environment, it should deactivate and start working properly.

Second, notice the yellow jumper on the corner of your pir: this sets the trigger mode for the pir. You can read about the different trigger modes here, but I find that my pir works better in "repeatable trigger" mode, which is not the mode you have yours set at.

Lastly, make sure you have your delay time set as low as it can go: adjust both potentiometers(the orange knob things, sensitivity and delay) fully counter-clockwise.

I hope this helps you figure out your pir. I recommend reading this article to help you understand PIRs.

ps. I would change a part of your script to read

if GPIO.input(PIR_PIN):
    print("Motion Detected")
    print("NO MOTION")
  • I dont have enough rep yet to upvote but this is what I was looking for so thank you, problem fixed
    – Nathaniel
    Commented May 20, 2018 at 21:02
  • @Nathaniel , even if you can't upvote this answer, you can accept it, which is like saying "this is the best answer I got and this answer solved my problem". You can accept answers by clicking the check mark right below the downvote button. Thankyou! Commented May 20, 2018 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.