Compare commits
4 Commits
b9c2c6054a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4d6f69450 | ||
|
|
5de9255526 | ||
|
|
27aaf239c7 | ||
|
|
af035f0358 |
28
dht11.py
28
dht11.py
@@ -24,7 +24,11 @@ sensor_data = {
|
|||||||
'fan': False
|
'fan': False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fan_timer_start = 0
|
||||||
|
fan_timer_actief = False
|
||||||
|
|
||||||
def check_data():
|
def check_data():
|
||||||
|
global fan_timer_actief, fan_timer_start
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
temperatuur_C = sensor.temperature
|
temperatuur_C = sensor.temperature
|
||||||
@@ -41,12 +45,30 @@ def check_data():
|
|||||||
GPIO.output(FAN_PIN, GPIO.HIGH)
|
GPIO.output(FAN_PIN, GPIO.HIGH)
|
||||||
sensor_data['led'] = True
|
sensor_data['led'] = True
|
||||||
sensor_data['fan'] = True
|
sensor_data['fan'] = True
|
||||||
|
fan_timer_actief = False
|
||||||
|
fan_timer_start = 0
|
||||||
else:
|
else:
|
||||||
GPIO.output(LED_PIN, GPIO.LOW)
|
if sensor_data['fan'] == True and fan_timer_actief == False:
|
||||||
GPIO.output(FAN_PIN, GPIO.LOW)
|
fan_timer_actief = True
|
||||||
|
fan_timer_start = time.time()
|
||||||
|
sensor_data['fan'] = True
|
||||||
sensor_data['led'] = False
|
sensor_data['led'] = False
|
||||||
|
GPIO.output(FAN_PIN, GPIO.HIGH)
|
||||||
|
GPIO.output(LED_PIN, GPIO.LOW)
|
||||||
|
elif sensor_data['fan'] == True and fan_timer_actief == True and time.time() - fan_timer_start > 300: # 5 minuten
|
||||||
|
fan_timer_actief = False
|
||||||
|
fan_timer_start = 0
|
||||||
sensor_data['fan'] = False
|
sensor_data['fan'] = False
|
||||||
|
sensor_data['led'] = False
|
||||||
|
GPIO.output(FAN_PIN, GPIO.LOW)
|
||||||
|
GPIO.output(LED_PIN, GPIO.LOW)
|
||||||
|
else:
|
||||||
|
fan_timer_actief = False
|
||||||
|
fan_timer_start = 0
|
||||||
|
sensor_data['fan'] = False
|
||||||
|
sensor_data['led'] = False
|
||||||
|
GPIO.output(FAN_PIN, GPIO.LOW)
|
||||||
|
GPIO.output(LED_PIN, GPIO.LOW)
|
||||||
|
|
||||||
class handler_class(http.server.BaseHTTPRequestHandler):
|
class handler_class(http.server.BaseHTTPRequestHandler):
|
||||||
def do_GET (self):
|
def do_GET (self):
|
||||||
|
|||||||
Reference in New Issue
Block a user