from machine import Pin
from utime import sleep
import dht
from lcd import lcd_init, lcd_print, lcd_clear # Make sure lcd.py is in same folder
# initializing the Temp and HMD Sensor
dht = dht.DHT22(Pin(14))
# Initializing the LED
led = Pin(12, Pin.OUT)
# Thresholds
temp_threshold = 30
hmd_threshold = 40
# Initializing LCD
lcd_init()
lcd_print("DHT22 Monitor")
while True:
dht.measure()
temp = dht.temperature()
hmd = dht.humidity()
print(f"Temperature: {temp} °C | Humidity: {hmd}%")
if temp > temp_threshold or hmd < hmd_threshold :
led.on()
sleep(0.2)
led.off()
sleep(0.2)
lcd_print("High Value")
print("Warning: High value")
else:
led.off()
lcd_print("Status: OK")
sleep(2)