i m using industrial PIR sensor (ekmc1603111) [link-https://www.amazon.in/Panasonic-EKMC1603111-Pir-Sensor/dp/B016KL1EQG/ref=sr_1_1?s=industrial&ie=UTF8&qid=1535017218&sr=8-1&keywords=pir+sensor+ekmc1603111]. which is digital sensor, with relay on raspberry pi for lab automation, when motion is detected lab values goes to high n relays goes to high. & when it goes to low relay also goes to low, my problem as follows, when motion is detected or human is present in lab sensor gives 4-5V value on multi meter its correct n relay goes high, but when there is no motion n no human presence sensor still gives me 2-3V rather than Zero, n here relays always set to high.(here relays have to set as LOW so please help me out from this, VCC-5V, GND-GND, SINGAL-GPIO 18, Relay - GPIO 5,6. Thanks in advance. below is my code.
from threading import Thread, Event import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.IN)
GPIO.setup(5,GPIO.OUT)
GPIO.setup(6,GPIO.OUT)
class MyThread(Thread):
def __init__(self, timeout=20):
super(MyThread, self).__init__()
self.intruder_spotted = Event()
self.timeout = timeout
self.daemon = True
def run(self):
while True:
if self.intruder_spotted.wait(self.timeout):
self.intruder_spotted.clear()
print("Intruder")
GPIO.output(5,GPIO.HIGH)
GPIO.output(6,GPIO.HIGH)
else:
print("No intruder")
GPIO.output(5,GPIO.LOW)
GPIO.output(6,GPIO.LOW)
t = MyThread(20)
try:
t.start()
while True:
i=GPIO.input(18)
if i==1:
t.intruder_spotted.set()
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
exit(0)