I ma running s script in rc.local (sleep 10;sudo python /etc/zonneregelaar.py) &
and this script check's two temperature probes (DS1820) and if the delta between the two is greater than one degree, GPIO 7 is turned on. If it is smaller, its turn off. Behind GPIO 7 is a relai that turn on a pump.
Some how and I do not understand, but when the state of GPIO had must change the scripts halts.
So lets say GPIO 7 is 0 but it has to change to 1, then the scripts halts.
The files are a checksum, to see how the script is handeling.
Code: Select all
import RPi.GPIO as GPIO
import time
from datetime import datetime
n = datetime.now()
print n
file = open("/HD/log/zbstarting.txt", "w")
file.write("Datum tijd %s\n"%n)
file.close()
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(7, GPIO.OUT)
while True:
# Solorcollector
while True:
tfile = open("/sys/bus/w1/devices/10-00080278d076/w1_slave")
text = tfile.read()
tfile.close()
secondline = text.split("\n")[1]
temperaturedata = secondline.split(" ")[9]
temperature = float(temperaturedata[2:])
if temperature != -1250.0:
break
time.sleep (.1)
ZC = temperature
print ZC
# Solor Boiler
while True:
tfile = open("/sys/bus/w1/devices/28-000005e6d9ca/w1_slave")
text = tfile.read()
tfile.close()
secondline = text.split("\n")[1]
temperaturedata = secondline.split(" ")[9]
temperature = float(temperaturedata[2:])
if temperature != -1250.0:
break
time.sleep (.1)
tempboiler = temperature
print tempboiler
delta = ZC - tempboiler
print delta
n = datetime.now()
if delta > 1000.0 and tempboiler < 90000.0:
print "delta greater than one 1, pomp on"
GPIO.output(7, 1)
time.sleep(.1)
file1 = open("/HD/log/pomp.txt", "w")
file1.write("pump on %s\n"%n)
file1.close()
elif delta < 1000.0:
print "delta smaller than one 1, pomp off"
GPIO.output(7, 0)
time.sleep(.1)
file2 = open("/HD/log/pomp.txt", "w")
file2.write("pump off%s\n"%n)
file2.close()
else:
# temperature boiler almost on 100 degree, safety on, pomp off
GPIO.output(7, 0)
time.sleep(.1)
file3 = open("/HD/log/pomp.txt", "w")
file3.write("pump off %s\n"%n)
file3.close()
time.sleep(30)