-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpull
More file actions
executable file
·20 lines (16 loc) · 725 Bytes
/
pull
File metadata and controls
executable file
·20 lines (16 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/python
import argparse
from w1thermsensor import W1ThermSensor
parser = argparse.ArgumentParser()
parser.add_argument("-p","--path", required=True, help="Specify which sensor path to use")
parser.add_argument("-s","--scale", help="Choose fahrenheit (f) or celsius (c)")
args = parser.parse_args()
sensor = W1ThermSensor(W1ThermSensor.THERM_SENSOR_DS18B20, args.path)
temperature_in_celsius = sensor.get_temperature()
temperature_in_fahrenheit = sensor.get_temperature(W1ThermSensor.DEGREES_F)
if args.scale == "fahrenheit" or args.scale == "f":
print (temperature_in_fahrenheit)
elif args.scale == "celsius" or args.scale == "c":
print (temperature_in_celsius)
else:
print (temperature_in_celsius)