from machine import Pin, I2C
from time import sleep
from dht import DHT22
import ssd1306
dht = DHT22(Pin(23))
dht.measure()
led = Pin(21, Pin.OUT)
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
display = ssd1306.SSD1306_I2C(128, 64, i2c)
while True:
display.fill(0)
dht.measure()
temp = dht.temperature()
humidity = dht.humidity()
if temp >= 30:
led.value(1)
else:
led.value(0)
display.text(f"temperature: {temp}",0,0,1)
display.text(f"humidity: {humidity}",0,10,1)
display.show()
for i in range(2):
print(".")
sleep(1)
print("check")