from machine import Pin
import utime
import dht
led=machine.Pin(0,Pin.OUT)
sensor = dht.DHT22(Pin(28))
while True:
sensor.measure()
temperature = sensor.temperature()
humidity = sensor.humidity()
print("Temperature is ",temperature ,"and humidity is : ",humidity)
utime.sleep(0.5)
if temperature>40:
led.value(1)
print("Temperature above 40")
utime.sleep(1)
else:
led.value(0)