Don't forget to add TIME_LAST_COOLER and COOLER_TIME to the global variable section near the top of bcc.py
Then replace the cooler function with the code below.
Again, the complete updated code is available on github - https://github.com/cyberlord8/bcc
TIME_LAST_COOLER = 0 #variable to track when cooler was last turned offCOOLER_TIME = 5 * 60 #5 minutes * 60 seconds
#cooler control functiondef cooler_control(current_temperature):global COOLER_ON, DESIRED_TEMP, DWELL, TIME_LAST_COOLER, COOLER_TIMEif current_temperature > DESIRED_TEMP + DWELL:if time.time() - TIME_LAST_COOLER > COOLER_TIME:#has it been more than 5 minutes?if not COOLER_ON:
COOLER_ON = Trueprint "Turning cooler on\n\n"GPIO.output("P9_23",GPIO.HIGH)else: print "Cooler can't turn on yet", 300 - (time.time() - TIME_LAST_COOLER),"seconds left\n\n"elif COOLER_ON:COOLER_ON = Falseprint "Turning cooler off\n\n"GPIO.output("P9_23",GPIO.LOW)TIME_LAST_COOLER = time.time()#reset cooler timerreturn
This project is great. I'm glad I found it. I was thinking of setting up a BrewPi but could not bring myself to use a separate microcontroller and computer. Plus this gives me the excuse I've been waiting for the buy a BBB! Thank you. If you need any help please let me know.
ReplyDelete