from machine import Pin
import time
import dht
#Chân D25 chân tín hiệu ra
led1 = Pin(25, Pin.OUT)
sensor = dht.DHT22(Pin (14))
sdaPIN = machine.Pin(21)
sclPIN = machine.Pin(22)
i2c = machine.I2C(sda = sdaPIN, scl = sclPIN)
#Nếu nhiệt độ (t)>40 -> bật đèn
#Nếu nhiệt đồ (t)<40 ->tắt đèn
while True:
  sensor.measure()
  t = sensor.temperature()
  print("Nhiet do: ", t)
  if t > 40:
    led1.on()
  else:
    led1.off()
time.sleep(2)