import time
from machine import Pin
import dht
dhtpin = Pin(15, pull=Pin.PULL_UP)
sensor = dht.DHT22(dhtpin)
ledBlue = Pin(25, Pin.OUT)
ledGreen = Pin(26, Pin.OUT)
ledRed = Pin(27, Pin.OUT)
while True :
print("Measuring weather conditions... ", end="")
sensor.measure()
temp = sensor.temperature()
humidity = sensor.humidity()
if (temp > 60 and humidity > 60) :
ledBlue.value(1)
elif ((temp <= 60 and temp >= 40) and (humidity <= 60 and humidity >= 30)) :
ledGreen.value(1)
else :
ledRed.value(1)
ledBlue.value(0)
ledGreen.value(0)
ledRed.value(0)
print("Temperature : {} Humidity : {}".format(temp, humidity))
time.sleep(0.5)