#from lcd_library import LCD
from lcd import LCD1602
from machine import Pin
import dht
from time import sleep
ht=dht.DHT22(Pin(27))
# Initialize LCD with GPIO pins (modify for ESP32 if needed)
lcd=LCD1602(rs=4,en=5,d4=12,d5=13,d6=14,d7=15)
# to display real time temperature and humidity
last_temp=None
last_humid=None
while True:
ht.measure()
temp=ht.temperature()
humid=ht.humidity()
print(temp)
print(humid)
if temp != last_temp or humid != last_humid:
lcd.clear()
lcd.set_cursor(0,0)
lcd.putstr(f"Temp: {temp:.1f} C")
lcd.set_cursor(1,0)
lcd.putstr(f"Hum: {humid:.1f} %")
last_temp=temp
last_humid=humid
sleep(2)