I have bought the PIR motion sensor: PIR motion sensor – Pimoroni
I have wired it up according to this tutorial: How to Interface a PIR Motion Sensor With Raspberry Pi GPIO | Raspberry Pi | Maker Pro
Here is my code:
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN) #Read output from PIR motion sensor
while True:
i = GPIO.input(11)
time.sleep(0.5)
if i==0: #When output from motion sensor is LOW
print(“No intruders”)
elif i==1: #When output from motion sensor is HIGH
print(“Intruder detected”)
However i is always 1, unless I unplug it and it goes to zero. I have tried turning the sensitivity and delay down, hiding the PIR in a box etc. Nothing works, always high.
I have also tried it on pins 7 and 3 and in .net code which works with another PIR I have. Still doesn’t work.
1 post - 1 participant