from machine import Pin, I2C
import dht
from SSD1306 import SSD1306_I2C
import utime as time
WIDTH= 128
HEIGHT = 64
i2c = I2C(0, scl=Pin(9),sda=Pin(8), freq=200000)
oled = SSD1306_I2C(WIDTH,HEIGHT,i2c)
sensor_dht= dht.DHT22(Pin(14))
while True:
time.sleep(1)
sensor_dht.measure()
hum=sensor_dht.humidity()
temp=sensor_dht.temperature()
print(f"Humidity is {hum}")
print(f"Temperature is {temp}")
time.sleep(2)
oled.fill(0)
oled.text("Temp is :",10,10)
oled.text(str(temp),50,10)
oled.text("C",90,10)
oled.show()
oled.text("Hum is:",5,30)
oled.text(str(hum),60,30)
oled.text("%",95,30)
oled.show()