-
Notifications
You must be signed in to change notification settings - Fork 0
/
relay.py
63 lines (45 loc) · 1.9 KB
/
relay.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import logging
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
logger = logging.getLogger('relay')
pin_light = 17
pin_heater = 27
pin_uvb = 22
pin_night = 23
lightLog = "\"Incandescent: {} UVB: {} Heat: {} Night: {}\"" \
".format(GPIO.input(pin_light), (GPIO.input(pin_uvb)), GPIO.input(pin_heater), GPIO.input(pin_night))"
def setup():
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BCM) # Use BCM numbering
GPIO.setup(pin_light, GPIO.OUT, initial=GPIO.HIGH)
GPIO.setup(pin_uvb, GPIO.OUT, initial=GPIO.HIGH)
GPIO.setup(pin_heater, GPIO.OUT, initial=GPIO.HIGH)
GPIO.setup(pin_night, GPIO.OUT, initial=GPIO.HIGH)
logger.debug(lightLog)
def day_light():
GPIO.output(pin_light, GPIO.LOW) # Turn on light bulb
GPIO.output(pin_uvb, GPIO.LOW) # Turn on UVB light
GPIO.output(pin_night, GPIO.HIGH) # Turn off night light
logger.debug(lightLog)
def night_light():
GPIO.output(pin_light, GPIO.HIGH) # Turn off light bulb
GPIO.output(pin_uvb, GPIO.HIGH) # Turn off UVB light
GPIO.output(pin_night, GPIO.LOW) # Turn on night light
logger.debug(lightLog)
def emergency_heat():
GPIO.output(pin_light, GPIO.LOW) # Turn on light bulb
GPIO.output(pin_uvb, GPIO.LOW) # Turn on UVB light
GPIO.output(pin_heater, GPIO.LOW) # Turn on heat
GPIO.output(pin_night, GPIO.LOW) # Turn on night light
logger.debug(lightLog)
def all_off():
GPIO.output(pin_light, GPIO.HIGH) # Turn off light bulb
GPIO.output(pin_uvb, GPIO.HIGH) # Turn off UVB light
GPIO.output(pin_heater, GPIO.HIGH) # Turn off heat
GPIO.output(pin_night, GPIO.HIGH) # Turn off night light
logger.debug(lightLog)
def heater_on():
GPIO.output(pin_heater, GPIO.LOW) # Turn on heater bulb
logger.debug(lightLog)
def heater_off():
GPIO.output(pin_heater, GPIO.HIGH) # Turn off heater bulb
logger.debug(lightLog)