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)
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT