from machine import I2C, Pin
from time import sleep
from pico_i2c_lcd import I2cLcd
from dht import DHT22
#LIBRERIAS ARRIBA
#configuracion para la pantaalla
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000) #GP0 Y GP1
I2C_ADDR = i2c.scan()[0]
dht = DHT22(Pin(5)) #GP5 EL SDA
lcd = I2cLcd(i2c, I2C_ADDR, 2, 16)
led_rojo = Pin(14,Pin.OUT) #GP14, CUALLQUIER GND
led_amarillo = Pin(13,Pin.OUT) #GP14, CUALLQUIER GND
led_verde = Pin(12,Pin.OUT) #GP14, CUALLQUIER GND
buzzer = Pin(16,Pin.OUT) #GP16, CUALQUIER GND
while True:
dht.measure()
temp = dht.temperature() #DECLARAMOS
hum = dht.humidity()
lcd.clear()
lcd.move_to(0,0)
lcd.putstr("Temp: " + str(temp) + " C")
lcd.move_to(0,1)
lcd.putstr("Hum: " + str(hum) + " %")
if temp > 50.0 and hum > 50.0:
for i in range(3):
led_rojo.value(1) # Encender LED
led_amarillo.value(0)
led_verde.value(0)
buzzer.value(1) # Encender Buzzer
sleep(0.2) # Esperar un momento encendido
led_rojo.value(0) # Apagar LED
buzzer.value(0) # Apagar Buzzer
sleep(0.2) # Esperar un momento apagado
elif temp > 35.0 and hum > 35.0:
led_rojo.value(0)
led_amarillo.value(1)
led_verde.value(0)
buzzer.value(0)
sleep(2) # Espera normal si todo está bien
else:
led_rojo.value(0)
led_amarillo.value(0)
led_verde.value(1)
sleep(2)
sleep(2)
Agregar un LED y que este encienda cuando
la humedad y temperatura superen los 50°,
en pantalla igual debe mostrar
la temperatura y humedad