Ejemplo n.º 1
0
def main():
    #Main execution block
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(FANPWR, GPIO.OUT)

    probe_modules()

    while True:
        temp = read_temp()
        print("Temp: %s" % temp)
        print("")

        trigger = False

        #COOLING
        if (MODE == 0):
            if float(temp) > THRESHOLD + SWING:
                turn_on()
            elif float(temp) < THRESHOLD - SWING:
                turn_off()

        #HEATING
        if (MODE == 1):
            if (float(temp) < THRESHOLD) - SWING:
                turn_on()
            elif float(temp) > THRESHOLD + SWING:
                turn_off()

        time.sleep(INTERVAL)
Ejemplo n.º 2
0
def main():
    #Main execution block
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)

    GPIO.setup(FAN, GPIO.OUT)
    GPIO.setup(LED2, GPIO.OUT)
    probe_modules()

    while True:
        speed = 0
        temp = read_temp()
        diff = THRESHOLD - temp
        if (diff > 0):
            speed = (RANGE / 100) * diff * FACTOR
            #speed = 1024
            #print("speed = " + str(speed))
            if speed >= RANGE:

                set_fan_speed(MAX)
            else:
                set_fan_speed(int(speed))
        else:
            set_fan_speed(0)

        print("Temp:" + str(temp))
        print("")

        trigger = False

        #COOLING
        if (MODE == 0):
            if float(temp) > THRESHOLD + SWING:
                turn_on()
            elif float(temp) < THRESHOLD - SWING:
                turn_off()

        #HEATING
        if (MODE == 1):
            if float(temp) < THRESHOLD - SWING:
                turn_on()
            elif float(temp) > THRESHOLD:
                turn_off()

        time.sleep(INTERVAL)
Ejemplo n.º 3
0
#!/usr/bin/env python
import Stubs.RPi.GPIO as GPIO

THRESHOLD = 80
SWING = 1

METRIC = False
MODE = 0  #0 is cool 1 is heat
INTERVAL = 5

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(20, GPIO.OUT)
print(GPIO.input(20))
print("Turn Off!")
GPIO.output(20, GPIO.LOW)
print(GPIO.input(20))