import time import board import adafruit_dht # board.D2 is GPIO2, some other pins can work as well sensor = adafruit_dht.DHT22(board.D2) while True: try: print(f"{sensor.temperature=:.1f}ÂșC, {sensor.humidity=:.1f}%") except RuntimeError as error: # Errors happen fairly often, just keep going print(error.args[0]) time.sleep(2) continue except Exception as error: sensor.exit() raise error time.sleep(10)