from machine import Pin
from lcd1602 import LCD
from time import sleep
import dht
sensor = dht.DHT22(Pin(9))
led = Pin(2,Pin.OUT)
lcd = LCD()
while True:
sensor.measure()
temp = sensor.temperature()
hum = sensor.humidity()
lcd.clear()
lcd.write(0,0,"Temp: {}°C ".format(temp))
lcd.write(0,1,"Humidity: {:.0f}% ".format(hum) )
sleep(2)
if temp > 40:
led.value(1)
else:
led.value(0)
sleep(2)