import machine
from machine import Pin, SoftI2C
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
from time import sleep_ms
import dht
i2c = SoftI2C(scl=Pin(22), sda=Pin(21), freq=40000)
lcd = I2cLcd(i2c, 0x27, 4, 20)
d = dht.DHT22(machine.Pin(15))
d.measure() #bắt đầu đo
t = d.temperature()
h = d.humidity()
heart = bytearray([0x00,0x00,0x1B,0x1F,0x1F,0x0E,0x04,0x00])
lcd.custom_char(0, heart)
while True:
lcd.move_to(0,0)
lcd.putstr("NguyenHuuHung"+ chr(0) +" 191404484")
lcd.move_to(0,1)
lcd.putstr('Temperature: %3.1f *C'%t)
lcd.move_to(0,2)
lcd.putstr('Humidity: %3.1f %%' %h)
for i in range(11):
lcd.move_to(0,3)
lcd.putstr("Dem 0-10: "+str(i))
print(i)
sleep_ms(200)
lcd.clear()