import dht
import machine
import time
DHT_PIN = 17
LED_PIN = 5
dht_sensor = dht.DHT22(machine.Pin(DHT_PIN))
led = machine.Pin(LED_PIN, machine.Pin.OUT)
def main():
while True:
try:
time.sleep(2)
dht_sensor.measure()
temperature = dht_sensor.temperature()
print("Температура: {:.2f}°C".format(temperature))
if temperature > -5.6:
led.value(1)
else:
led.value(0)
except OSError as e:
print("Помилка зчитування з датчика DHT22: ", e)
if __name__ == "__main__":
main()