簡體   English   中英

工業PIR傳感器始終為高

[英]Industrial PIR sensor always High

我正在使用工業PIR傳感器(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] 它是數字傳感器,在樹莓派上帶有用於實驗室自動化的繼電器,當檢測到運動時,實驗室值會變高,而繼電器會變高。 &當它變低時,繼電器也變低,我的問題如下,當檢測到運動或實驗室傳感器中有人時,萬用表上給出4-5V的值,其正確的n繼電器變高,但是當無運動時n沒有人的存在感測器仍然給我2-3V而不是零電壓,這里的繼電器總是設置為高電平。(這里的繼電器必須設置為LOW,所以請幫助我,VCC-5V,GND-GND,SINGAL-GPIO 18 ,繼電器-GPIO 5,6,在此先感謝我的代碼。

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)

盡管傳感器設計用於最高7V的工作電壓,但PI的SoC的GPIO引腳本質上不能承受5V的電壓! 這意味着您必須從3.3V上電給傳感器供電,或者繼續從5V供電。但是在這種情況下,您需要在傳感器的輸出和Pi的GPIO之間添加一個分壓器。

我無法在數據手冊中找到有關低信號電壓電平的信息,但是,我相信從3.3V供電給傳感器將解決問題。 如果沒有,您可以使用運算放大器來解決此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM