from machine import Pin, I2C
from time import sleep
from ssd1306 import SSD1306_I2C
#LIBRERIA PARA EL SENSOR DE HUMEDAD
from dht import DHT22
#parametros
ancho = 128
alto = 64
i2c = I2C (0, scl = Pin(22), sda = Pin (21) )
oled = SSD1306_I2C (ancho, alto ,i2c)
sensor = DHT22(Pin(15))
while True:
sensor.measure()
temp = sensor.temperature()
hum = sensor.humidity()
kelvin = temp+273
sleep(1)
print("T = {:02} H={:02}% k = {:02}" .format(temp,hum,kelvin))
#visualizacion de datos
oled.fill(0)
oled.text(str(temp),0,0)
oled.text(str(hum),0,10)
oled.text(str(kelvin),0,20)
oled.text("**************",0,50)
oled.show()
sleep(0.5)