-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-read.py
30 lines (27 loc) · 965 Bytes
/
test-read.py
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
29
30
import os
import RPi.GPIO as GPIO
import time
dsid = {}
#dsid["solarlead"] = "800000262ce2"
dsid["solarlead"] = "011621375bee"
dsid["solarreturn"] = "80000026331f"
dsid["poolreturn"] = "02161de351ee"
for tmpds in dsid:
tmpdir = ('/sys/bus/w1/devices/28-' + dsid[tmpds])
if (os.path.isdir(tmpdir) == False):
print("\n\n************\nW1 dir for %s not found. Attempting to reset GPIO 17 power\n******************\n\n" % tmpdir)
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17, GPIO.LOW)
time.sleep(3)
GPIO.output(17, GPIO.HIGH)
time.sleep(5)
try:
from w1thermsensor import W1ThermSensor
sensor = W1ThermSensor(W1ThermSensor.THERM_SENSOR_DS18B20, dsid[tmpds])
temp_f = sensor.get_temperature(W1ThermSensor.DEGREES_F)
print(dsid[tmpds] + "\t" + str(temp_f) + "\n")
except (SystemExit, KeyboardInterrupt):
raise
except Exception:
print("\n\nFailed to read temperature from %s" % dsid[tmpds], exc_info=True)