from machine import I2C, Pin
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
from time import sleep
from dht import DHT22
dht_pin=(33)
sensor = DHT22(dht_pin)
I2C_ADDR = 0x27
TOTAL_ROWS = 2
TOTAL_COLUMNS = 16
i2c = I2C(scl=Pin(22), sda=Pin(21), freq=50000)
lcd = I2cLcd(i2c, I2C_ADDR, TOTAL_ROWS, TOTAL_COLUMNS)
while True:
sensor.measure()
temperature = sensor.temperature() # Membaca suhu
humidity = sensor.humidity() # Membaca kelembapan
lcd.clear()
lcd.putstr("Suhu: {:.2f}°C\n".format(temperature))
sleep(2)
lcd.putstr("Kelembapan: {:.2f}%".format(humidity))
sleep(2)