Skip to content

Commit fd756be

Browse files
committed
added simpletest example
1 parent 617628d commit fd756be

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

examples/dht_simpletest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import time
2+
import adafruit_dht
3+
from board import D2
4+
5+
#initial the dht device
6+
dhtDevice = adafruit_dht.DHT22(D2)
7+
8+
while True:
9+
try:
10+
# show the values to the serial port
11+
temperature = dhtDevice.temperature*9/5+32
12+
humidity = dhtDevice.humidity
13+
print("Temp: {:.1f} F Humidity: {}% ".format(temperature, humidity))
14+
15+
except RuntimeError as error:
16+
print(error.args)
17+
18+
time.sleep(2.0)

0 commit comments

Comments
 (0)