from machine import Pin, SoftI2C
import ssd1306
import dht
from time import sleep
i2c = SoftI2C(scl=Pin(22), sda=Pin(21))
sensorA = dht.DHT22(Pin(14))
sensorI = dht.DHT22(Pin(12))
button = Pin(25, Pin.IN, Pin.PULL_UP)
oled_width = 128
oled_heigth = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_heigth, i2c)
while True:
sensorA.measure()
sensorI.measure()
if button.value() == 0:
print("on")
tempA = sensorA.temperature()
tempI = sensorI.temperature()
feuchteA = sensorA.humidity()
feuchteI = sensorI.humidity()
zeile1 = "C A" + f"{tempA:5.1f}" + " I" + f"{tempI:5.1f}"
zeile2 = "% A" + f"{feuchteA:5.1f}" + " I" + f"{feuchteI:5.1f}"
oled.fill(0)
oled.text(zeile1, 0, 0)
oled.text(zeile2, 0, 10)
oled.show()
sleep(2)