Python 为什么我看不懂;“探测到火灾”;当火焰传感器为真时,在firebase上?
下面是我的flame sensor代码,它通过python和raspberry pi在firebase上运行。我只需要看看火,它不工作了Python 为什么我看不懂;“探测到火灾”;当火焰传感器为真时,在firebase上?,python,firebase,raspberry-pi,sensors,Python,Firebase,Raspberry Pi,Sensors,下面是我的flame sensor代码,它通过python和raspberry pi在firebase上运行。我只需要看看火,它不工作了 import RPi.GPIO as GPIO import time channel = 21 def callback(channel): print("Fire Detected") x = GPIO.add_event_detect(channel, GPIO.BOTH, bouncetime = 300)
import RPi.GPIO as GPIO
import time
channel = 21
def callback(channel):
print("Fire Detected")
x = GPIO.add_event_detect(channel, GPIO.BOTH, bouncetime = 300)
y = GPIO.add_event_detect(channel, callback)
while True:
if x is True:
db.child("account").child("email_password").child("p@gmail.com").child("write").child("flame").set("Fire Detected")
else:
db.child("account").child("email_password").child("p@gmail.com").child("write").child("flame").set("Fire not Detected")
data = {
"flame": str(x)
}
db.child("account").child("email_password").child("p@gmail.com").child("write").set(data)
time.sleep(1)
GPIO.cleanup()