from machine import Pin, SoftI2C
from i2c_lcd import I2cLcd
import time
import dht
i2c = SoftI2C(scl=Pin(22)), sda=Pin(21),freq=100000
lcd = 2cLcd(i2c, 0x27,2,16)
time.sleep(1)
lcd.clear()
d = dht.DHT22(Pin(23))
t = 0
d = 0
text = 'Starting...'
lcd.putstr(text)
while True:
try:
d.measure()
time.sleep(2)
t = d.temperature()
h = d.humedity()
temp = 'Temp: {:,0f} C'.format(t)
humid = 'Humidity: {:,0f} %'.format(h)
print('DHT22:',t,h)
lcd.putstr(temp)
lcd.move_to(0,1)
lcd.putstr(humid)
time.sleep(5)
except :
pass