from machine import Pin, SoftI2C
import dht
import time
import machine
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
buzzer_pin = Pin(34, Pin.IN)
led = Pin(5, Pin.OUT)
sensor = dht.DHT22(Pin(14))
I2C_ADDR = 0x27
totalRows = 2
totalColumns = 16
i2c = SoftI2C(scl=Pin(22), sda=Pin(21), freq=10000)
lcd = I2cLcd(i2c, I2C_ADDR, totalRows, totalColumns)
lcd.putstr("Hello")
h = -1
while True:
sensor.measure()
t = sensor.temperature()
if h != sensor.humidity():
h = sensor.humidity()
lcd.clear()
lcd.putstr("The Humidity: ")
lcd.putstr(str(h))
if t > 40:
led.on()
buzzer_pin.value(1)
else:
led.off()
time.sleep(1)
buzzer_pin.value(0)
lcd.clear()