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_timer_start = 0
|
||||
fan_timer_actief = False
|
||||
|
||||
def check_data():
|
||||
global fan_timer_actief, fan_timer_start
|
||||
while True:
|
||||
try:
|
||||
temperatuur_C = sensor.temperature
|
||||
@@ -41,12 +45,30 @@ def check_data():
|
||||
GPIO.output(FAN_PIN, GPIO.HIGH)
|
||||
sensor_data['led'] = True
|
||||
sensor_data['fan'] = True
|
||||
fan_timer_actief = False
|
||||
fan_timer_start = 0
|
||||
else:
|
||||
GPIO.output(LED_PIN, GPIO.LOW)
|
||||
GPIO.output(FAN_PIN, GPIO.LOW)
|
||||
if sensor_data['fan'] == True and fan_timer_actief == False:
|
||||
fan_timer_actief = True
|
||||
fan_timer_start = time.time()
|
||||
sensor_data['fan'] = True
|
||||
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['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):
|
||||
def do_GET (self):
|
||||
|
||||
Reference in New Issue
Block a user