Skip to content

Commit a8e2023

Browse files
committed
corrected python dht example
1 parent 83aaced commit a8e2023

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

source/DHT22.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# -*- coding: utf-8 -*
22
from time import sleep
3-
from dhtxx import DHT22
3+
#from dhtxx import DHT22
4+
from dhtxx import DHT11
45

5-
dht = DHT22(4)
6+
#dht = DHT22(22)
7+
dht = DHT11(22)
68
while True:
79
try:
810
res = dht.get_result_once()
9-
print('Temp: ' + '{:.2f}'.format(res[0]) + '°C, Hum: ' + '{:.2f}'.format(res[1]))
11+
print('Temp: ' + '{:.1f}'.format(res[0]) + '°C, Hum: ' + '{:.1f}'.format(res[1]))
1012
except Exception as e:
1113
print(e)
1214
sleep(1)

0 commit comments

Comments
 (0)