Ejemplo n.º 1
0
def home():

    return render_template("mainpage.html",
                           dht11_now1=dht11.dht_v1(),
                           dht11_now2=dht11.dht_v2(),
                           moisture_now=moisture.moisture_v(),
                           sun_light_now1=sun_light.sun_light_v1(),
                           sun_light_now2=sun_light.sun_light_v2(),
                           sun_light_now3=sun_light.sun_light_v3(),
                           water_sensor_now=water_sensor.water_v())
Ejemplo n.º 2
0
    elif vv > 0.05:
        led_12v.write(0)  #uvIndex>0.05, 'OFF'
    print('sunlight:', vv)
    time.sleep(1)

    # Moisture sensor
    if moisture.moisture_v() <= 20:
        water_pump.write(1)  #m<=10, 'ON'
        water_pump.write(0)  #after, 'OFF' -> once 'ON'
    elif moisture.moisture_v() > 20:
        water_pump.write(0)  #m>10, 'OFF'
    time.sleep(1)
    print(moisture.moisture_v())

    # dht11
    king1 = float(dht.dht_v1())  #float type change
    king2 = float(dht.dht_v2())  #float type change
    if king1 >= 60 or king2 >= 23:
        fan_led.write(1)  #humi>=60, temp>=23 'ON'
        print('yes', king1, king2)
    elif king1 < 60 or king2 < 23:
        fan_led.write(0)  #humi<60, temp<23 'OFF'
        print('no', king1, king2)
    time.sleep(1)

    # water sensor
    if water_sensor.water_v() < 500:
        water_sensor1.write(1)
    else:
        water_sensor1.write(0)
    time.sleep(1)