-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgettemp.py
More file actions
29 lines (21 loc) · 712 Bytes
/
gettemp.py
File metadata and controls
29 lines (21 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python
import sys
import Adafruit_DHT
def tempHumidity():
humidity, temperature = Adafruit_DHT.read(Adafruit_DHT.AM2302, 4)
temperature = temperature * 9/5.0 + 32
if humidity is not None and temperature is not None:
#return 'Temp={0:0.1f}* Humidity={1:0.1f}%'.format(temperature, humidity)
return temperature, humidity
else:
print('Failed to get reading. Try again!')
sys.exit(1)
def temp():
preformat = '{}'.format(print(tempHumidity['0']))
return preformat
def humidity():
# print(tempHumidity['1'])
preformat = '{}'.format(print(tempHumidity['1']))
#eturn tempHumidity['1']
return preformat
# print(tempHumidity()[1])