import utime, dht
from machine import Pin, I2C
from lcd_api import LcdApi
from pico_i2c_lcd import I2cLcd
sensor = dht.DHT22(Pin(28, Pin.IN))
# Pin assignment
i2c = I2C(0, sda = Pin(0), scl = Pin(1), freq = 400000)
I2C_ADDR = i2c.scan()[0];
I2C_ROWS = 2; I2C_COLS = 16
lcd = I2cLcd(i2c, I2C_ADDR, I2C_ROWS, I2C_COLS)
def update_lcd(temp,hum):
lcd.move_to(0,0)
lcd.putstr("Temp : " + str(temp))
lcd.move_to(0,1)
lcd.putstr("Humidity: " + str(hum))
while True:
sensor.measure()
temp = sensor.temperature()
hum = sensor.humidity()
update_lcd(temp,hum)
utime.sleep(2)