-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2022_hydroponics_EY_2
54 lines (43 loc) · 1.71 KB
/
2022_hydroponics_EY_2
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
#Add Phidgets Library
from Phidget22.Phidget import *
from Phidget22.Devices.DigitalOutput import *
from Phidget22.Devices.LCD import *
from Phidget22.Devices.PHSensor import *
from Phidget22.Devices.TemperatureSensor import *
import time
#Create
lcd = LCD()
powerPlug = DigitalOutput()
phSensor = PHSensor()
temp = TemperatureSensor()
#User Controlled Variables
floodTime = 180 #in seconds
drainTime = 180 #in seconds
#Address
powerPlug.setIsHubPortDevice(True)
powerPlug.setHubPort(3) #This number indicates the port that is being used on the VINT Hub for the Power Plug.
#Open
powerPlug.openWaitForAttachment(5000)
lcd.openWaitForAttachment(1000)
phSensor.openWaitForAttachment(1000)
temp.openWaitForAttachment(1000)
#Functions
def systemFlood(): #This starts and stops the flood cycle (pump).
powerPlug.setState(1) #Turns pump on.
time.sleep(floodTime) #Pump stays on for number of seconds defined under "floodTime" above.
powerPlug.setState(0) #Turns pump off
time.sleep(drainTime) #Pump stays off for number of seconds defined under "drainTime" above.
def displaySystemData():
lcd.writeText(LCDFont.FONT_6x12, 0, 15, "pH Level: " + str(phSensor.getPH()) + " pH")
#ptint("pH Level: " + str(phSensor.getPH()))
time.sleep(0.25)
lcd.writeText(LCDFont.FONT_6x12, 0, 35, "Temp: " + str(temp.getTemperature()))
#ptint("Temp: " + str(VoltageInput.TemperatureSensor()))
time.sleep(0.25)
lcd.flush()
#Use your Phidgets
lcd.setBacklight(0.25) #This controls the brightness of the LCD screen.
# The following loop displays the pH and temperature readings on the LCD screen.
while (True):
systemFlood() #Starts the flood cycle.
displaySystemData() #Displays sensor data on LCD screen.