ADD file via upload

main
pxnmejity 9 months ago
parent 807c127e78
commit 96cb49dd75

@ -0,0 +1,66 @@
#!/usr/bin/python
# encoding:utf-8
# 目前用的人体红外传感器模块是最迷你型的,因此感应的距离只有一米
# 当检测到人体活动时会持续高电平24秒
import RPi.GPIO as GPIO
import time
import renlian as rl
import lighting as l
import MySQL as m
import jiqiren as jqr
import huoyan as hy
# !/usr/bin/python
# encoding:utf-8
def gy():
Infrared = 22
GPIO.setmode(GPIO.BCM)
GPIO.setup(Infrared, GPIO.IN)
for i in range(5):
t = time.strftime('%Y-%m-%d %H:%M:%S')
if (GPIO.input(Infrared) == True):
print(t + " 家居环境异常 !")
GPIO.cleanup(Infrared)
return t
else:
# print(t + " Nobody !")
time.sleep(0.1)
GPIO.cleanup(Infrared)
return 0
# gy()
# time.sleep(10) #找出感应器重置的时间
# gy()
def check_env():
hy.hy()
sign = gy()
if (sign != 0):
jqr.Key("检测到环境异常!即将启动自动监控!")
while True:
l.L_hcsr_open()
id = rl.auto_video()
if (id[1] == 0):
jqr.Key("警报解除!")
l.L_hcsr_close()
break
sign = gy()
if (sign != 0):
jqr.Key("警告警告!环境异常!")
m.hcsr_update("hcsr", "alarm_time", sign, id[0])
continue
else:
jqr.Key("警报解除!")
l.L_hcsr_close()
break
# check_env()
Loading…
Cancel
Save