Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import Adafruit_DHT
- import RPi.GPIO as GPIO
- GPIO.setmode(GPIO.BCM) # GPIO Nummern statt Board Nummern
- sensor = Adafruit_DHT.DHT22
- pin = 4
- RELAIS_1_GPIO = 17
- GPIO.setup(RELAIS_1_GPIO, GPIO.OUT)
- counter=0
- mintemp=float(43.0)
- maxtemp=float(44.0)
- szeit=time.time() # startzeit
- lzeit=25200 #laufzeit 7 std
- while time.time() < szeit+lzeit:
- humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
- temp= round(temperature,1)
- if temp>maxtemp:
- GPIO.output(RELAIS_1_GPIO, GPIO.LOW)
- if temp<mintemp:
- GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
- # Nur für Testlauf
- # counter=counter+1
- # print "durchgang", counter
- # print "vergangene zeit", (time.time()-szeit)/60.0, "min"
- # print "restzeit", (szeit+lzeit-time.time())/60.0, "min"
- # print "temperatur:", temp
- # print "tempmesswert:", temperature
- time.sleep(30)
- GPIO.output(RELAIS_1_GPIO, GPIO.LOW)
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment