from machine import Pin, SoftI2C
from time import sleep
import ssd1306
import dht
sensor = dht.DHT22(Pin(15))
i2c= SoftI2C(sda=Pin(21), scl=Pin(22))
display = ssd1306.SSD1306_I2C(128,64,i2c)
while True:
#definimos una medida para el sensor
sensor.measure()
#Declaro una variable que almcene el sensor
#Temperatura
t = sensor.temperature()
#Humedad
h = sensor.humidity()
sleep (2)
display.fill(0)
display.text('Temperatura: %3.1f C'%t, 0,0)
display.text('Humedad: %3.1f %%' %h, 0,20)
display.show()
sleep(1)