from machine import Pin,I2C
from utime import sleep, sleep_ms
from dht import DHT22
from ssd1306 import SSD1306_I2C
ancho= 128
alto= 64
i2c=I2C(0, scl=Pin(22), sda=Pin(21))
oled = SSD1306_I2C(ancho, alto, i2c)
sensor_dht = DHT22(Pin(4))
print(i2c.scan(), "conectada" )
while True:
sensor_dht.measure()
tem = sensor_dht.temperature()
hum = sensor_dht.humidity()
#print("Tem:{}°c, Hum:{}% ".format(tem, hum))
#sleep_ms:(50)
oled.fill(0)
#oled.pixel(60, 30, 1)
#oled.hline(40, 60, 40, 1)
#oled.hline(40, 60, 40, 1)
#oled.vline(40, 20, 40, 1)
#oled,vline(80, 20, 40, 1)
oled.text("*"*30, 0, 0, 1)
oled.text("datos", 30, 9, 1)
oled.text("*"*30, 0, 20, 1)
oled.text("temp", 0, 30, 1)
oled.text(str(tem), 60, 30, 1)
oled.text("hum", 0, 40, 1)
oled.text(str(hum), 60, 40, 1)
oled.show()
sleep_ms(50)