from machine import I2C, Pin
from dht import DHT22
from utime import sleep
from pico_i2c_lcd import I2cLcd
dht = DHT22(Pin(16))
i2c = I2C(1, scl=Pin(15), sda=Pin(14), freq=400000)
I2C_ADDR = i2c.scan()[0]
lcd = I2cLcd(i2c, I2C_ADDR, 2, 16)
lcd.putstr("================================")
lcd.clear()
lcd.putstr(" TEMP | UMID" )
while True:
dht.measure()
temp = dht.temperature()
umid = dht.humidity()
if temp != None and umid != None:
lcd.move_to(0, 1)
lcd.putstr(f"{temp} C | {umid} %")
sleep(2)
else:
lcd.putstr("Falha na leitura")
sleep(2)