Esempio 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())
Esempio n. 2
0
#input.enable_reporting()

while True:

    # Sunlight sensor
    v = sun_light.sun_light_v3()
    vv = float(v[2])
    if vv <= 0.05:
        led_12v.write(1)  #uvIndex<=0.05, 'ON'
    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'
#input.enable_reporting()

while True:

    # Sunlight sensor
    v = sun_light.sun_light_v()
    vv = float(v[2])
    if vv <= 0.05:
        led_12v.write(1)  #uvIndex<=0.05, 'ON'
    elif vv > 0.05:
        led_12v.write(0)  #uvIndex>0.05, 'OFF'
    print('sun: \t\tG', vv)
    time.sleep(1)

    # Moisture sensor
    if moisture.moisture_v() <= 10:
        water_pump.write(1)  #m<=10, 'ON'
        water_pump.write(0)  #after, 'OFF' -> once 'ON'
    elif moisture.moisture_v() > 10:
        water_pump.write(0)  #m>10, 'OFF'
    time.sleep(1)
    print('moisture:\tR', 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('dht11: yes \tB', king1, king2)
    elif king1 < 60 or king2 <= 23:
        fan_led.write(0)  #humi<60, temp<23 'OFF'