0
votes

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)
1

1 Answers

0
votes

Despite the fact that the sensor is designed for operating voltage up to 7V, essentially the GPIO pins of the PI's SoC, are NOT 5V tolerant! That means you must power up the sensor from 3.3V or continue powering it from 5V but in this case you need to add a voltage divider between the output of the sensor and Pi's GPIO.

I could not find the information about the low signal voltage level in the datasheet, however, I believe that feeding the sensor from 3.3V will solve the problem. If not, you can use an operational amplifier to solve this problem.