forked from fisherinnovation/FI-Automated-Greenhouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutomatedGreenhouse.py
More file actions
107 lines (88 loc) · 3.12 KB
/
AutomatedGreenhouse.py
File metadata and controls
107 lines (88 loc) · 3.12 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python
##
# Fisher Innovation Automated Greenhouse Controller
# @author Matt Fisher (Fisher Innovation - http://fisherinnovation.com) [fisher.matt@gmail.com]
#
# Copyright (c) 2013 Fisher Innovation
# Licensed the MIT license.
#
# http://www.fisherinnovation.com
# https://github.com/fisherinnovation/FI-Automated-Greenhouse
##
import time
import sys
import os
#import RPi.GPIO as io
#io.setmode(io.BCM)
sys.path.append('conf')
import Configuration
sys.path.append('lib')
import LightController
import FanController
import TemperatureController
import WaterController
sys.path.append('lib/db')
import MySQL
import re
class AutomatedGreenhouse():
CONFIGURATION = False
DATABASE = False
LIGHTCONTROLLER = False
FANCONTROLLER = False
TEMPERATURECONTROLLER = False
WATERCONTROLLER = False
def __init__(self):
''' Application Setup '''
# Clear screen on application instantiation.
if os.name == 'nt':
os.system('cls') # Windows
else:
os.system('clear') # Linux / OSX
print("--------------------------------------------------------")
print("Fisher Innovation - Automated Greenhouse Controller")
print("Created By: Matt Fisher <fisher.matt@gmail.com>")
print("https://github.com/fisherinnovation/FI-Automated-Greenhouse")
print("--------------------------------------------------------")
print("")
#print("> NOTICE: Activating system...")
#inpput = raw_input(">")
#print inpput
self.CONFIGURATION = Configuration.Configuration()
self.DATABASE = MySQL.MySQL(self.CONFIGURATION)
# Init controllers
self.LIGHTCONTROLLER = LightController.LightController(self.CONFIGURATION)
self.FANCONTROLLER = FanController.FanController(self.CONFIGURATION)
self.WATERCONTROLLER = WaterController.WaterController(self.CONFIGURATION)
self.TEMPERATURECONTROLLER = TemperatureController.TemperatureController(self.CONFIGURATION)
print("> NOTICE: System Startup Complete.")
print("> NOTICE: Greenhouse Startup Complete!")
#self.mainLoop()
def mainLoop(self):
''' Main Application Loop. '''
# Read Water Flow Values
self.WATERCONTROLLER.readFlowSensor()
# Read Internal Greenhouse Temperature and Humidity
self.TEMPERATURECONTROLLER.readGreenhouseTemperature()
self.TEMPERATURECONTROLLER.readWaterTemperature()
# Water Temperature Checks
self.TEMPERATURECONTROLLER.regulateWaterTemperature()
'''
# Check if the system temperature is higher then configured.
if(CURRENT_TEMP > MAX_GREENHOUSE_TEMP):
# Temperature is too high.
# Make sure fans are on.
turnFanOn()
else:
# Temperature is at a stable reading.
if(CURRENT_HUMIDITY > MAX_GREENHOUSE_HUMIDITY):
turnFanOn() # Humidity is too high. Make sure fans are on.
else:
turnFanOff() # Humidity is at a stable reading. Make sure fans are off.
# Check lighting system conditions.
# Check if it is time to turn on the lights.
if(CURRENT_TIME[0] >= LIGHTS_ON_TIME):
turnLightsOn() # Turn lights on.
else:
turnLightsOff() # Turn lights off.
'''
greenhouse = AutomatedGreenhouse()