diff --git a/new.c b/new.c new file mode 100644 index 0000000..d25b585 --- /dev/null +++ b/new.c @@ -0,0 +1,18 @@ +import time + +import adafruit_dht +import board + +dht = adafruit_dht.DHT22(board.D2) + +while True: + try: + temperature = dht.temperature + humidity = dht.humidity + # Print what we got to the REPL + print("Temp: {:.1f} *C \t Humidity: {}%".format(temperature, humidity)) + except RuntimeError as e: + # Reading doesn't always work! Just print error and we'll try again + print("Reading from DHT failure: ", e.args) + + time.sleep(1)