# Importar Librerias
from machine import I2C, Pin, ADC
import utime
import dht
from lcd_api import LcdApi
from pico_i2c_lcd import I2cLcd
# Direccion del I2C y el tamaño del LCD
I2C_ADDR = 0X27
I2C_NUM_ROWS= 2
I2C_NUM_COLS= 16
# Configuraciob de la Raspberry
i2c=I2C(0, sda=Pin(0), scl= Pin(1), freq= 400000)
dht11= dht.DHT22(Pin(16))
# configurar LCD
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)
led1= Pin(17, Pin.OUT)
led2= Pin(18, Pin.OUT)
led3= Pin(19, Pin.OUT)
led4= Pin(20, Pin.OUT)
led5= Pin(21, Pin.OUT)
def lcd_str(message, col, row):
lcd.move_to(col, row)# mover posicion segun los valores de fila y columna
lcd.putstr(message)# envía una cadena de caracteres
while True:
dht11.measure()
t= dht11.temperature()
h=dht11.humidity()
if (t)and(t <60):
led5.on()
if (t >=40)and(t <49):
lcd.clear()
led1.on()
lcd_str("MOTOR 1 - ACTIVADO", 0, 0)
if (t >=50)and(t <55):
lcd.clear()
led1.on()
led2.on()
lcd_str("MOTOR 1 Y 2 ACTIVADO", 0, 0)
if (t >=55)and(t <60):
lcd.clear()
led1.off()
led2.off()
led3.on()
lcd_str("MOTOR 3-ACTIVADO", 0,0)
if (t >=60):
lcd.clear()
led3.off()
led4.on()
led5.off()
lcd_str("SISTEMA APAGADO", 0,0)
print("T=", t,"H=",h,"%")
# lcd_str("T="+str(t)+" |"+"H="+str(h)+"%", 0, 1)
# lcd_str(str(t), 2,1)
# lcd_str(str(h), 11,1)
# lcd_str("T=", 0,1)
#lcd_str("/", 7,1)
#lcd_str("H=", 9,1)
utime.sleep_ms(500)