from machine import I2C, Pin
from time import sleep
from dht import DHT22
from pico_i2c_lcd import I2cLcd
dht = DHT22(Pin(15))
miniFan = machine.Pin(14, machine.Pin.OUT)
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
I2C_ADDR = i2c.scan()[0]
lcd = I2cLcd(i2c, I2C_ADDR, 2, 16)
current_temp = 0
while True:
dht.measure()
temp = dht.temperature()
if current_temp != temp:
lcd.clear()
lcd.putstr("Temp = " + str(temp))
current_temp = temp
if temp > 60:
miniFan.toggle()