from machine import Pin
from time import sleep
import dht
sensor = dht.DHT22(Pin(18))
led = Pin(25,Pin.OUT)
while True:
sensor.measure()
tmpr = sensor.temperature()
print("Temperature: {}°C ".format(tmpr))
if tmpr >= 40:
led.value(1)
print("Temperature is more than 40")
else:
led.value(0)
print("Temperature is less than 40")
sleep(0.5)