1
0

voeg 5 minuten ventilator toe

This commit is contained in:
2025-06-30 20:05:30 +02:00
parent b9c2c6054a
commit af035f0358

View File

@@ -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,19 @@ 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)
sensor_data['led'] = False
if sensor_data['fan'] == True and fan_timer_actief == False:
fan_timer_actief = True
fan_timer_start = time.time()
sensor_data['fan'] = True
GPIO.output(FAN_PIN, GPIO.HIGH)
if 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
GPIO.output(FAN_PIN, GPIO.LOW)
class handler_class(http.server.BaseHTTPRequestHandler):
def do_GET (self):