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
GPIO.setmode(GPIO.BCM)
PIR_PIN = 7
GPIO.setup(PIR_PIN, GPIO.IN)
print("Setup complete...")
print("Starting script")
try:
while True:
if GPIO.input(PIR_PIN):
print("Motion Detected")
time.sleep(1)
except KeyboardInterrupt:
print("Quitting")
GPIO.cleanup()
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.
however their contexts do not apply
why not?