1 changed files with 24 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||
import board |
|||
import digitalio |
|||
import adafruit_dht |
|||
import time |
|||
|
|||
dht = adafruit_dht.DHT22(board.GP8) |
|||
def mesure_temp(): |
|||
t = 0 |
|||
h = 0 |
|||
try: |
|||
dht.measure() |
|||
time.sleep(0.5) |
|||
h = dht.humidity |
|||
t = dht.temperature |
|||
print(t,h) |
|||
except: |
|||
print("Temperature measure failed!") |
|||
return (t, h) |
|||
|
|||
if __name__ == "__main__": |
|||
while True: |
|||
mesure_temp() |
|||
time.sleep(1) |
|||
|
Loading…
Reference in new issue