using wireless sensor network controls to monitor an indoor aquaponics ... · 1 . using wireless...

35
1 Using Wireless Sensor Network Controls to monitor an indoor aquaponics system RET: Research Experiences for Teachers on Sensor Networks Summer 2013 By: Jose Guerrero, Carrollton-Farmers Branch ISD, Fern Edwards, Frisco ISD Faculty Mentor: Dr. Yan Wan, Department of Electrical Engineering Research Assistant: Vardham Sheth, Graduate Student EE University of North Texas, Denton Texas Acknowledgments Research conducted under RET (Research Experiences for Teachers), on Sensor Networks, Electrical Engineering Department, and Institute of Applied Sciences, UNT, Denton, Texas. This material is based upon work supported by the National Science Foundation under Grant No. 1132585 and by the IEEE Control Systems Society (CSS). Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation or IEEE CSS. For further information visit www.teo.unt.edu/ret/ http://untret2013.blogspot.com

Upload: trandan

Post on 23-Jul-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

1

Using Wireless Sensor Network Controls to monitor an indoor aquaponics system

RET Research Experiences for Teachers on Sensor Networks Summer 2013

By Jose Guerrero Carrollton-Farmers Branch ISD Fern Edwards Frisco ISD Faculty Mentor Dr Yan Wan Department of Electrical Engineering

Research Assistant Vardham Sheth Graduate Student EE University of North Texas Denton Texas

Acknowledgments Research conducted under RET (Research Experiences for Teachers) on Sensor Networks Electrical Engineering Department and Institute of Applied Sciences UNT Denton Texas This material is based upon work supported by the National Science Foundation under Grant No 1132585 and by the IEEE Control Systems Society (CSS) Any opinions findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation or IEEE CSS

For further information visit wwwteounteduret

httpuntret2013blogspotcom

2

Contents

Contents Acknowledgments 1

Abstract 3

Introduction 3

Literature Review 3

Aquaponics Classroom Model 5

Methods 8

Results 9

Discussion 9

Conclusion 10

Recommendations 11

Acknowledgements 11

References 11

Appendix A Additional Figures 13

Appendix B Links for video 24

Appendix C Arduino Code 25

3

Abstract This research report covers the use of a wireless sensor network (WSN) to monitor and remotely control various water parameters in an aquaponics system which served as a model for an aquatic ecosystem found in nature Research indicates that dissolved oxygen pH and water levels are the most important parameters to monitor and control for successful growth in both fish and plants Temperature and ammonia levels were also monitored but a control system was not developed because of the difficulty in re-establishing these two conditions using a control system An aquaponics system is not entirely a close system as fish need to be fed almost daily so an automatic food dispenser was created The aquaponics control system used an Arduino as the microprocessor and an XBee shield radio transmitter and receiver respectively Dissolved oxygen pH and temperature were collected in a database initially for 24 and then later at 48 hrs When this data was compared to the more developed and commercially used sensor probe ware PASCO less than a 3 error was calculated Data was also collected for dissolved oxygen pH and tank refill control systems and results show reliability and sustainability in each control

Introduction Aquaponics is a special form of recirculating aquaculture systems - namely a polyculture consisting of fish tanks (aquaculture) and plants that are cultivated in a soil free environment (hydroponics) The primary goal of aquaponics is to reuse the nutrients released by fish to grow crop plants By exploiting this natural phenomenon one can easily design and build an aquaponics system that is capable of sustaining plant growth and producing crops and food that is essentially chemical free and healthier (Graber and Junge 2009) Our design is not unique but instead mimics different parts of various systems One of the draw backs one encounters in aquaponics systems is the difficulty in maintaining optimal levels of production and the time it takes to monitor and manually reset parameters to the required amounts A primary goal for this project therefore is to integrate various sensors that would remotely monitor and respond to changes in water parameters namely pH water level and dissolved oxygen A self-monitoring system would enhance a system that has already been tried and proven and would take away a lot of the lsquogrunt workrsquo Our hopes with developing our own aquaponics control system are to control pH levels dissolved oxygen and water levels in the fish tank

Literature Review Aquaponics is the integrated culture of aquatic animals and plants grown in a soil-less environment and serves as an effective context for integrating the agricultural sciences and technologies into academic courses (Wardlow G 2002) The system is fairly simple in concept (Diver S 2004)

bull The waste products of one system serve as food or fuel for a second biological system bull The integration of fish and plants is a type of polyculture that increases diversity and

thereby enhances system stability bull Biological water filtration removes nutrients from water before it leaves the system bull Sale of greenhouse products generates income which supports the local economy

Maintaining good water quality is critical in an aquaponics system but more importantly in aquaculture Environmental parameters which play a critical role in an aquaculture system include concentrations of dissolved oxygen un-ionized ammonia-nitrogen nitrite- nitrogen and carbon dioxide in the water of the production system Several other important factors include nitrate concentration pH and alkalinity levels (Losordo T 1992)

4

There is a natural symbiotic relationship between fish and plants in this type of system but one need not forget that these systems are manmade so monitoring performance is of importance Ion waste production by fish cannot satisfy all plant requirements and the relationship between total feed provided for fish and the production of milliequivalents (mEq) of different macronutrients for plants is less known (Villarroel J 2011)

The simplicity in constructing aquaponics systems makes it adaptable for the average citizen choosing to cultivate plants as a hobby or small profit or for corporations choosing to replace food product import costs for an on-siteon-demand ecosystem In the early 1990rsquos Tom and Paula Speraneo owners of a small greenhouse operation near West Plains Missouri raised basil which they sold for $12 a pound to gourmet restaurants four hours away in St Louis Missouri They developed an aquaponics system known now as The Speraneo System in which they raised tilapia using a unique blend of microbes in above-ground tanks inside a solar greenhouse (Diver S 2004)

Universities have also taken advantage of an aquaponics system using both the biotic and abiotic conditions to serve as real world models for students pursuing careers in the agricultural sciences The University of Hawaii is an aquaculture research and extension complex which in 2009 began in the College of Technical Agriculture and Human Resources (CTAHRrsquos) program to include aquaponics technologies for food production methods The program began to address and raise awareness as to what it would take for an island state to become self-reliant in producing its own food The program has created a working prototype which allows for researchers professional and educators a means to identify the various inputs (energy feed micronutrients) of a renewable system (Tamaru C 2011) Most aquaponics systems currently in place need physical monitoring and any corrective environmental measures within this system take time to correct

There are wide arrays of uses for control systems in industrial and commercial platform Autonomous control systems are designed to perform well under significant uncertainties in the system and environment for extended periods of time and they must be able to compensate for significant system failures without external intervention (Antsaklis P 1991)

Interesting enough there are constraints with using these systems on long-term remote autonomous high-resolution monitoring in the real environment These limitations exist even with all the technological and commercial advances Constraints include limited availability of energy precise autonomous actuation and highly accurate localization With this in mind there has always been a need to address the problems that come with the sophistication and complexity in control Dynamic systems are complex and the demand for closed loop system requires sophisticated controllers Highly nonlinear systems normally require the use of more complex controllers than low order linear ones when goals beyond stability are to be met (Antsaklis P 1991)

As the global community searches for improved methods of sustainable living it becomes more apparent that there is a need for better monitoring and control of parameters that influence the well-being of aquatic and plant life In work done by Wang et al they describe the control of several of these parameters as the key to greater automation and efficiency They design and made wireless sensor networks for measuring temperature humidity carbon dioxide concentrations pH and other parameters Once measured the data was transferred and solved the problems encountered with wiring in a greenhouse

Our summer project incorporated WSN technology specifically Arduino which is an open-source electronics prototyping platform based on flexible easy-to use hardware The most

5

beneficial outcome to using Arduino was that software can be downloaded for free and CAD files are available under an open-source license Also there is a wide list of users incorporating it into art design and anyone interested in creating interactive objects or environments (Arduino 2012) To relay our data we used an XBee which can operate either in a transparent data mode or in a packet-based application programming interface (API) mode In the transparent mode data coming into the Data IN (DIN) pin is directly transmitted over-the-air to the intended receiving radios without any modification Incoming packets can either be directly addressed to one target (point-to-point) or broadcast to multiple targets (star) Along with Arduino and Xbee we utilized Atlas Scientific temperature pH and dissolved oxygen probes which are great for laboratory testing or long term field use Their Rugged Epoxy design makes them virtually unbreakable (Atlas- Scientific 2012)

Aquaponics Classroom Model The costs of building a classroom aquaponics depends on the scale and purpose you intend it to serve If on a tight budget building only one to serve as a classroom demonstration with student participation might suit your needs If your intention is to have them come up with their own design constraints and budget analysis then determining how students will fundraise for their parts is something you need to consider ahead of time Although you could give them the task of coming up with a list of fundraising ideas and provide you with an attached spreadsheet showing an analysis of fundraising supplies and expenses You want to ensure that both students and teacher have a realistic view of how much this will cost and where costs can be cut There are numerous designs available online some which utilize household supplies others that are more extensive and of greater scale In each case students should have researched extensively to cross out any designs that do not fit with the constraints of the classroom or which require a budget beyond their mean The following information describes our summer trainings project expectations for building a cost efficient aquaponics system and maintenance involved in making sure plants and fish receive their daily nutrients While making a list of supplies you should contact your schools purchasing department to ensure that there are local vendors who offer both a tax exempt and which you could use a schools purchase order for supplies We purchased all of our supplies from Lowersquos and Petsmart

We designed our aquaponics system to incorporate 3 height levels in cascade Level 1 tank was raised 25rsquo above the ground and set on a sturdy table We used a 30

gallon storage tank to house 6 goldfish and 6 gambusia a bulkhead inserted through one side of tank served as the tanks overflow drain a second bulkhead with a control valve allowed for water to fill level 2 which housed plants a bubbler was added and a hose was clamped which came from level 1 pump The tanks lid was modified for placement of our controls along with the sensor cluster and they were braced using a combination of zip ties bonding solutions and Velcro

6

Figure 1- Left hose coming from sump Center control valve and grow lights Right Otter box housing sensor cluster pH dispenser (in blue) food dispenser (inserted in 4 X 4)

Level 2 was raised 13rdquo off the ground and positioned on top of 3 12rsquo wide plywood which sat on two 10 gallon aquariums boxes (boxes were used because of accessibility) In total we grew 3 tomato and 3 cucumber plants while utilizing an ebb and flow system which allows for plant roots to get both water and free O2 at variable times The Ebb and Flow is a form of hydroponics that is known for its simplicity reliability of operation and low initial investment cost Pots are filled with an inert medium which does not function like soil or contribute nutrition to the plants but which anchors the roots and functions as a temporary reserve of water and solvent mineral nutrients The hydroponic solution alternately floods the system and is allowed to ebb away (wikipedia)

Figure 2- Tomatoes on the right and cucumbers on the left

Level 3 was reserved as our drainersump and included a small pump with a 4rsquo uphill power Both level 1 amp 2 drained down to 3rd level We grew 3 water lilies in a hydroponic condition

7

Figure 3- Water lilies inserted through the more buoyant Styrofoam

Figure 4- Overflow control valve in sump along with 4rsquo power motor

8

Figure 5- Fully assembled aquaponics system

Methods We collected daily measurements for pH temperature and dissolved oxygen of our aquaponics system We used the PASCO Spark probe to test these parameters as well as a commercially sold water condition kit which we needed to take physical water samples from our tank The kit also included tests for nitrite nitrate and ammonia levels These data were added to a spreadsheet and shared amongst the team We began comparing data between PASCO and sensor cluster in the clusterrsquos infancy stage (around week 2 of our training) and found little error testing for only 5 minutes between the two readings Several discrepancies were seen when cluster read for more than 5 minutes so Vardhman refined the circuit design By week 5 the cluster gave less than a 2 error for more than an hour of data collection for pH temperature and dissolved oxygen The intended goal for this project required a dayrsquos worth of data collection to allow us to determine the reliability of our cluster We also intended to collect data remotely so Vardhman created a database in which he can access it from his laptop We could then correct any major problems within our system if controllers failed plus this data can be graphed allowing us to see trends in environmental conditions A major part to our aquaponic system is the implementation of several controls to neutralize any environmental conditions that might spiral out of control We utilized a plastic dispenser for pH with an accompanying pH neutralizer with the sensor cluster taking constant readings it will allow for a specific amount of pH to be dispensed into the fish tank The control uses a closed loop system allowing for the sensor cluster to once again monitor water conditions before determining which steps to take A second control was the food dispenser (Figure 7) Like our pH dispenser this control is integrated into the sensor cluster A motor was

9

attached to a small fluid collecting bottle which was used to house fish pellets and was inserted into a 12rsquo 4rdquo X 4rdquo The bottle would rotate 360 degrees 4 times a day Our third control included a 50 gallon storage container (acting as a reservoir) which we filled with water which will dispense water into fish tank when sonar sensors located under tank lid sensed a frac12rdquo drop in water Finally in order to maintain the proper dissolved oxygen levels a bubbler was added to fish tank both the reservoir and bubbler used a turn onoff power control Once cluster and controls were built and tested for accuracy we added disturbances to our tank these included fluctuating pH DO and water level conditions We made sure not to vary pH drastically as this would shock and possibly kill our fish Instead only a +- 6 change in pH was needed to activate control Observations were made and recorded onto our blog

Results Data was collected at two different time period once at 24hrs and another at 48hrs Both sets of data showed our sensor cluster working as programmed Graphs created show no major disturbance indicating no further breakdown of cluster (Figure 8 and Figure 9 in Appendix) Figure 6 was collected from a set of points of Figure 9 and an algorithm was developed to allow for a much smoother line graph Figure 6 shows temperature constant at 23C pH levels 72 and DO levels at 78 Similarly Figure 8 maintains temperature and DO levels through the tested time period but pH drops several decimal points but not significantly to propose a sensor cluster problem Figure 9 shows data without the algorithm Figure 10 to Figure 17 show our last set of data with individual readings for pH DO and temperature (Appendix) There is no evidence in graphs of fluctuation in sensors Figure 18 and Figure 19 show data for testing of our controls (Appendix)

Figure 6 Results showing temperature at 23C pH levels 72 and DO levels at 78

Discussion Our initial data collection comparing sensor cluster to PASCO gave us pretty good readings for the first 5 minutes of testing Dissolved oxygen pH and temperature probes of cluster gave less than a 3 error when compare to PASCO (Figure 6) The problem arose when left for more than

10

5 minutes and also having the DO and pH probes in the tank at the same time When each of these probes are taking live readings there is a voltage interference that then translates to a digital error reading The errors were significant more than a point off These problems required for Vardhman to isolate dissolved oxygen from pH using a 6N137 single-channel and utilizing a dual-channel HCPL2630 This change also isolated ground for each of the probes (Figure 9 Figure 10 and Figure 11)

Once our sensor cluster was finalized we collected 24hr data of our fish tanks conditions (Figure 7) The accompanying Figure 8 graph was produced using MATLAB The data did not report any errors although we determined that there were too many data points to be graphed so Vardhman decided that on future trials to develop an algorithm which would eliminate these points Also there are multiple 0 point values with pH reading but this is expected due to the sensitivity of these probes This hiccup is not enough to alter graph readings We made a second attempt at collecting data but this time leaving the sensor cluster activated for nearly 48hrs Once again we had reliable data (Figure 15 and Figure 16) There are no major points within graph where it becomes inactive We wanted to show a comparison between a graph with a developed algorithm and one without this function Figure 15 Figure 16 Figure 19 and Figure 20 show this comparison Figure 17 and Figure 21 show a partial collection of data

The difficulty in simulating each control is that there are many factors that come into play- most importantly time We needed to manipulate the environmental conditions in a lab that would otherwise be found in nature Also because we are working with parts that require a power source the use of multiple outlets and power strips made our testing area fairly tight and problematic Finally we are working with electrical components that we all know do not mix well with water so it took time when stationing for demonstration Our final circuit system unfortunately was not soldered together so we needed to connect the appropriate wires for each control--again taking time

We tested our controls by manipulating each in an isolated volume of water After adding a disturbance for pH there is no immediate control input instead there is a 2 min delay but we do continue to gather data into our database (Figure 22) The actuator only dispenses after the average results are collected This average if you recall are 10 data points or collections at 8 seconds apart So a total of 80 sec passes before there is some action from actuator Vardhman programmed the system this way to allow the added control (fluid etc) to diffuse through water before taking the appropriate next steps The disturbance in this experimental trial was added at 20 sec (pH right above 7) levels dropped to just under 7 (fluctuating a little) and after 2 minutes a volume of pH corrector was added system continued to collect data averaging points One factor different to this graph compared to all others is that Vardhmans algorithm allows for a much smoother sloped line and removes every data point collected every 8 sec that would otherwise show sharp and steep lines The graph also shows where control is turned off and levels rise back to normal The reestablished conditions of our sampled water is a reliable control system Similar to pH we used an isolated volume of water to test tank refill We used Velcro to constrain two sonars and pumped water from a reservoir We started our data collection with water height of 19 cm pump turned on for a total time of nearly two minute until the desired depth of 14 cm pump then turned off (Figure 23) You can see video of each control simulation under the appendix of this report

Conclusion In conclusion after testing sensor cluster at two time intervals 24hr and 48hr we are confident in its reliability and accuracy Data and graphs provided do not suggest speculation of its

11

dependability the clusters parts and software are also trustworthy as they are mass produced and there are a number of professions who utilize its capacity to operate and maintain high end expensive machines Each control was tested under a simulated field environment and each performed as expected Preparation leading to tests remains a hurdle as there are many components that play intricate roles in each controls operations The use of water around electrical components also limits portability but with given time positioning for simulation can be obtained The aquaponic system itself played a small role in each controls simulation as this project is itrsquos first of its kind so experimenting in controlled environments allowed for minimal fish and plant casualties Given the preparation and collaboration in finalizing this study future aquaponic control systems can be fully implemented with the desired expected results which include autonomy fish culture and plant ecology

Recommendations It is recommended when combining a traditional aquaponic system with automated control systems for there to be collaborators at either a university or professional level The design and creation of sensor clusters using arduino as a microprossesor and an Xbee shield will more than likely be beyond the average citizenrsquos knowledge Beginning with an indoor small scale prototype will most likely save you money and time plus implementation of control system will be more accessible to troubleshoot Research knowledge of running and maintaining an aquaponic system and learning how controls work is important for a successful integrated system

Acknowledgements RET (Research Experiences for Teachers) Site on Sensor Networks Electrical Engineering Department and Institute of Applied Sciences UNT Denton Texas This material is based upon work supported by the National Science Foundation (NSF) under Grant No 1132585 and the IEEE Control Systems Society (CSS) Outreach Fund Any opinions findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF or the IEEE We would like to thank UNTrsquos Electrical Engineering Department staff and graduate students for their support and expertise throughout the course of this project In particular Dr Yan Wan for her mentoring and workshops over system controls Vardhman Sheth for working with us on designing creating and executing our sensor cluster and individual controls Dr Thompson and Dr Acevedo for initiating this training and requiring the very best from each of the participating teachers We would also like to acknowledge all participating teachers for their encouragement and enthusiasm throughout the entire training

References Antsaklis P Passino K An Introduction to Autonomous Control Systems IEEE Control

Systems 1991 httpwww2eceohio-stateedu~passinoPapersToPostIntro-Aut-Controlpdf

Arduino - HomePage Np nd Web 17 July 2012 lthttpwwwarduinoccgt Atlas-Scientific Home Np nd Web 17 July 2012 lthttpatlas-scientificcomgt Diver S AQUAPONICS - INTEGRATION OF HYDROPONICS WITH AQUACULTURE httpwwwacesedudeptfisherieseducationdocumentsHorticulturesystemsguidepdf Graber A Junge R ldquo Aquaponic Systems Nutrient recycling from fish wastewater by vegetable

productionrdquo Desalination 246147-156 012009 DOI 101016jdesal200803048

12

Losordo T Recirculating Aquaculture Tank Production Systems SRAC Publication No 4531992 httpuniversityuogeducalspeoplepubsaquac453recpdf

Tamaru C Challenges and Opportunities for Aquaponics in the College of Tropical Agriculture and Human Resources 2011 httpwwwctahrhawaiiedusustainagnewsarticlesV6-Tamaru-aquaponicpdf

Villarroel M Aquaponics integrating fish feeding rates and ion waste production for strawberry hydroponics 2011 httprevistasiniaesindexphpsjararticleview1758

Wardlow G Enhancing Student Interest in the Agricultural Sciences through Aquaponics J Nat Resour Life Sci Educ Vol 31 2002 httpswwwagronomyorgfilesjnrlseissues2002e00-15kpdf

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

2

Contents

Contents Acknowledgments 1

Abstract 3

Introduction 3

Literature Review 3

Aquaponics Classroom Model 5

Methods 8

Results 9

Discussion 9

Conclusion 10

Recommendations 11

Acknowledgements 11

References 11

Appendix A Additional Figures 13

Appendix B Links for video 24

Appendix C Arduino Code 25

3

Abstract This research report covers the use of a wireless sensor network (WSN) to monitor and remotely control various water parameters in an aquaponics system which served as a model for an aquatic ecosystem found in nature Research indicates that dissolved oxygen pH and water levels are the most important parameters to monitor and control for successful growth in both fish and plants Temperature and ammonia levels were also monitored but a control system was not developed because of the difficulty in re-establishing these two conditions using a control system An aquaponics system is not entirely a close system as fish need to be fed almost daily so an automatic food dispenser was created The aquaponics control system used an Arduino as the microprocessor and an XBee shield radio transmitter and receiver respectively Dissolved oxygen pH and temperature were collected in a database initially for 24 and then later at 48 hrs When this data was compared to the more developed and commercially used sensor probe ware PASCO less than a 3 error was calculated Data was also collected for dissolved oxygen pH and tank refill control systems and results show reliability and sustainability in each control

Introduction Aquaponics is a special form of recirculating aquaculture systems - namely a polyculture consisting of fish tanks (aquaculture) and plants that are cultivated in a soil free environment (hydroponics) The primary goal of aquaponics is to reuse the nutrients released by fish to grow crop plants By exploiting this natural phenomenon one can easily design and build an aquaponics system that is capable of sustaining plant growth and producing crops and food that is essentially chemical free and healthier (Graber and Junge 2009) Our design is not unique but instead mimics different parts of various systems One of the draw backs one encounters in aquaponics systems is the difficulty in maintaining optimal levels of production and the time it takes to monitor and manually reset parameters to the required amounts A primary goal for this project therefore is to integrate various sensors that would remotely monitor and respond to changes in water parameters namely pH water level and dissolved oxygen A self-monitoring system would enhance a system that has already been tried and proven and would take away a lot of the lsquogrunt workrsquo Our hopes with developing our own aquaponics control system are to control pH levels dissolved oxygen and water levels in the fish tank

Literature Review Aquaponics is the integrated culture of aquatic animals and plants grown in a soil-less environment and serves as an effective context for integrating the agricultural sciences and technologies into academic courses (Wardlow G 2002) The system is fairly simple in concept (Diver S 2004)

bull The waste products of one system serve as food or fuel for a second biological system bull The integration of fish and plants is a type of polyculture that increases diversity and

thereby enhances system stability bull Biological water filtration removes nutrients from water before it leaves the system bull Sale of greenhouse products generates income which supports the local economy

Maintaining good water quality is critical in an aquaponics system but more importantly in aquaculture Environmental parameters which play a critical role in an aquaculture system include concentrations of dissolved oxygen un-ionized ammonia-nitrogen nitrite- nitrogen and carbon dioxide in the water of the production system Several other important factors include nitrate concentration pH and alkalinity levels (Losordo T 1992)

4

There is a natural symbiotic relationship between fish and plants in this type of system but one need not forget that these systems are manmade so monitoring performance is of importance Ion waste production by fish cannot satisfy all plant requirements and the relationship between total feed provided for fish and the production of milliequivalents (mEq) of different macronutrients for plants is less known (Villarroel J 2011)

The simplicity in constructing aquaponics systems makes it adaptable for the average citizen choosing to cultivate plants as a hobby or small profit or for corporations choosing to replace food product import costs for an on-siteon-demand ecosystem In the early 1990rsquos Tom and Paula Speraneo owners of a small greenhouse operation near West Plains Missouri raised basil which they sold for $12 a pound to gourmet restaurants four hours away in St Louis Missouri They developed an aquaponics system known now as The Speraneo System in which they raised tilapia using a unique blend of microbes in above-ground tanks inside a solar greenhouse (Diver S 2004)

Universities have also taken advantage of an aquaponics system using both the biotic and abiotic conditions to serve as real world models for students pursuing careers in the agricultural sciences The University of Hawaii is an aquaculture research and extension complex which in 2009 began in the College of Technical Agriculture and Human Resources (CTAHRrsquos) program to include aquaponics technologies for food production methods The program began to address and raise awareness as to what it would take for an island state to become self-reliant in producing its own food The program has created a working prototype which allows for researchers professional and educators a means to identify the various inputs (energy feed micronutrients) of a renewable system (Tamaru C 2011) Most aquaponics systems currently in place need physical monitoring and any corrective environmental measures within this system take time to correct

There are wide arrays of uses for control systems in industrial and commercial platform Autonomous control systems are designed to perform well under significant uncertainties in the system and environment for extended periods of time and they must be able to compensate for significant system failures without external intervention (Antsaklis P 1991)

Interesting enough there are constraints with using these systems on long-term remote autonomous high-resolution monitoring in the real environment These limitations exist even with all the technological and commercial advances Constraints include limited availability of energy precise autonomous actuation and highly accurate localization With this in mind there has always been a need to address the problems that come with the sophistication and complexity in control Dynamic systems are complex and the demand for closed loop system requires sophisticated controllers Highly nonlinear systems normally require the use of more complex controllers than low order linear ones when goals beyond stability are to be met (Antsaklis P 1991)

As the global community searches for improved methods of sustainable living it becomes more apparent that there is a need for better monitoring and control of parameters that influence the well-being of aquatic and plant life In work done by Wang et al they describe the control of several of these parameters as the key to greater automation and efficiency They design and made wireless sensor networks for measuring temperature humidity carbon dioxide concentrations pH and other parameters Once measured the data was transferred and solved the problems encountered with wiring in a greenhouse

Our summer project incorporated WSN technology specifically Arduino which is an open-source electronics prototyping platform based on flexible easy-to use hardware The most

5

beneficial outcome to using Arduino was that software can be downloaded for free and CAD files are available under an open-source license Also there is a wide list of users incorporating it into art design and anyone interested in creating interactive objects or environments (Arduino 2012) To relay our data we used an XBee which can operate either in a transparent data mode or in a packet-based application programming interface (API) mode In the transparent mode data coming into the Data IN (DIN) pin is directly transmitted over-the-air to the intended receiving radios without any modification Incoming packets can either be directly addressed to one target (point-to-point) or broadcast to multiple targets (star) Along with Arduino and Xbee we utilized Atlas Scientific temperature pH and dissolved oxygen probes which are great for laboratory testing or long term field use Their Rugged Epoxy design makes them virtually unbreakable (Atlas- Scientific 2012)

Aquaponics Classroom Model The costs of building a classroom aquaponics depends on the scale and purpose you intend it to serve If on a tight budget building only one to serve as a classroom demonstration with student participation might suit your needs If your intention is to have them come up with their own design constraints and budget analysis then determining how students will fundraise for their parts is something you need to consider ahead of time Although you could give them the task of coming up with a list of fundraising ideas and provide you with an attached spreadsheet showing an analysis of fundraising supplies and expenses You want to ensure that both students and teacher have a realistic view of how much this will cost and where costs can be cut There are numerous designs available online some which utilize household supplies others that are more extensive and of greater scale In each case students should have researched extensively to cross out any designs that do not fit with the constraints of the classroom or which require a budget beyond their mean The following information describes our summer trainings project expectations for building a cost efficient aquaponics system and maintenance involved in making sure plants and fish receive their daily nutrients While making a list of supplies you should contact your schools purchasing department to ensure that there are local vendors who offer both a tax exempt and which you could use a schools purchase order for supplies We purchased all of our supplies from Lowersquos and Petsmart

We designed our aquaponics system to incorporate 3 height levels in cascade Level 1 tank was raised 25rsquo above the ground and set on a sturdy table We used a 30

gallon storage tank to house 6 goldfish and 6 gambusia a bulkhead inserted through one side of tank served as the tanks overflow drain a second bulkhead with a control valve allowed for water to fill level 2 which housed plants a bubbler was added and a hose was clamped which came from level 1 pump The tanks lid was modified for placement of our controls along with the sensor cluster and they were braced using a combination of zip ties bonding solutions and Velcro

6

Figure 1- Left hose coming from sump Center control valve and grow lights Right Otter box housing sensor cluster pH dispenser (in blue) food dispenser (inserted in 4 X 4)

Level 2 was raised 13rdquo off the ground and positioned on top of 3 12rsquo wide plywood which sat on two 10 gallon aquariums boxes (boxes were used because of accessibility) In total we grew 3 tomato and 3 cucumber plants while utilizing an ebb and flow system which allows for plant roots to get both water and free O2 at variable times The Ebb and Flow is a form of hydroponics that is known for its simplicity reliability of operation and low initial investment cost Pots are filled with an inert medium which does not function like soil or contribute nutrition to the plants but which anchors the roots and functions as a temporary reserve of water and solvent mineral nutrients The hydroponic solution alternately floods the system and is allowed to ebb away (wikipedia)

Figure 2- Tomatoes on the right and cucumbers on the left

Level 3 was reserved as our drainersump and included a small pump with a 4rsquo uphill power Both level 1 amp 2 drained down to 3rd level We grew 3 water lilies in a hydroponic condition

7

Figure 3- Water lilies inserted through the more buoyant Styrofoam

Figure 4- Overflow control valve in sump along with 4rsquo power motor

8

Figure 5- Fully assembled aquaponics system

Methods We collected daily measurements for pH temperature and dissolved oxygen of our aquaponics system We used the PASCO Spark probe to test these parameters as well as a commercially sold water condition kit which we needed to take physical water samples from our tank The kit also included tests for nitrite nitrate and ammonia levels These data were added to a spreadsheet and shared amongst the team We began comparing data between PASCO and sensor cluster in the clusterrsquos infancy stage (around week 2 of our training) and found little error testing for only 5 minutes between the two readings Several discrepancies were seen when cluster read for more than 5 minutes so Vardhman refined the circuit design By week 5 the cluster gave less than a 2 error for more than an hour of data collection for pH temperature and dissolved oxygen The intended goal for this project required a dayrsquos worth of data collection to allow us to determine the reliability of our cluster We also intended to collect data remotely so Vardhman created a database in which he can access it from his laptop We could then correct any major problems within our system if controllers failed plus this data can be graphed allowing us to see trends in environmental conditions A major part to our aquaponic system is the implementation of several controls to neutralize any environmental conditions that might spiral out of control We utilized a plastic dispenser for pH with an accompanying pH neutralizer with the sensor cluster taking constant readings it will allow for a specific amount of pH to be dispensed into the fish tank The control uses a closed loop system allowing for the sensor cluster to once again monitor water conditions before determining which steps to take A second control was the food dispenser (Figure 7) Like our pH dispenser this control is integrated into the sensor cluster A motor was

9

attached to a small fluid collecting bottle which was used to house fish pellets and was inserted into a 12rsquo 4rdquo X 4rdquo The bottle would rotate 360 degrees 4 times a day Our third control included a 50 gallon storage container (acting as a reservoir) which we filled with water which will dispense water into fish tank when sonar sensors located under tank lid sensed a frac12rdquo drop in water Finally in order to maintain the proper dissolved oxygen levels a bubbler was added to fish tank both the reservoir and bubbler used a turn onoff power control Once cluster and controls were built and tested for accuracy we added disturbances to our tank these included fluctuating pH DO and water level conditions We made sure not to vary pH drastically as this would shock and possibly kill our fish Instead only a +- 6 change in pH was needed to activate control Observations were made and recorded onto our blog

Results Data was collected at two different time period once at 24hrs and another at 48hrs Both sets of data showed our sensor cluster working as programmed Graphs created show no major disturbance indicating no further breakdown of cluster (Figure 8 and Figure 9 in Appendix) Figure 6 was collected from a set of points of Figure 9 and an algorithm was developed to allow for a much smoother line graph Figure 6 shows temperature constant at 23C pH levels 72 and DO levels at 78 Similarly Figure 8 maintains temperature and DO levels through the tested time period but pH drops several decimal points but not significantly to propose a sensor cluster problem Figure 9 shows data without the algorithm Figure 10 to Figure 17 show our last set of data with individual readings for pH DO and temperature (Appendix) There is no evidence in graphs of fluctuation in sensors Figure 18 and Figure 19 show data for testing of our controls (Appendix)

Figure 6 Results showing temperature at 23C pH levels 72 and DO levels at 78

Discussion Our initial data collection comparing sensor cluster to PASCO gave us pretty good readings for the first 5 minutes of testing Dissolved oxygen pH and temperature probes of cluster gave less than a 3 error when compare to PASCO (Figure 6) The problem arose when left for more than

10

5 minutes and also having the DO and pH probes in the tank at the same time When each of these probes are taking live readings there is a voltage interference that then translates to a digital error reading The errors were significant more than a point off These problems required for Vardhman to isolate dissolved oxygen from pH using a 6N137 single-channel and utilizing a dual-channel HCPL2630 This change also isolated ground for each of the probes (Figure 9 Figure 10 and Figure 11)

Once our sensor cluster was finalized we collected 24hr data of our fish tanks conditions (Figure 7) The accompanying Figure 8 graph was produced using MATLAB The data did not report any errors although we determined that there were too many data points to be graphed so Vardhman decided that on future trials to develop an algorithm which would eliminate these points Also there are multiple 0 point values with pH reading but this is expected due to the sensitivity of these probes This hiccup is not enough to alter graph readings We made a second attempt at collecting data but this time leaving the sensor cluster activated for nearly 48hrs Once again we had reliable data (Figure 15 and Figure 16) There are no major points within graph where it becomes inactive We wanted to show a comparison between a graph with a developed algorithm and one without this function Figure 15 Figure 16 Figure 19 and Figure 20 show this comparison Figure 17 and Figure 21 show a partial collection of data

The difficulty in simulating each control is that there are many factors that come into play- most importantly time We needed to manipulate the environmental conditions in a lab that would otherwise be found in nature Also because we are working with parts that require a power source the use of multiple outlets and power strips made our testing area fairly tight and problematic Finally we are working with electrical components that we all know do not mix well with water so it took time when stationing for demonstration Our final circuit system unfortunately was not soldered together so we needed to connect the appropriate wires for each control--again taking time

We tested our controls by manipulating each in an isolated volume of water After adding a disturbance for pH there is no immediate control input instead there is a 2 min delay but we do continue to gather data into our database (Figure 22) The actuator only dispenses after the average results are collected This average if you recall are 10 data points or collections at 8 seconds apart So a total of 80 sec passes before there is some action from actuator Vardhman programmed the system this way to allow the added control (fluid etc) to diffuse through water before taking the appropriate next steps The disturbance in this experimental trial was added at 20 sec (pH right above 7) levels dropped to just under 7 (fluctuating a little) and after 2 minutes a volume of pH corrector was added system continued to collect data averaging points One factor different to this graph compared to all others is that Vardhmans algorithm allows for a much smoother sloped line and removes every data point collected every 8 sec that would otherwise show sharp and steep lines The graph also shows where control is turned off and levels rise back to normal The reestablished conditions of our sampled water is a reliable control system Similar to pH we used an isolated volume of water to test tank refill We used Velcro to constrain two sonars and pumped water from a reservoir We started our data collection with water height of 19 cm pump turned on for a total time of nearly two minute until the desired depth of 14 cm pump then turned off (Figure 23) You can see video of each control simulation under the appendix of this report

Conclusion In conclusion after testing sensor cluster at two time intervals 24hr and 48hr we are confident in its reliability and accuracy Data and graphs provided do not suggest speculation of its

11

dependability the clusters parts and software are also trustworthy as they are mass produced and there are a number of professions who utilize its capacity to operate and maintain high end expensive machines Each control was tested under a simulated field environment and each performed as expected Preparation leading to tests remains a hurdle as there are many components that play intricate roles in each controls operations The use of water around electrical components also limits portability but with given time positioning for simulation can be obtained The aquaponic system itself played a small role in each controls simulation as this project is itrsquos first of its kind so experimenting in controlled environments allowed for minimal fish and plant casualties Given the preparation and collaboration in finalizing this study future aquaponic control systems can be fully implemented with the desired expected results which include autonomy fish culture and plant ecology

Recommendations It is recommended when combining a traditional aquaponic system with automated control systems for there to be collaborators at either a university or professional level The design and creation of sensor clusters using arduino as a microprossesor and an Xbee shield will more than likely be beyond the average citizenrsquos knowledge Beginning with an indoor small scale prototype will most likely save you money and time plus implementation of control system will be more accessible to troubleshoot Research knowledge of running and maintaining an aquaponic system and learning how controls work is important for a successful integrated system

Acknowledgements RET (Research Experiences for Teachers) Site on Sensor Networks Electrical Engineering Department and Institute of Applied Sciences UNT Denton Texas This material is based upon work supported by the National Science Foundation (NSF) under Grant No 1132585 and the IEEE Control Systems Society (CSS) Outreach Fund Any opinions findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF or the IEEE We would like to thank UNTrsquos Electrical Engineering Department staff and graduate students for their support and expertise throughout the course of this project In particular Dr Yan Wan for her mentoring and workshops over system controls Vardhman Sheth for working with us on designing creating and executing our sensor cluster and individual controls Dr Thompson and Dr Acevedo for initiating this training and requiring the very best from each of the participating teachers We would also like to acknowledge all participating teachers for their encouragement and enthusiasm throughout the entire training

References Antsaklis P Passino K An Introduction to Autonomous Control Systems IEEE Control

Systems 1991 httpwww2eceohio-stateedu~passinoPapersToPostIntro-Aut-Controlpdf

Arduino - HomePage Np nd Web 17 July 2012 lthttpwwwarduinoccgt Atlas-Scientific Home Np nd Web 17 July 2012 lthttpatlas-scientificcomgt Diver S AQUAPONICS - INTEGRATION OF HYDROPONICS WITH AQUACULTURE httpwwwacesedudeptfisherieseducationdocumentsHorticulturesystemsguidepdf Graber A Junge R ldquo Aquaponic Systems Nutrient recycling from fish wastewater by vegetable

productionrdquo Desalination 246147-156 012009 DOI 101016jdesal200803048

12

Losordo T Recirculating Aquaculture Tank Production Systems SRAC Publication No 4531992 httpuniversityuogeducalspeoplepubsaquac453recpdf

Tamaru C Challenges and Opportunities for Aquaponics in the College of Tropical Agriculture and Human Resources 2011 httpwwwctahrhawaiiedusustainagnewsarticlesV6-Tamaru-aquaponicpdf

Villarroel M Aquaponics integrating fish feeding rates and ion waste production for strawberry hydroponics 2011 httprevistasiniaesindexphpsjararticleview1758

Wardlow G Enhancing Student Interest in the Agricultural Sciences through Aquaponics J Nat Resour Life Sci Educ Vol 31 2002 httpswwwagronomyorgfilesjnrlseissues2002e00-15kpdf

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

3

Abstract This research report covers the use of a wireless sensor network (WSN) to monitor and remotely control various water parameters in an aquaponics system which served as a model for an aquatic ecosystem found in nature Research indicates that dissolved oxygen pH and water levels are the most important parameters to monitor and control for successful growth in both fish and plants Temperature and ammonia levels were also monitored but a control system was not developed because of the difficulty in re-establishing these two conditions using a control system An aquaponics system is not entirely a close system as fish need to be fed almost daily so an automatic food dispenser was created The aquaponics control system used an Arduino as the microprocessor and an XBee shield radio transmitter and receiver respectively Dissolved oxygen pH and temperature were collected in a database initially for 24 and then later at 48 hrs When this data was compared to the more developed and commercially used sensor probe ware PASCO less than a 3 error was calculated Data was also collected for dissolved oxygen pH and tank refill control systems and results show reliability and sustainability in each control

Introduction Aquaponics is a special form of recirculating aquaculture systems - namely a polyculture consisting of fish tanks (aquaculture) and plants that are cultivated in a soil free environment (hydroponics) The primary goal of aquaponics is to reuse the nutrients released by fish to grow crop plants By exploiting this natural phenomenon one can easily design and build an aquaponics system that is capable of sustaining plant growth and producing crops and food that is essentially chemical free and healthier (Graber and Junge 2009) Our design is not unique but instead mimics different parts of various systems One of the draw backs one encounters in aquaponics systems is the difficulty in maintaining optimal levels of production and the time it takes to monitor and manually reset parameters to the required amounts A primary goal for this project therefore is to integrate various sensors that would remotely monitor and respond to changes in water parameters namely pH water level and dissolved oxygen A self-monitoring system would enhance a system that has already been tried and proven and would take away a lot of the lsquogrunt workrsquo Our hopes with developing our own aquaponics control system are to control pH levels dissolved oxygen and water levels in the fish tank

Literature Review Aquaponics is the integrated culture of aquatic animals and plants grown in a soil-less environment and serves as an effective context for integrating the agricultural sciences and technologies into academic courses (Wardlow G 2002) The system is fairly simple in concept (Diver S 2004)

bull The waste products of one system serve as food or fuel for a second biological system bull The integration of fish and plants is a type of polyculture that increases diversity and

thereby enhances system stability bull Biological water filtration removes nutrients from water before it leaves the system bull Sale of greenhouse products generates income which supports the local economy

Maintaining good water quality is critical in an aquaponics system but more importantly in aquaculture Environmental parameters which play a critical role in an aquaculture system include concentrations of dissolved oxygen un-ionized ammonia-nitrogen nitrite- nitrogen and carbon dioxide in the water of the production system Several other important factors include nitrate concentration pH and alkalinity levels (Losordo T 1992)

4

There is a natural symbiotic relationship between fish and plants in this type of system but one need not forget that these systems are manmade so monitoring performance is of importance Ion waste production by fish cannot satisfy all plant requirements and the relationship between total feed provided for fish and the production of milliequivalents (mEq) of different macronutrients for plants is less known (Villarroel J 2011)

The simplicity in constructing aquaponics systems makes it adaptable for the average citizen choosing to cultivate plants as a hobby or small profit or for corporations choosing to replace food product import costs for an on-siteon-demand ecosystem In the early 1990rsquos Tom and Paula Speraneo owners of a small greenhouse operation near West Plains Missouri raised basil which they sold for $12 a pound to gourmet restaurants four hours away in St Louis Missouri They developed an aquaponics system known now as The Speraneo System in which they raised tilapia using a unique blend of microbes in above-ground tanks inside a solar greenhouse (Diver S 2004)

Universities have also taken advantage of an aquaponics system using both the biotic and abiotic conditions to serve as real world models for students pursuing careers in the agricultural sciences The University of Hawaii is an aquaculture research and extension complex which in 2009 began in the College of Technical Agriculture and Human Resources (CTAHRrsquos) program to include aquaponics technologies for food production methods The program began to address and raise awareness as to what it would take for an island state to become self-reliant in producing its own food The program has created a working prototype which allows for researchers professional and educators a means to identify the various inputs (energy feed micronutrients) of a renewable system (Tamaru C 2011) Most aquaponics systems currently in place need physical monitoring and any corrective environmental measures within this system take time to correct

There are wide arrays of uses for control systems in industrial and commercial platform Autonomous control systems are designed to perform well under significant uncertainties in the system and environment for extended periods of time and they must be able to compensate for significant system failures without external intervention (Antsaklis P 1991)

Interesting enough there are constraints with using these systems on long-term remote autonomous high-resolution monitoring in the real environment These limitations exist even with all the technological and commercial advances Constraints include limited availability of energy precise autonomous actuation and highly accurate localization With this in mind there has always been a need to address the problems that come with the sophistication and complexity in control Dynamic systems are complex and the demand for closed loop system requires sophisticated controllers Highly nonlinear systems normally require the use of more complex controllers than low order linear ones when goals beyond stability are to be met (Antsaklis P 1991)

As the global community searches for improved methods of sustainable living it becomes more apparent that there is a need for better monitoring and control of parameters that influence the well-being of aquatic and plant life In work done by Wang et al they describe the control of several of these parameters as the key to greater automation and efficiency They design and made wireless sensor networks for measuring temperature humidity carbon dioxide concentrations pH and other parameters Once measured the data was transferred and solved the problems encountered with wiring in a greenhouse

Our summer project incorporated WSN technology specifically Arduino which is an open-source electronics prototyping platform based on flexible easy-to use hardware The most

5

beneficial outcome to using Arduino was that software can be downloaded for free and CAD files are available under an open-source license Also there is a wide list of users incorporating it into art design and anyone interested in creating interactive objects or environments (Arduino 2012) To relay our data we used an XBee which can operate either in a transparent data mode or in a packet-based application programming interface (API) mode In the transparent mode data coming into the Data IN (DIN) pin is directly transmitted over-the-air to the intended receiving radios without any modification Incoming packets can either be directly addressed to one target (point-to-point) or broadcast to multiple targets (star) Along with Arduino and Xbee we utilized Atlas Scientific temperature pH and dissolved oxygen probes which are great for laboratory testing or long term field use Their Rugged Epoxy design makes them virtually unbreakable (Atlas- Scientific 2012)

Aquaponics Classroom Model The costs of building a classroom aquaponics depends on the scale and purpose you intend it to serve If on a tight budget building only one to serve as a classroom demonstration with student participation might suit your needs If your intention is to have them come up with their own design constraints and budget analysis then determining how students will fundraise for their parts is something you need to consider ahead of time Although you could give them the task of coming up with a list of fundraising ideas and provide you with an attached spreadsheet showing an analysis of fundraising supplies and expenses You want to ensure that both students and teacher have a realistic view of how much this will cost and where costs can be cut There are numerous designs available online some which utilize household supplies others that are more extensive and of greater scale In each case students should have researched extensively to cross out any designs that do not fit with the constraints of the classroom or which require a budget beyond their mean The following information describes our summer trainings project expectations for building a cost efficient aquaponics system and maintenance involved in making sure plants and fish receive their daily nutrients While making a list of supplies you should contact your schools purchasing department to ensure that there are local vendors who offer both a tax exempt and which you could use a schools purchase order for supplies We purchased all of our supplies from Lowersquos and Petsmart

We designed our aquaponics system to incorporate 3 height levels in cascade Level 1 tank was raised 25rsquo above the ground and set on a sturdy table We used a 30

gallon storage tank to house 6 goldfish and 6 gambusia a bulkhead inserted through one side of tank served as the tanks overflow drain a second bulkhead with a control valve allowed for water to fill level 2 which housed plants a bubbler was added and a hose was clamped which came from level 1 pump The tanks lid was modified for placement of our controls along with the sensor cluster and they were braced using a combination of zip ties bonding solutions and Velcro

6

Figure 1- Left hose coming from sump Center control valve and grow lights Right Otter box housing sensor cluster pH dispenser (in blue) food dispenser (inserted in 4 X 4)

Level 2 was raised 13rdquo off the ground and positioned on top of 3 12rsquo wide plywood which sat on two 10 gallon aquariums boxes (boxes were used because of accessibility) In total we grew 3 tomato and 3 cucumber plants while utilizing an ebb and flow system which allows for plant roots to get both water and free O2 at variable times The Ebb and Flow is a form of hydroponics that is known for its simplicity reliability of operation and low initial investment cost Pots are filled with an inert medium which does not function like soil or contribute nutrition to the plants but which anchors the roots and functions as a temporary reserve of water and solvent mineral nutrients The hydroponic solution alternately floods the system and is allowed to ebb away (wikipedia)

Figure 2- Tomatoes on the right and cucumbers on the left

Level 3 was reserved as our drainersump and included a small pump with a 4rsquo uphill power Both level 1 amp 2 drained down to 3rd level We grew 3 water lilies in a hydroponic condition

7

Figure 3- Water lilies inserted through the more buoyant Styrofoam

Figure 4- Overflow control valve in sump along with 4rsquo power motor

8

Figure 5- Fully assembled aquaponics system

Methods We collected daily measurements for pH temperature and dissolved oxygen of our aquaponics system We used the PASCO Spark probe to test these parameters as well as a commercially sold water condition kit which we needed to take physical water samples from our tank The kit also included tests for nitrite nitrate and ammonia levels These data were added to a spreadsheet and shared amongst the team We began comparing data between PASCO and sensor cluster in the clusterrsquos infancy stage (around week 2 of our training) and found little error testing for only 5 minutes between the two readings Several discrepancies were seen when cluster read for more than 5 minutes so Vardhman refined the circuit design By week 5 the cluster gave less than a 2 error for more than an hour of data collection for pH temperature and dissolved oxygen The intended goal for this project required a dayrsquos worth of data collection to allow us to determine the reliability of our cluster We also intended to collect data remotely so Vardhman created a database in which he can access it from his laptop We could then correct any major problems within our system if controllers failed plus this data can be graphed allowing us to see trends in environmental conditions A major part to our aquaponic system is the implementation of several controls to neutralize any environmental conditions that might spiral out of control We utilized a plastic dispenser for pH with an accompanying pH neutralizer with the sensor cluster taking constant readings it will allow for a specific amount of pH to be dispensed into the fish tank The control uses a closed loop system allowing for the sensor cluster to once again monitor water conditions before determining which steps to take A second control was the food dispenser (Figure 7) Like our pH dispenser this control is integrated into the sensor cluster A motor was

9

attached to a small fluid collecting bottle which was used to house fish pellets and was inserted into a 12rsquo 4rdquo X 4rdquo The bottle would rotate 360 degrees 4 times a day Our third control included a 50 gallon storage container (acting as a reservoir) which we filled with water which will dispense water into fish tank when sonar sensors located under tank lid sensed a frac12rdquo drop in water Finally in order to maintain the proper dissolved oxygen levels a bubbler was added to fish tank both the reservoir and bubbler used a turn onoff power control Once cluster and controls were built and tested for accuracy we added disturbances to our tank these included fluctuating pH DO and water level conditions We made sure not to vary pH drastically as this would shock and possibly kill our fish Instead only a +- 6 change in pH was needed to activate control Observations were made and recorded onto our blog

Results Data was collected at two different time period once at 24hrs and another at 48hrs Both sets of data showed our sensor cluster working as programmed Graphs created show no major disturbance indicating no further breakdown of cluster (Figure 8 and Figure 9 in Appendix) Figure 6 was collected from a set of points of Figure 9 and an algorithm was developed to allow for a much smoother line graph Figure 6 shows temperature constant at 23C pH levels 72 and DO levels at 78 Similarly Figure 8 maintains temperature and DO levels through the tested time period but pH drops several decimal points but not significantly to propose a sensor cluster problem Figure 9 shows data without the algorithm Figure 10 to Figure 17 show our last set of data with individual readings for pH DO and temperature (Appendix) There is no evidence in graphs of fluctuation in sensors Figure 18 and Figure 19 show data for testing of our controls (Appendix)

Figure 6 Results showing temperature at 23C pH levels 72 and DO levels at 78

Discussion Our initial data collection comparing sensor cluster to PASCO gave us pretty good readings for the first 5 minutes of testing Dissolved oxygen pH and temperature probes of cluster gave less than a 3 error when compare to PASCO (Figure 6) The problem arose when left for more than

10

5 minutes and also having the DO and pH probes in the tank at the same time When each of these probes are taking live readings there is a voltage interference that then translates to a digital error reading The errors were significant more than a point off These problems required for Vardhman to isolate dissolved oxygen from pH using a 6N137 single-channel and utilizing a dual-channel HCPL2630 This change also isolated ground for each of the probes (Figure 9 Figure 10 and Figure 11)

Once our sensor cluster was finalized we collected 24hr data of our fish tanks conditions (Figure 7) The accompanying Figure 8 graph was produced using MATLAB The data did not report any errors although we determined that there were too many data points to be graphed so Vardhman decided that on future trials to develop an algorithm which would eliminate these points Also there are multiple 0 point values with pH reading but this is expected due to the sensitivity of these probes This hiccup is not enough to alter graph readings We made a second attempt at collecting data but this time leaving the sensor cluster activated for nearly 48hrs Once again we had reliable data (Figure 15 and Figure 16) There are no major points within graph where it becomes inactive We wanted to show a comparison between a graph with a developed algorithm and one without this function Figure 15 Figure 16 Figure 19 and Figure 20 show this comparison Figure 17 and Figure 21 show a partial collection of data

The difficulty in simulating each control is that there are many factors that come into play- most importantly time We needed to manipulate the environmental conditions in a lab that would otherwise be found in nature Also because we are working with parts that require a power source the use of multiple outlets and power strips made our testing area fairly tight and problematic Finally we are working with electrical components that we all know do not mix well with water so it took time when stationing for demonstration Our final circuit system unfortunately was not soldered together so we needed to connect the appropriate wires for each control--again taking time

We tested our controls by manipulating each in an isolated volume of water After adding a disturbance for pH there is no immediate control input instead there is a 2 min delay but we do continue to gather data into our database (Figure 22) The actuator only dispenses after the average results are collected This average if you recall are 10 data points or collections at 8 seconds apart So a total of 80 sec passes before there is some action from actuator Vardhman programmed the system this way to allow the added control (fluid etc) to diffuse through water before taking the appropriate next steps The disturbance in this experimental trial was added at 20 sec (pH right above 7) levels dropped to just under 7 (fluctuating a little) and after 2 minutes a volume of pH corrector was added system continued to collect data averaging points One factor different to this graph compared to all others is that Vardhmans algorithm allows for a much smoother sloped line and removes every data point collected every 8 sec that would otherwise show sharp and steep lines The graph also shows where control is turned off and levels rise back to normal The reestablished conditions of our sampled water is a reliable control system Similar to pH we used an isolated volume of water to test tank refill We used Velcro to constrain two sonars and pumped water from a reservoir We started our data collection with water height of 19 cm pump turned on for a total time of nearly two minute until the desired depth of 14 cm pump then turned off (Figure 23) You can see video of each control simulation under the appendix of this report

Conclusion In conclusion after testing sensor cluster at two time intervals 24hr and 48hr we are confident in its reliability and accuracy Data and graphs provided do not suggest speculation of its

11

dependability the clusters parts and software are also trustworthy as they are mass produced and there are a number of professions who utilize its capacity to operate and maintain high end expensive machines Each control was tested under a simulated field environment and each performed as expected Preparation leading to tests remains a hurdle as there are many components that play intricate roles in each controls operations The use of water around electrical components also limits portability but with given time positioning for simulation can be obtained The aquaponic system itself played a small role in each controls simulation as this project is itrsquos first of its kind so experimenting in controlled environments allowed for minimal fish and plant casualties Given the preparation and collaboration in finalizing this study future aquaponic control systems can be fully implemented with the desired expected results which include autonomy fish culture and plant ecology

Recommendations It is recommended when combining a traditional aquaponic system with automated control systems for there to be collaborators at either a university or professional level The design and creation of sensor clusters using arduino as a microprossesor and an Xbee shield will more than likely be beyond the average citizenrsquos knowledge Beginning with an indoor small scale prototype will most likely save you money and time plus implementation of control system will be more accessible to troubleshoot Research knowledge of running and maintaining an aquaponic system and learning how controls work is important for a successful integrated system

Acknowledgements RET (Research Experiences for Teachers) Site on Sensor Networks Electrical Engineering Department and Institute of Applied Sciences UNT Denton Texas This material is based upon work supported by the National Science Foundation (NSF) under Grant No 1132585 and the IEEE Control Systems Society (CSS) Outreach Fund Any opinions findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF or the IEEE We would like to thank UNTrsquos Electrical Engineering Department staff and graduate students for their support and expertise throughout the course of this project In particular Dr Yan Wan for her mentoring and workshops over system controls Vardhman Sheth for working with us on designing creating and executing our sensor cluster and individual controls Dr Thompson and Dr Acevedo for initiating this training and requiring the very best from each of the participating teachers We would also like to acknowledge all participating teachers for their encouragement and enthusiasm throughout the entire training

References Antsaklis P Passino K An Introduction to Autonomous Control Systems IEEE Control

Systems 1991 httpwww2eceohio-stateedu~passinoPapersToPostIntro-Aut-Controlpdf

Arduino - HomePage Np nd Web 17 July 2012 lthttpwwwarduinoccgt Atlas-Scientific Home Np nd Web 17 July 2012 lthttpatlas-scientificcomgt Diver S AQUAPONICS - INTEGRATION OF HYDROPONICS WITH AQUACULTURE httpwwwacesedudeptfisherieseducationdocumentsHorticulturesystemsguidepdf Graber A Junge R ldquo Aquaponic Systems Nutrient recycling from fish wastewater by vegetable

productionrdquo Desalination 246147-156 012009 DOI 101016jdesal200803048

12

Losordo T Recirculating Aquaculture Tank Production Systems SRAC Publication No 4531992 httpuniversityuogeducalspeoplepubsaquac453recpdf

Tamaru C Challenges and Opportunities for Aquaponics in the College of Tropical Agriculture and Human Resources 2011 httpwwwctahrhawaiiedusustainagnewsarticlesV6-Tamaru-aquaponicpdf

Villarroel M Aquaponics integrating fish feeding rates and ion waste production for strawberry hydroponics 2011 httprevistasiniaesindexphpsjararticleview1758

Wardlow G Enhancing Student Interest in the Agricultural Sciences through Aquaponics J Nat Resour Life Sci Educ Vol 31 2002 httpswwwagronomyorgfilesjnrlseissues2002e00-15kpdf

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

4

There is a natural symbiotic relationship between fish and plants in this type of system but one need not forget that these systems are manmade so monitoring performance is of importance Ion waste production by fish cannot satisfy all plant requirements and the relationship between total feed provided for fish and the production of milliequivalents (mEq) of different macronutrients for plants is less known (Villarroel J 2011)

The simplicity in constructing aquaponics systems makes it adaptable for the average citizen choosing to cultivate plants as a hobby or small profit or for corporations choosing to replace food product import costs for an on-siteon-demand ecosystem In the early 1990rsquos Tom and Paula Speraneo owners of a small greenhouse operation near West Plains Missouri raised basil which they sold for $12 a pound to gourmet restaurants four hours away in St Louis Missouri They developed an aquaponics system known now as The Speraneo System in which they raised tilapia using a unique blend of microbes in above-ground tanks inside a solar greenhouse (Diver S 2004)

Universities have also taken advantage of an aquaponics system using both the biotic and abiotic conditions to serve as real world models for students pursuing careers in the agricultural sciences The University of Hawaii is an aquaculture research and extension complex which in 2009 began in the College of Technical Agriculture and Human Resources (CTAHRrsquos) program to include aquaponics technologies for food production methods The program began to address and raise awareness as to what it would take for an island state to become self-reliant in producing its own food The program has created a working prototype which allows for researchers professional and educators a means to identify the various inputs (energy feed micronutrients) of a renewable system (Tamaru C 2011) Most aquaponics systems currently in place need physical monitoring and any corrective environmental measures within this system take time to correct

There are wide arrays of uses for control systems in industrial and commercial platform Autonomous control systems are designed to perform well under significant uncertainties in the system and environment for extended periods of time and they must be able to compensate for significant system failures without external intervention (Antsaklis P 1991)

Interesting enough there are constraints with using these systems on long-term remote autonomous high-resolution monitoring in the real environment These limitations exist even with all the technological and commercial advances Constraints include limited availability of energy precise autonomous actuation and highly accurate localization With this in mind there has always been a need to address the problems that come with the sophistication and complexity in control Dynamic systems are complex and the demand for closed loop system requires sophisticated controllers Highly nonlinear systems normally require the use of more complex controllers than low order linear ones when goals beyond stability are to be met (Antsaklis P 1991)

As the global community searches for improved methods of sustainable living it becomes more apparent that there is a need for better monitoring and control of parameters that influence the well-being of aquatic and plant life In work done by Wang et al they describe the control of several of these parameters as the key to greater automation and efficiency They design and made wireless sensor networks for measuring temperature humidity carbon dioxide concentrations pH and other parameters Once measured the data was transferred and solved the problems encountered with wiring in a greenhouse

Our summer project incorporated WSN technology specifically Arduino which is an open-source electronics prototyping platform based on flexible easy-to use hardware The most

5

beneficial outcome to using Arduino was that software can be downloaded for free and CAD files are available under an open-source license Also there is a wide list of users incorporating it into art design and anyone interested in creating interactive objects or environments (Arduino 2012) To relay our data we used an XBee which can operate either in a transparent data mode or in a packet-based application programming interface (API) mode In the transparent mode data coming into the Data IN (DIN) pin is directly transmitted over-the-air to the intended receiving radios without any modification Incoming packets can either be directly addressed to one target (point-to-point) or broadcast to multiple targets (star) Along with Arduino and Xbee we utilized Atlas Scientific temperature pH and dissolved oxygen probes which are great for laboratory testing or long term field use Their Rugged Epoxy design makes them virtually unbreakable (Atlas- Scientific 2012)

Aquaponics Classroom Model The costs of building a classroom aquaponics depends on the scale and purpose you intend it to serve If on a tight budget building only one to serve as a classroom demonstration with student participation might suit your needs If your intention is to have them come up with their own design constraints and budget analysis then determining how students will fundraise for their parts is something you need to consider ahead of time Although you could give them the task of coming up with a list of fundraising ideas and provide you with an attached spreadsheet showing an analysis of fundraising supplies and expenses You want to ensure that both students and teacher have a realistic view of how much this will cost and where costs can be cut There are numerous designs available online some which utilize household supplies others that are more extensive and of greater scale In each case students should have researched extensively to cross out any designs that do not fit with the constraints of the classroom or which require a budget beyond their mean The following information describes our summer trainings project expectations for building a cost efficient aquaponics system and maintenance involved in making sure plants and fish receive their daily nutrients While making a list of supplies you should contact your schools purchasing department to ensure that there are local vendors who offer both a tax exempt and which you could use a schools purchase order for supplies We purchased all of our supplies from Lowersquos and Petsmart

We designed our aquaponics system to incorporate 3 height levels in cascade Level 1 tank was raised 25rsquo above the ground and set on a sturdy table We used a 30

gallon storage tank to house 6 goldfish and 6 gambusia a bulkhead inserted through one side of tank served as the tanks overflow drain a second bulkhead with a control valve allowed for water to fill level 2 which housed plants a bubbler was added and a hose was clamped which came from level 1 pump The tanks lid was modified for placement of our controls along with the sensor cluster and they were braced using a combination of zip ties bonding solutions and Velcro

6

Figure 1- Left hose coming from sump Center control valve and grow lights Right Otter box housing sensor cluster pH dispenser (in blue) food dispenser (inserted in 4 X 4)

Level 2 was raised 13rdquo off the ground and positioned on top of 3 12rsquo wide plywood which sat on two 10 gallon aquariums boxes (boxes were used because of accessibility) In total we grew 3 tomato and 3 cucumber plants while utilizing an ebb and flow system which allows for plant roots to get both water and free O2 at variable times The Ebb and Flow is a form of hydroponics that is known for its simplicity reliability of operation and low initial investment cost Pots are filled with an inert medium which does not function like soil or contribute nutrition to the plants but which anchors the roots and functions as a temporary reserve of water and solvent mineral nutrients The hydroponic solution alternately floods the system and is allowed to ebb away (wikipedia)

Figure 2- Tomatoes on the right and cucumbers on the left

Level 3 was reserved as our drainersump and included a small pump with a 4rsquo uphill power Both level 1 amp 2 drained down to 3rd level We grew 3 water lilies in a hydroponic condition

7

Figure 3- Water lilies inserted through the more buoyant Styrofoam

Figure 4- Overflow control valve in sump along with 4rsquo power motor

8

Figure 5- Fully assembled aquaponics system

Methods We collected daily measurements for pH temperature and dissolved oxygen of our aquaponics system We used the PASCO Spark probe to test these parameters as well as a commercially sold water condition kit which we needed to take physical water samples from our tank The kit also included tests for nitrite nitrate and ammonia levels These data were added to a spreadsheet and shared amongst the team We began comparing data between PASCO and sensor cluster in the clusterrsquos infancy stage (around week 2 of our training) and found little error testing for only 5 minutes between the two readings Several discrepancies were seen when cluster read for more than 5 minutes so Vardhman refined the circuit design By week 5 the cluster gave less than a 2 error for more than an hour of data collection for pH temperature and dissolved oxygen The intended goal for this project required a dayrsquos worth of data collection to allow us to determine the reliability of our cluster We also intended to collect data remotely so Vardhman created a database in which he can access it from his laptop We could then correct any major problems within our system if controllers failed plus this data can be graphed allowing us to see trends in environmental conditions A major part to our aquaponic system is the implementation of several controls to neutralize any environmental conditions that might spiral out of control We utilized a plastic dispenser for pH with an accompanying pH neutralizer with the sensor cluster taking constant readings it will allow for a specific amount of pH to be dispensed into the fish tank The control uses a closed loop system allowing for the sensor cluster to once again monitor water conditions before determining which steps to take A second control was the food dispenser (Figure 7) Like our pH dispenser this control is integrated into the sensor cluster A motor was

9

attached to a small fluid collecting bottle which was used to house fish pellets and was inserted into a 12rsquo 4rdquo X 4rdquo The bottle would rotate 360 degrees 4 times a day Our third control included a 50 gallon storage container (acting as a reservoir) which we filled with water which will dispense water into fish tank when sonar sensors located under tank lid sensed a frac12rdquo drop in water Finally in order to maintain the proper dissolved oxygen levels a bubbler was added to fish tank both the reservoir and bubbler used a turn onoff power control Once cluster and controls were built and tested for accuracy we added disturbances to our tank these included fluctuating pH DO and water level conditions We made sure not to vary pH drastically as this would shock and possibly kill our fish Instead only a +- 6 change in pH was needed to activate control Observations were made and recorded onto our blog

Results Data was collected at two different time period once at 24hrs and another at 48hrs Both sets of data showed our sensor cluster working as programmed Graphs created show no major disturbance indicating no further breakdown of cluster (Figure 8 and Figure 9 in Appendix) Figure 6 was collected from a set of points of Figure 9 and an algorithm was developed to allow for a much smoother line graph Figure 6 shows temperature constant at 23C pH levels 72 and DO levels at 78 Similarly Figure 8 maintains temperature and DO levels through the tested time period but pH drops several decimal points but not significantly to propose a sensor cluster problem Figure 9 shows data without the algorithm Figure 10 to Figure 17 show our last set of data with individual readings for pH DO and temperature (Appendix) There is no evidence in graphs of fluctuation in sensors Figure 18 and Figure 19 show data for testing of our controls (Appendix)

Figure 6 Results showing temperature at 23C pH levels 72 and DO levels at 78

Discussion Our initial data collection comparing sensor cluster to PASCO gave us pretty good readings for the first 5 minutes of testing Dissolved oxygen pH and temperature probes of cluster gave less than a 3 error when compare to PASCO (Figure 6) The problem arose when left for more than

10

5 minutes and also having the DO and pH probes in the tank at the same time When each of these probes are taking live readings there is a voltage interference that then translates to a digital error reading The errors were significant more than a point off These problems required for Vardhman to isolate dissolved oxygen from pH using a 6N137 single-channel and utilizing a dual-channel HCPL2630 This change also isolated ground for each of the probes (Figure 9 Figure 10 and Figure 11)

Once our sensor cluster was finalized we collected 24hr data of our fish tanks conditions (Figure 7) The accompanying Figure 8 graph was produced using MATLAB The data did not report any errors although we determined that there were too many data points to be graphed so Vardhman decided that on future trials to develop an algorithm which would eliminate these points Also there are multiple 0 point values with pH reading but this is expected due to the sensitivity of these probes This hiccup is not enough to alter graph readings We made a second attempt at collecting data but this time leaving the sensor cluster activated for nearly 48hrs Once again we had reliable data (Figure 15 and Figure 16) There are no major points within graph where it becomes inactive We wanted to show a comparison between a graph with a developed algorithm and one without this function Figure 15 Figure 16 Figure 19 and Figure 20 show this comparison Figure 17 and Figure 21 show a partial collection of data

The difficulty in simulating each control is that there are many factors that come into play- most importantly time We needed to manipulate the environmental conditions in a lab that would otherwise be found in nature Also because we are working with parts that require a power source the use of multiple outlets and power strips made our testing area fairly tight and problematic Finally we are working with electrical components that we all know do not mix well with water so it took time when stationing for demonstration Our final circuit system unfortunately was not soldered together so we needed to connect the appropriate wires for each control--again taking time

We tested our controls by manipulating each in an isolated volume of water After adding a disturbance for pH there is no immediate control input instead there is a 2 min delay but we do continue to gather data into our database (Figure 22) The actuator only dispenses after the average results are collected This average if you recall are 10 data points or collections at 8 seconds apart So a total of 80 sec passes before there is some action from actuator Vardhman programmed the system this way to allow the added control (fluid etc) to diffuse through water before taking the appropriate next steps The disturbance in this experimental trial was added at 20 sec (pH right above 7) levels dropped to just under 7 (fluctuating a little) and after 2 minutes a volume of pH corrector was added system continued to collect data averaging points One factor different to this graph compared to all others is that Vardhmans algorithm allows for a much smoother sloped line and removes every data point collected every 8 sec that would otherwise show sharp and steep lines The graph also shows where control is turned off and levels rise back to normal The reestablished conditions of our sampled water is a reliable control system Similar to pH we used an isolated volume of water to test tank refill We used Velcro to constrain two sonars and pumped water from a reservoir We started our data collection with water height of 19 cm pump turned on for a total time of nearly two minute until the desired depth of 14 cm pump then turned off (Figure 23) You can see video of each control simulation under the appendix of this report

Conclusion In conclusion after testing sensor cluster at two time intervals 24hr and 48hr we are confident in its reliability and accuracy Data and graphs provided do not suggest speculation of its

11

dependability the clusters parts and software are also trustworthy as they are mass produced and there are a number of professions who utilize its capacity to operate and maintain high end expensive machines Each control was tested under a simulated field environment and each performed as expected Preparation leading to tests remains a hurdle as there are many components that play intricate roles in each controls operations The use of water around electrical components also limits portability but with given time positioning for simulation can be obtained The aquaponic system itself played a small role in each controls simulation as this project is itrsquos first of its kind so experimenting in controlled environments allowed for minimal fish and plant casualties Given the preparation and collaboration in finalizing this study future aquaponic control systems can be fully implemented with the desired expected results which include autonomy fish culture and plant ecology

Recommendations It is recommended when combining a traditional aquaponic system with automated control systems for there to be collaborators at either a university or professional level The design and creation of sensor clusters using arduino as a microprossesor and an Xbee shield will more than likely be beyond the average citizenrsquos knowledge Beginning with an indoor small scale prototype will most likely save you money and time plus implementation of control system will be more accessible to troubleshoot Research knowledge of running and maintaining an aquaponic system and learning how controls work is important for a successful integrated system

Acknowledgements RET (Research Experiences for Teachers) Site on Sensor Networks Electrical Engineering Department and Institute of Applied Sciences UNT Denton Texas This material is based upon work supported by the National Science Foundation (NSF) under Grant No 1132585 and the IEEE Control Systems Society (CSS) Outreach Fund Any opinions findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF or the IEEE We would like to thank UNTrsquos Electrical Engineering Department staff and graduate students for their support and expertise throughout the course of this project In particular Dr Yan Wan for her mentoring and workshops over system controls Vardhman Sheth for working with us on designing creating and executing our sensor cluster and individual controls Dr Thompson and Dr Acevedo for initiating this training and requiring the very best from each of the participating teachers We would also like to acknowledge all participating teachers for their encouragement and enthusiasm throughout the entire training

References Antsaklis P Passino K An Introduction to Autonomous Control Systems IEEE Control

Systems 1991 httpwww2eceohio-stateedu~passinoPapersToPostIntro-Aut-Controlpdf

Arduino - HomePage Np nd Web 17 July 2012 lthttpwwwarduinoccgt Atlas-Scientific Home Np nd Web 17 July 2012 lthttpatlas-scientificcomgt Diver S AQUAPONICS - INTEGRATION OF HYDROPONICS WITH AQUACULTURE httpwwwacesedudeptfisherieseducationdocumentsHorticulturesystemsguidepdf Graber A Junge R ldquo Aquaponic Systems Nutrient recycling from fish wastewater by vegetable

productionrdquo Desalination 246147-156 012009 DOI 101016jdesal200803048

12

Losordo T Recirculating Aquaculture Tank Production Systems SRAC Publication No 4531992 httpuniversityuogeducalspeoplepubsaquac453recpdf

Tamaru C Challenges and Opportunities for Aquaponics in the College of Tropical Agriculture and Human Resources 2011 httpwwwctahrhawaiiedusustainagnewsarticlesV6-Tamaru-aquaponicpdf

Villarroel M Aquaponics integrating fish feeding rates and ion waste production for strawberry hydroponics 2011 httprevistasiniaesindexphpsjararticleview1758

Wardlow G Enhancing Student Interest in the Agricultural Sciences through Aquaponics J Nat Resour Life Sci Educ Vol 31 2002 httpswwwagronomyorgfilesjnrlseissues2002e00-15kpdf

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

5

beneficial outcome to using Arduino was that software can be downloaded for free and CAD files are available under an open-source license Also there is a wide list of users incorporating it into art design and anyone interested in creating interactive objects or environments (Arduino 2012) To relay our data we used an XBee which can operate either in a transparent data mode or in a packet-based application programming interface (API) mode In the transparent mode data coming into the Data IN (DIN) pin is directly transmitted over-the-air to the intended receiving radios without any modification Incoming packets can either be directly addressed to one target (point-to-point) or broadcast to multiple targets (star) Along with Arduino and Xbee we utilized Atlas Scientific temperature pH and dissolved oxygen probes which are great for laboratory testing or long term field use Their Rugged Epoxy design makes them virtually unbreakable (Atlas- Scientific 2012)

Aquaponics Classroom Model The costs of building a classroom aquaponics depends on the scale and purpose you intend it to serve If on a tight budget building only one to serve as a classroom demonstration with student participation might suit your needs If your intention is to have them come up with their own design constraints and budget analysis then determining how students will fundraise for their parts is something you need to consider ahead of time Although you could give them the task of coming up with a list of fundraising ideas and provide you with an attached spreadsheet showing an analysis of fundraising supplies and expenses You want to ensure that both students and teacher have a realistic view of how much this will cost and where costs can be cut There are numerous designs available online some which utilize household supplies others that are more extensive and of greater scale In each case students should have researched extensively to cross out any designs that do not fit with the constraints of the classroom or which require a budget beyond their mean The following information describes our summer trainings project expectations for building a cost efficient aquaponics system and maintenance involved in making sure plants and fish receive their daily nutrients While making a list of supplies you should contact your schools purchasing department to ensure that there are local vendors who offer both a tax exempt and which you could use a schools purchase order for supplies We purchased all of our supplies from Lowersquos and Petsmart

We designed our aquaponics system to incorporate 3 height levels in cascade Level 1 tank was raised 25rsquo above the ground and set on a sturdy table We used a 30

gallon storage tank to house 6 goldfish and 6 gambusia a bulkhead inserted through one side of tank served as the tanks overflow drain a second bulkhead with a control valve allowed for water to fill level 2 which housed plants a bubbler was added and a hose was clamped which came from level 1 pump The tanks lid was modified for placement of our controls along with the sensor cluster and they were braced using a combination of zip ties bonding solutions and Velcro

6

Figure 1- Left hose coming from sump Center control valve and grow lights Right Otter box housing sensor cluster pH dispenser (in blue) food dispenser (inserted in 4 X 4)

Level 2 was raised 13rdquo off the ground and positioned on top of 3 12rsquo wide plywood which sat on two 10 gallon aquariums boxes (boxes were used because of accessibility) In total we grew 3 tomato and 3 cucumber plants while utilizing an ebb and flow system which allows for plant roots to get both water and free O2 at variable times The Ebb and Flow is a form of hydroponics that is known for its simplicity reliability of operation and low initial investment cost Pots are filled with an inert medium which does not function like soil or contribute nutrition to the plants but which anchors the roots and functions as a temporary reserve of water and solvent mineral nutrients The hydroponic solution alternately floods the system and is allowed to ebb away (wikipedia)

Figure 2- Tomatoes on the right and cucumbers on the left

Level 3 was reserved as our drainersump and included a small pump with a 4rsquo uphill power Both level 1 amp 2 drained down to 3rd level We grew 3 water lilies in a hydroponic condition

7

Figure 3- Water lilies inserted through the more buoyant Styrofoam

Figure 4- Overflow control valve in sump along with 4rsquo power motor

8

Figure 5- Fully assembled aquaponics system

Methods We collected daily measurements for pH temperature and dissolved oxygen of our aquaponics system We used the PASCO Spark probe to test these parameters as well as a commercially sold water condition kit which we needed to take physical water samples from our tank The kit also included tests for nitrite nitrate and ammonia levels These data were added to a spreadsheet and shared amongst the team We began comparing data between PASCO and sensor cluster in the clusterrsquos infancy stage (around week 2 of our training) and found little error testing for only 5 minutes between the two readings Several discrepancies were seen when cluster read for more than 5 minutes so Vardhman refined the circuit design By week 5 the cluster gave less than a 2 error for more than an hour of data collection for pH temperature and dissolved oxygen The intended goal for this project required a dayrsquos worth of data collection to allow us to determine the reliability of our cluster We also intended to collect data remotely so Vardhman created a database in which he can access it from his laptop We could then correct any major problems within our system if controllers failed plus this data can be graphed allowing us to see trends in environmental conditions A major part to our aquaponic system is the implementation of several controls to neutralize any environmental conditions that might spiral out of control We utilized a plastic dispenser for pH with an accompanying pH neutralizer with the sensor cluster taking constant readings it will allow for a specific amount of pH to be dispensed into the fish tank The control uses a closed loop system allowing for the sensor cluster to once again monitor water conditions before determining which steps to take A second control was the food dispenser (Figure 7) Like our pH dispenser this control is integrated into the sensor cluster A motor was

9

attached to a small fluid collecting bottle which was used to house fish pellets and was inserted into a 12rsquo 4rdquo X 4rdquo The bottle would rotate 360 degrees 4 times a day Our third control included a 50 gallon storage container (acting as a reservoir) which we filled with water which will dispense water into fish tank when sonar sensors located under tank lid sensed a frac12rdquo drop in water Finally in order to maintain the proper dissolved oxygen levels a bubbler was added to fish tank both the reservoir and bubbler used a turn onoff power control Once cluster and controls were built and tested for accuracy we added disturbances to our tank these included fluctuating pH DO and water level conditions We made sure not to vary pH drastically as this would shock and possibly kill our fish Instead only a +- 6 change in pH was needed to activate control Observations were made and recorded onto our blog

Results Data was collected at two different time period once at 24hrs and another at 48hrs Both sets of data showed our sensor cluster working as programmed Graphs created show no major disturbance indicating no further breakdown of cluster (Figure 8 and Figure 9 in Appendix) Figure 6 was collected from a set of points of Figure 9 and an algorithm was developed to allow for a much smoother line graph Figure 6 shows temperature constant at 23C pH levels 72 and DO levels at 78 Similarly Figure 8 maintains temperature and DO levels through the tested time period but pH drops several decimal points but not significantly to propose a sensor cluster problem Figure 9 shows data without the algorithm Figure 10 to Figure 17 show our last set of data with individual readings for pH DO and temperature (Appendix) There is no evidence in graphs of fluctuation in sensors Figure 18 and Figure 19 show data for testing of our controls (Appendix)

Figure 6 Results showing temperature at 23C pH levels 72 and DO levels at 78

Discussion Our initial data collection comparing sensor cluster to PASCO gave us pretty good readings for the first 5 minutes of testing Dissolved oxygen pH and temperature probes of cluster gave less than a 3 error when compare to PASCO (Figure 6) The problem arose when left for more than

10

5 minutes and also having the DO and pH probes in the tank at the same time When each of these probes are taking live readings there is a voltage interference that then translates to a digital error reading The errors were significant more than a point off These problems required for Vardhman to isolate dissolved oxygen from pH using a 6N137 single-channel and utilizing a dual-channel HCPL2630 This change also isolated ground for each of the probes (Figure 9 Figure 10 and Figure 11)

Once our sensor cluster was finalized we collected 24hr data of our fish tanks conditions (Figure 7) The accompanying Figure 8 graph was produced using MATLAB The data did not report any errors although we determined that there were too many data points to be graphed so Vardhman decided that on future trials to develop an algorithm which would eliminate these points Also there are multiple 0 point values with pH reading but this is expected due to the sensitivity of these probes This hiccup is not enough to alter graph readings We made a second attempt at collecting data but this time leaving the sensor cluster activated for nearly 48hrs Once again we had reliable data (Figure 15 and Figure 16) There are no major points within graph where it becomes inactive We wanted to show a comparison between a graph with a developed algorithm and one without this function Figure 15 Figure 16 Figure 19 and Figure 20 show this comparison Figure 17 and Figure 21 show a partial collection of data

The difficulty in simulating each control is that there are many factors that come into play- most importantly time We needed to manipulate the environmental conditions in a lab that would otherwise be found in nature Also because we are working with parts that require a power source the use of multiple outlets and power strips made our testing area fairly tight and problematic Finally we are working with electrical components that we all know do not mix well with water so it took time when stationing for demonstration Our final circuit system unfortunately was not soldered together so we needed to connect the appropriate wires for each control--again taking time

We tested our controls by manipulating each in an isolated volume of water After adding a disturbance for pH there is no immediate control input instead there is a 2 min delay but we do continue to gather data into our database (Figure 22) The actuator only dispenses after the average results are collected This average if you recall are 10 data points or collections at 8 seconds apart So a total of 80 sec passes before there is some action from actuator Vardhman programmed the system this way to allow the added control (fluid etc) to diffuse through water before taking the appropriate next steps The disturbance in this experimental trial was added at 20 sec (pH right above 7) levels dropped to just under 7 (fluctuating a little) and after 2 minutes a volume of pH corrector was added system continued to collect data averaging points One factor different to this graph compared to all others is that Vardhmans algorithm allows for a much smoother sloped line and removes every data point collected every 8 sec that would otherwise show sharp and steep lines The graph also shows where control is turned off and levels rise back to normal The reestablished conditions of our sampled water is a reliable control system Similar to pH we used an isolated volume of water to test tank refill We used Velcro to constrain two sonars and pumped water from a reservoir We started our data collection with water height of 19 cm pump turned on for a total time of nearly two minute until the desired depth of 14 cm pump then turned off (Figure 23) You can see video of each control simulation under the appendix of this report

Conclusion In conclusion after testing sensor cluster at two time intervals 24hr and 48hr we are confident in its reliability and accuracy Data and graphs provided do not suggest speculation of its

11

dependability the clusters parts and software are also trustworthy as they are mass produced and there are a number of professions who utilize its capacity to operate and maintain high end expensive machines Each control was tested under a simulated field environment and each performed as expected Preparation leading to tests remains a hurdle as there are many components that play intricate roles in each controls operations The use of water around electrical components also limits portability but with given time positioning for simulation can be obtained The aquaponic system itself played a small role in each controls simulation as this project is itrsquos first of its kind so experimenting in controlled environments allowed for minimal fish and plant casualties Given the preparation and collaboration in finalizing this study future aquaponic control systems can be fully implemented with the desired expected results which include autonomy fish culture and plant ecology

Recommendations It is recommended when combining a traditional aquaponic system with automated control systems for there to be collaborators at either a university or professional level The design and creation of sensor clusters using arduino as a microprossesor and an Xbee shield will more than likely be beyond the average citizenrsquos knowledge Beginning with an indoor small scale prototype will most likely save you money and time plus implementation of control system will be more accessible to troubleshoot Research knowledge of running and maintaining an aquaponic system and learning how controls work is important for a successful integrated system

Acknowledgements RET (Research Experiences for Teachers) Site on Sensor Networks Electrical Engineering Department and Institute of Applied Sciences UNT Denton Texas This material is based upon work supported by the National Science Foundation (NSF) under Grant No 1132585 and the IEEE Control Systems Society (CSS) Outreach Fund Any opinions findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF or the IEEE We would like to thank UNTrsquos Electrical Engineering Department staff and graduate students for their support and expertise throughout the course of this project In particular Dr Yan Wan for her mentoring and workshops over system controls Vardhman Sheth for working with us on designing creating and executing our sensor cluster and individual controls Dr Thompson and Dr Acevedo for initiating this training and requiring the very best from each of the participating teachers We would also like to acknowledge all participating teachers for their encouragement and enthusiasm throughout the entire training

References Antsaklis P Passino K An Introduction to Autonomous Control Systems IEEE Control

Systems 1991 httpwww2eceohio-stateedu~passinoPapersToPostIntro-Aut-Controlpdf

Arduino - HomePage Np nd Web 17 July 2012 lthttpwwwarduinoccgt Atlas-Scientific Home Np nd Web 17 July 2012 lthttpatlas-scientificcomgt Diver S AQUAPONICS - INTEGRATION OF HYDROPONICS WITH AQUACULTURE httpwwwacesedudeptfisherieseducationdocumentsHorticulturesystemsguidepdf Graber A Junge R ldquo Aquaponic Systems Nutrient recycling from fish wastewater by vegetable

productionrdquo Desalination 246147-156 012009 DOI 101016jdesal200803048

12

Losordo T Recirculating Aquaculture Tank Production Systems SRAC Publication No 4531992 httpuniversityuogeducalspeoplepubsaquac453recpdf

Tamaru C Challenges and Opportunities for Aquaponics in the College of Tropical Agriculture and Human Resources 2011 httpwwwctahrhawaiiedusustainagnewsarticlesV6-Tamaru-aquaponicpdf

Villarroel M Aquaponics integrating fish feeding rates and ion waste production for strawberry hydroponics 2011 httprevistasiniaesindexphpsjararticleview1758

Wardlow G Enhancing Student Interest in the Agricultural Sciences through Aquaponics J Nat Resour Life Sci Educ Vol 31 2002 httpswwwagronomyorgfilesjnrlseissues2002e00-15kpdf

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

6

Figure 1- Left hose coming from sump Center control valve and grow lights Right Otter box housing sensor cluster pH dispenser (in blue) food dispenser (inserted in 4 X 4)

Level 2 was raised 13rdquo off the ground and positioned on top of 3 12rsquo wide plywood which sat on two 10 gallon aquariums boxes (boxes were used because of accessibility) In total we grew 3 tomato and 3 cucumber plants while utilizing an ebb and flow system which allows for plant roots to get both water and free O2 at variable times The Ebb and Flow is a form of hydroponics that is known for its simplicity reliability of operation and low initial investment cost Pots are filled with an inert medium which does not function like soil or contribute nutrition to the plants but which anchors the roots and functions as a temporary reserve of water and solvent mineral nutrients The hydroponic solution alternately floods the system and is allowed to ebb away (wikipedia)

Figure 2- Tomatoes on the right and cucumbers on the left

Level 3 was reserved as our drainersump and included a small pump with a 4rsquo uphill power Both level 1 amp 2 drained down to 3rd level We grew 3 water lilies in a hydroponic condition

7

Figure 3- Water lilies inserted through the more buoyant Styrofoam

Figure 4- Overflow control valve in sump along with 4rsquo power motor

8

Figure 5- Fully assembled aquaponics system

Methods We collected daily measurements for pH temperature and dissolved oxygen of our aquaponics system We used the PASCO Spark probe to test these parameters as well as a commercially sold water condition kit which we needed to take physical water samples from our tank The kit also included tests for nitrite nitrate and ammonia levels These data were added to a spreadsheet and shared amongst the team We began comparing data between PASCO and sensor cluster in the clusterrsquos infancy stage (around week 2 of our training) and found little error testing for only 5 minutes between the two readings Several discrepancies were seen when cluster read for more than 5 minutes so Vardhman refined the circuit design By week 5 the cluster gave less than a 2 error for more than an hour of data collection for pH temperature and dissolved oxygen The intended goal for this project required a dayrsquos worth of data collection to allow us to determine the reliability of our cluster We also intended to collect data remotely so Vardhman created a database in which he can access it from his laptop We could then correct any major problems within our system if controllers failed plus this data can be graphed allowing us to see trends in environmental conditions A major part to our aquaponic system is the implementation of several controls to neutralize any environmental conditions that might spiral out of control We utilized a plastic dispenser for pH with an accompanying pH neutralizer with the sensor cluster taking constant readings it will allow for a specific amount of pH to be dispensed into the fish tank The control uses a closed loop system allowing for the sensor cluster to once again monitor water conditions before determining which steps to take A second control was the food dispenser (Figure 7) Like our pH dispenser this control is integrated into the sensor cluster A motor was

9

attached to a small fluid collecting bottle which was used to house fish pellets and was inserted into a 12rsquo 4rdquo X 4rdquo The bottle would rotate 360 degrees 4 times a day Our third control included a 50 gallon storage container (acting as a reservoir) which we filled with water which will dispense water into fish tank when sonar sensors located under tank lid sensed a frac12rdquo drop in water Finally in order to maintain the proper dissolved oxygen levels a bubbler was added to fish tank both the reservoir and bubbler used a turn onoff power control Once cluster and controls were built and tested for accuracy we added disturbances to our tank these included fluctuating pH DO and water level conditions We made sure not to vary pH drastically as this would shock and possibly kill our fish Instead only a +- 6 change in pH was needed to activate control Observations were made and recorded onto our blog

Results Data was collected at two different time period once at 24hrs and another at 48hrs Both sets of data showed our sensor cluster working as programmed Graphs created show no major disturbance indicating no further breakdown of cluster (Figure 8 and Figure 9 in Appendix) Figure 6 was collected from a set of points of Figure 9 and an algorithm was developed to allow for a much smoother line graph Figure 6 shows temperature constant at 23C pH levels 72 and DO levels at 78 Similarly Figure 8 maintains temperature and DO levels through the tested time period but pH drops several decimal points but not significantly to propose a sensor cluster problem Figure 9 shows data without the algorithm Figure 10 to Figure 17 show our last set of data with individual readings for pH DO and temperature (Appendix) There is no evidence in graphs of fluctuation in sensors Figure 18 and Figure 19 show data for testing of our controls (Appendix)

Figure 6 Results showing temperature at 23C pH levels 72 and DO levels at 78

Discussion Our initial data collection comparing sensor cluster to PASCO gave us pretty good readings for the first 5 minutes of testing Dissolved oxygen pH and temperature probes of cluster gave less than a 3 error when compare to PASCO (Figure 6) The problem arose when left for more than

10

5 minutes and also having the DO and pH probes in the tank at the same time When each of these probes are taking live readings there is a voltage interference that then translates to a digital error reading The errors were significant more than a point off These problems required for Vardhman to isolate dissolved oxygen from pH using a 6N137 single-channel and utilizing a dual-channel HCPL2630 This change also isolated ground for each of the probes (Figure 9 Figure 10 and Figure 11)

Once our sensor cluster was finalized we collected 24hr data of our fish tanks conditions (Figure 7) The accompanying Figure 8 graph was produced using MATLAB The data did not report any errors although we determined that there were too many data points to be graphed so Vardhman decided that on future trials to develop an algorithm which would eliminate these points Also there are multiple 0 point values with pH reading but this is expected due to the sensitivity of these probes This hiccup is not enough to alter graph readings We made a second attempt at collecting data but this time leaving the sensor cluster activated for nearly 48hrs Once again we had reliable data (Figure 15 and Figure 16) There are no major points within graph where it becomes inactive We wanted to show a comparison between a graph with a developed algorithm and one without this function Figure 15 Figure 16 Figure 19 and Figure 20 show this comparison Figure 17 and Figure 21 show a partial collection of data

The difficulty in simulating each control is that there are many factors that come into play- most importantly time We needed to manipulate the environmental conditions in a lab that would otherwise be found in nature Also because we are working with parts that require a power source the use of multiple outlets and power strips made our testing area fairly tight and problematic Finally we are working with electrical components that we all know do not mix well with water so it took time when stationing for demonstration Our final circuit system unfortunately was not soldered together so we needed to connect the appropriate wires for each control--again taking time

We tested our controls by manipulating each in an isolated volume of water After adding a disturbance for pH there is no immediate control input instead there is a 2 min delay but we do continue to gather data into our database (Figure 22) The actuator only dispenses after the average results are collected This average if you recall are 10 data points or collections at 8 seconds apart So a total of 80 sec passes before there is some action from actuator Vardhman programmed the system this way to allow the added control (fluid etc) to diffuse through water before taking the appropriate next steps The disturbance in this experimental trial was added at 20 sec (pH right above 7) levels dropped to just under 7 (fluctuating a little) and after 2 minutes a volume of pH corrector was added system continued to collect data averaging points One factor different to this graph compared to all others is that Vardhmans algorithm allows for a much smoother sloped line and removes every data point collected every 8 sec that would otherwise show sharp and steep lines The graph also shows where control is turned off and levels rise back to normal The reestablished conditions of our sampled water is a reliable control system Similar to pH we used an isolated volume of water to test tank refill We used Velcro to constrain two sonars and pumped water from a reservoir We started our data collection with water height of 19 cm pump turned on for a total time of nearly two minute until the desired depth of 14 cm pump then turned off (Figure 23) You can see video of each control simulation under the appendix of this report

Conclusion In conclusion after testing sensor cluster at two time intervals 24hr and 48hr we are confident in its reliability and accuracy Data and graphs provided do not suggest speculation of its

11

dependability the clusters parts and software are also trustworthy as they are mass produced and there are a number of professions who utilize its capacity to operate and maintain high end expensive machines Each control was tested under a simulated field environment and each performed as expected Preparation leading to tests remains a hurdle as there are many components that play intricate roles in each controls operations The use of water around electrical components also limits portability but with given time positioning for simulation can be obtained The aquaponic system itself played a small role in each controls simulation as this project is itrsquos first of its kind so experimenting in controlled environments allowed for minimal fish and plant casualties Given the preparation and collaboration in finalizing this study future aquaponic control systems can be fully implemented with the desired expected results which include autonomy fish culture and plant ecology

Recommendations It is recommended when combining a traditional aquaponic system with automated control systems for there to be collaborators at either a university or professional level The design and creation of sensor clusters using arduino as a microprossesor and an Xbee shield will more than likely be beyond the average citizenrsquos knowledge Beginning with an indoor small scale prototype will most likely save you money and time plus implementation of control system will be more accessible to troubleshoot Research knowledge of running and maintaining an aquaponic system and learning how controls work is important for a successful integrated system

Acknowledgements RET (Research Experiences for Teachers) Site on Sensor Networks Electrical Engineering Department and Institute of Applied Sciences UNT Denton Texas This material is based upon work supported by the National Science Foundation (NSF) under Grant No 1132585 and the IEEE Control Systems Society (CSS) Outreach Fund Any opinions findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF or the IEEE We would like to thank UNTrsquos Electrical Engineering Department staff and graduate students for their support and expertise throughout the course of this project In particular Dr Yan Wan for her mentoring and workshops over system controls Vardhman Sheth for working with us on designing creating and executing our sensor cluster and individual controls Dr Thompson and Dr Acevedo for initiating this training and requiring the very best from each of the participating teachers We would also like to acknowledge all participating teachers for their encouragement and enthusiasm throughout the entire training

References Antsaklis P Passino K An Introduction to Autonomous Control Systems IEEE Control

Systems 1991 httpwww2eceohio-stateedu~passinoPapersToPostIntro-Aut-Controlpdf

Arduino - HomePage Np nd Web 17 July 2012 lthttpwwwarduinoccgt Atlas-Scientific Home Np nd Web 17 July 2012 lthttpatlas-scientificcomgt Diver S AQUAPONICS - INTEGRATION OF HYDROPONICS WITH AQUACULTURE httpwwwacesedudeptfisherieseducationdocumentsHorticulturesystemsguidepdf Graber A Junge R ldquo Aquaponic Systems Nutrient recycling from fish wastewater by vegetable

productionrdquo Desalination 246147-156 012009 DOI 101016jdesal200803048

12

Losordo T Recirculating Aquaculture Tank Production Systems SRAC Publication No 4531992 httpuniversityuogeducalspeoplepubsaquac453recpdf

Tamaru C Challenges and Opportunities for Aquaponics in the College of Tropical Agriculture and Human Resources 2011 httpwwwctahrhawaiiedusustainagnewsarticlesV6-Tamaru-aquaponicpdf

Villarroel M Aquaponics integrating fish feeding rates and ion waste production for strawberry hydroponics 2011 httprevistasiniaesindexphpsjararticleview1758

Wardlow G Enhancing Student Interest in the Agricultural Sciences through Aquaponics J Nat Resour Life Sci Educ Vol 31 2002 httpswwwagronomyorgfilesjnrlseissues2002e00-15kpdf

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

7

Figure 3- Water lilies inserted through the more buoyant Styrofoam

Figure 4- Overflow control valve in sump along with 4rsquo power motor

8

Figure 5- Fully assembled aquaponics system

Methods We collected daily measurements for pH temperature and dissolved oxygen of our aquaponics system We used the PASCO Spark probe to test these parameters as well as a commercially sold water condition kit which we needed to take physical water samples from our tank The kit also included tests for nitrite nitrate and ammonia levels These data were added to a spreadsheet and shared amongst the team We began comparing data between PASCO and sensor cluster in the clusterrsquos infancy stage (around week 2 of our training) and found little error testing for only 5 minutes between the two readings Several discrepancies were seen when cluster read for more than 5 minutes so Vardhman refined the circuit design By week 5 the cluster gave less than a 2 error for more than an hour of data collection for pH temperature and dissolved oxygen The intended goal for this project required a dayrsquos worth of data collection to allow us to determine the reliability of our cluster We also intended to collect data remotely so Vardhman created a database in which he can access it from his laptop We could then correct any major problems within our system if controllers failed plus this data can be graphed allowing us to see trends in environmental conditions A major part to our aquaponic system is the implementation of several controls to neutralize any environmental conditions that might spiral out of control We utilized a plastic dispenser for pH with an accompanying pH neutralizer with the sensor cluster taking constant readings it will allow for a specific amount of pH to be dispensed into the fish tank The control uses a closed loop system allowing for the sensor cluster to once again monitor water conditions before determining which steps to take A second control was the food dispenser (Figure 7) Like our pH dispenser this control is integrated into the sensor cluster A motor was

9

attached to a small fluid collecting bottle which was used to house fish pellets and was inserted into a 12rsquo 4rdquo X 4rdquo The bottle would rotate 360 degrees 4 times a day Our third control included a 50 gallon storage container (acting as a reservoir) which we filled with water which will dispense water into fish tank when sonar sensors located under tank lid sensed a frac12rdquo drop in water Finally in order to maintain the proper dissolved oxygen levels a bubbler was added to fish tank both the reservoir and bubbler used a turn onoff power control Once cluster and controls were built and tested for accuracy we added disturbances to our tank these included fluctuating pH DO and water level conditions We made sure not to vary pH drastically as this would shock and possibly kill our fish Instead only a +- 6 change in pH was needed to activate control Observations were made and recorded onto our blog

Results Data was collected at two different time period once at 24hrs and another at 48hrs Both sets of data showed our sensor cluster working as programmed Graphs created show no major disturbance indicating no further breakdown of cluster (Figure 8 and Figure 9 in Appendix) Figure 6 was collected from a set of points of Figure 9 and an algorithm was developed to allow for a much smoother line graph Figure 6 shows temperature constant at 23C pH levels 72 and DO levels at 78 Similarly Figure 8 maintains temperature and DO levels through the tested time period but pH drops several decimal points but not significantly to propose a sensor cluster problem Figure 9 shows data without the algorithm Figure 10 to Figure 17 show our last set of data with individual readings for pH DO and temperature (Appendix) There is no evidence in graphs of fluctuation in sensors Figure 18 and Figure 19 show data for testing of our controls (Appendix)

Figure 6 Results showing temperature at 23C pH levels 72 and DO levels at 78

Discussion Our initial data collection comparing sensor cluster to PASCO gave us pretty good readings for the first 5 minutes of testing Dissolved oxygen pH and temperature probes of cluster gave less than a 3 error when compare to PASCO (Figure 6) The problem arose when left for more than

10

5 minutes and also having the DO and pH probes in the tank at the same time When each of these probes are taking live readings there is a voltage interference that then translates to a digital error reading The errors were significant more than a point off These problems required for Vardhman to isolate dissolved oxygen from pH using a 6N137 single-channel and utilizing a dual-channel HCPL2630 This change also isolated ground for each of the probes (Figure 9 Figure 10 and Figure 11)

Once our sensor cluster was finalized we collected 24hr data of our fish tanks conditions (Figure 7) The accompanying Figure 8 graph was produced using MATLAB The data did not report any errors although we determined that there were too many data points to be graphed so Vardhman decided that on future trials to develop an algorithm which would eliminate these points Also there are multiple 0 point values with pH reading but this is expected due to the sensitivity of these probes This hiccup is not enough to alter graph readings We made a second attempt at collecting data but this time leaving the sensor cluster activated for nearly 48hrs Once again we had reliable data (Figure 15 and Figure 16) There are no major points within graph where it becomes inactive We wanted to show a comparison between a graph with a developed algorithm and one without this function Figure 15 Figure 16 Figure 19 and Figure 20 show this comparison Figure 17 and Figure 21 show a partial collection of data

The difficulty in simulating each control is that there are many factors that come into play- most importantly time We needed to manipulate the environmental conditions in a lab that would otherwise be found in nature Also because we are working with parts that require a power source the use of multiple outlets and power strips made our testing area fairly tight and problematic Finally we are working with electrical components that we all know do not mix well with water so it took time when stationing for demonstration Our final circuit system unfortunately was not soldered together so we needed to connect the appropriate wires for each control--again taking time

We tested our controls by manipulating each in an isolated volume of water After adding a disturbance for pH there is no immediate control input instead there is a 2 min delay but we do continue to gather data into our database (Figure 22) The actuator only dispenses after the average results are collected This average if you recall are 10 data points or collections at 8 seconds apart So a total of 80 sec passes before there is some action from actuator Vardhman programmed the system this way to allow the added control (fluid etc) to diffuse through water before taking the appropriate next steps The disturbance in this experimental trial was added at 20 sec (pH right above 7) levels dropped to just under 7 (fluctuating a little) and after 2 minutes a volume of pH corrector was added system continued to collect data averaging points One factor different to this graph compared to all others is that Vardhmans algorithm allows for a much smoother sloped line and removes every data point collected every 8 sec that would otherwise show sharp and steep lines The graph also shows where control is turned off and levels rise back to normal The reestablished conditions of our sampled water is a reliable control system Similar to pH we used an isolated volume of water to test tank refill We used Velcro to constrain two sonars and pumped water from a reservoir We started our data collection with water height of 19 cm pump turned on for a total time of nearly two minute until the desired depth of 14 cm pump then turned off (Figure 23) You can see video of each control simulation under the appendix of this report

Conclusion In conclusion after testing sensor cluster at two time intervals 24hr and 48hr we are confident in its reliability and accuracy Data and graphs provided do not suggest speculation of its

11

dependability the clusters parts and software are also trustworthy as they are mass produced and there are a number of professions who utilize its capacity to operate and maintain high end expensive machines Each control was tested under a simulated field environment and each performed as expected Preparation leading to tests remains a hurdle as there are many components that play intricate roles in each controls operations The use of water around electrical components also limits portability but with given time positioning for simulation can be obtained The aquaponic system itself played a small role in each controls simulation as this project is itrsquos first of its kind so experimenting in controlled environments allowed for minimal fish and plant casualties Given the preparation and collaboration in finalizing this study future aquaponic control systems can be fully implemented with the desired expected results which include autonomy fish culture and plant ecology

Recommendations It is recommended when combining a traditional aquaponic system with automated control systems for there to be collaborators at either a university or professional level The design and creation of sensor clusters using arduino as a microprossesor and an Xbee shield will more than likely be beyond the average citizenrsquos knowledge Beginning with an indoor small scale prototype will most likely save you money and time plus implementation of control system will be more accessible to troubleshoot Research knowledge of running and maintaining an aquaponic system and learning how controls work is important for a successful integrated system

Acknowledgements RET (Research Experiences for Teachers) Site on Sensor Networks Electrical Engineering Department and Institute of Applied Sciences UNT Denton Texas This material is based upon work supported by the National Science Foundation (NSF) under Grant No 1132585 and the IEEE Control Systems Society (CSS) Outreach Fund Any opinions findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF or the IEEE We would like to thank UNTrsquos Electrical Engineering Department staff and graduate students for their support and expertise throughout the course of this project In particular Dr Yan Wan for her mentoring and workshops over system controls Vardhman Sheth for working with us on designing creating and executing our sensor cluster and individual controls Dr Thompson and Dr Acevedo for initiating this training and requiring the very best from each of the participating teachers We would also like to acknowledge all participating teachers for their encouragement and enthusiasm throughout the entire training

References Antsaklis P Passino K An Introduction to Autonomous Control Systems IEEE Control

Systems 1991 httpwww2eceohio-stateedu~passinoPapersToPostIntro-Aut-Controlpdf

Arduino - HomePage Np nd Web 17 July 2012 lthttpwwwarduinoccgt Atlas-Scientific Home Np nd Web 17 July 2012 lthttpatlas-scientificcomgt Diver S AQUAPONICS - INTEGRATION OF HYDROPONICS WITH AQUACULTURE httpwwwacesedudeptfisherieseducationdocumentsHorticulturesystemsguidepdf Graber A Junge R ldquo Aquaponic Systems Nutrient recycling from fish wastewater by vegetable

productionrdquo Desalination 246147-156 012009 DOI 101016jdesal200803048

12

Losordo T Recirculating Aquaculture Tank Production Systems SRAC Publication No 4531992 httpuniversityuogeducalspeoplepubsaquac453recpdf

Tamaru C Challenges and Opportunities for Aquaponics in the College of Tropical Agriculture and Human Resources 2011 httpwwwctahrhawaiiedusustainagnewsarticlesV6-Tamaru-aquaponicpdf

Villarroel M Aquaponics integrating fish feeding rates and ion waste production for strawberry hydroponics 2011 httprevistasiniaesindexphpsjararticleview1758

Wardlow G Enhancing Student Interest in the Agricultural Sciences through Aquaponics J Nat Resour Life Sci Educ Vol 31 2002 httpswwwagronomyorgfilesjnrlseissues2002e00-15kpdf

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

8

Figure 5- Fully assembled aquaponics system

Methods We collected daily measurements for pH temperature and dissolved oxygen of our aquaponics system We used the PASCO Spark probe to test these parameters as well as a commercially sold water condition kit which we needed to take physical water samples from our tank The kit also included tests for nitrite nitrate and ammonia levels These data were added to a spreadsheet and shared amongst the team We began comparing data between PASCO and sensor cluster in the clusterrsquos infancy stage (around week 2 of our training) and found little error testing for only 5 minutes between the two readings Several discrepancies were seen when cluster read for more than 5 minutes so Vardhman refined the circuit design By week 5 the cluster gave less than a 2 error for more than an hour of data collection for pH temperature and dissolved oxygen The intended goal for this project required a dayrsquos worth of data collection to allow us to determine the reliability of our cluster We also intended to collect data remotely so Vardhman created a database in which he can access it from his laptop We could then correct any major problems within our system if controllers failed plus this data can be graphed allowing us to see trends in environmental conditions A major part to our aquaponic system is the implementation of several controls to neutralize any environmental conditions that might spiral out of control We utilized a plastic dispenser for pH with an accompanying pH neutralizer with the sensor cluster taking constant readings it will allow for a specific amount of pH to be dispensed into the fish tank The control uses a closed loop system allowing for the sensor cluster to once again monitor water conditions before determining which steps to take A second control was the food dispenser (Figure 7) Like our pH dispenser this control is integrated into the sensor cluster A motor was

9

attached to a small fluid collecting bottle which was used to house fish pellets and was inserted into a 12rsquo 4rdquo X 4rdquo The bottle would rotate 360 degrees 4 times a day Our third control included a 50 gallon storage container (acting as a reservoir) which we filled with water which will dispense water into fish tank when sonar sensors located under tank lid sensed a frac12rdquo drop in water Finally in order to maintain the proper dissolved oxygen levels a bubbler was added to fish tank both the reservoir and bubbler used a turn onoff power control Once cluster and controls were built and tested for accuracy we added disturbances to our tank these included fluctuating pH DO and water level conditions We made sure not to vary pH drastically as this would shock and possibly kill our fish Instead only a +- 6 change in pH was needed to activate control Observations were made and recorded onto our blog

Results Data was collected at two different time period once at 24hrs and another at 48hrs Both sets of data showed our sensor cluster working as programmed Graphs created show no major disturbance indicating no further breakdown of cluster (Figure 8 and Figure 9 in Appendix) Figure 6 was collected from a set of points of Figure 9 and an algorithm was developed to allow for a much smoother line graph Figure 6 shows temperature constant at 23C pH levels 72 and DO levels at 78 Similarly Figure 8 maintains temperature and DO levels through the tested time period but pH drops several decimal points but not significantly to propose a sensor cluster problem Figure 9 shows data without the algorithm Figure 10 to Figure 17 show our last set of data with individual readings for pH DO and temperature (Appendix) There is no evidence in graphs of fluctuation in sensors Figure 18 and Figure 19 show data for testing of our controls (Appendix)

Figure 6 Results showing temperature at 23C pH levels 72 and DO levels at 78

Discussion Our initial data collection comparing sensor cluster to PASCO gave us pretty good readings for the first 5 minutes of testing Dissolved oxygen pH and temperature probes of cluster gave less than a 3 error when compare to PASCO (Figure 6) The problem arose when left for more than

10

5 minutes and also having the DO and pH probes in the tank at the same time When each of these probes are taking live readings there is a voltage interference that then translates to a digital error reading The errors were significant more than a point off These problems required for Vardhman to isolate dissolved oxygen from pH using a 6N137 single-channel and utilizing a dual-channel HCPL2630 This change also isolated ground for each of the probes (Figure 9 Figure 10 and Figure 11)

Once our sensor cluster was finalized we collected 24hr data of our fish tanks conditions (Figure 7) The accompanying Figure 8 graph was produced using MATLAB The data did not report any errors although we determined that there were too many data points to be graphed so Vardhman decided that on future trials to develop an algorithm which would eliminate these points Also there are multiple 0 point values with pH reading but this is expected due to the sensitivity of these probes This hiccup is not enough to alter graph readings We made a second attempt at collecting data but this time leaving the sensor cluster activated for nearly 48hrs Once again we had reliable data (Figure 15 and Figure 16) There are no major points within graph where it becomes inactive We wanted to show a comparison between a graph with a developed algorithm and one without this function Figure 15 Figure 16 Figure 19 and Figure 20 show this comparison Figure 17 and Figure 21 show a partial collection of data

The difficulty in simulating each control is that there are many factors that come into play- most importantly time We needed to manipulate the environmental conditions in a lab that would otherwise be found in nature Also because we are working with parts that require a power source the use of multiple outlets and power strips made our testing area fairly tight and problematic Finally we are working with electrical components that we all know do not mix well with water so it took time when stationing for demonstration Our final circuit system unfortunately was not soldered together so we needed to connect the appropriate wires for each control--again taking time

We tested our controls by manipulating each in an isolated volume of water After adding a disturbance for pH there is no immediate control input instead there is a 2 min delay but we do continue to gather data into our database (Figure 22) The actuator only dispenses after the average results are collected This average if you recall are 10 data points or collections at 8 seconds apart So a total of 80 sec passes before there is some action from actuator Vardhman programmed the system this way to allow the added control (fluid etc) to diffuse through water before taking the appropriate next steps The disturbance in this experimental trial was added at 20 sec (pH right above 7) levels dropped to just under 7 (fluctuating a little) and after 2 minutes a volume of pH corrector was added system continued to collect data averaging points One factor different to this graph compared to all others is that Vardhmans algorithm allows for a much smoother sloped line and removes every data point collected every 8 sec that would otherwise show sharp and steep lines The graph also shows where control is turned off and levels rise back to normal The reestablished conditions of our sampled water is a reliable control system Similar to pH we used an isolated volume of water to test tank refill We used Velcro to constrain two sonars and pumped water from a reservoir We started our data collection with water height of 19 cm pump turned on for a total time of nearly two minute until the desired depth of 14 cm pump then turned off (Figure 23) You can see video of each control simulation under the appendix of this report

Conclusion In conclusion after testing sensor cluster at two time intervals 24hr and 48hr we are confident in its reliability and accuracy Data and graphs provided do not suggest speculation of its

11

dependability the clusters parts and software are also trustworthy as they are mass produced and there are a number of professions who utilize its capacity to operate and maintain high end expensive machines Each control was tested under a simulated field environment and each performed as expected Preparation leading to tests remains a hurdle as there are many components that play intricate roles in each controls operations The use of water around electrical components also limits portability but with given time positioning for simulation can be obtained The aquaponic system itself played a small role in each controls simulation as this project is itrsquos first of its kind so experimenting in controlled environments allowed for minimal fish and plant casualties Given the preparation and collaboration in finalizing this study future aquaponic control systems can be fully implemented with the desired expected results which include autonomy fish culture and plant ecology

Recommendations It is recommended when combining a traditional aquaponic system with automated control systems for there to be collaborators at either a university or professional level The design and creation of sensor clusters using arduino as a microprossesor and an Xbee shield will more than likely be beyond the average citizenrsquos knowledge Beginning with an indoor small scale prototype will most likely save you money and time plus implementation of control system will be more accessible to troubleshoot Research knowledge of running and maintaining an aquaponic system and learning how controls work is important for a successful integrated system

Acknowledgements RET (Research Experiences for Teachers) Site on Sensor Networks Electrical Engineering Department and Institute of Applied Sciences UNT Denton Texas This material is based upon work supported by the National Science Foundation (NSF) under Grant No 1132585 and the IEEE Control Systems Society (CSS) Outreach Fund Any opinions findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF or the IEEE We would like to thank UNTrsquos Electrical Engineering Department staff and graduate students for their support and expertise throughout the course of this project In particular Dr Yan Wan for her mentoring and workshops over system controls Vardhman Sheth for working with us on designing creating and executing our sensor cluster and individual controls Dr Thompson and Dr Acevedo for initiating this training and requiring the very best from each of the participating teachers We would also like to acknowledge all participating teachers for their encouragement and enthusiasm throughout the entire training

References Antsaklis P Passino K An Introduction to Autonomous Control Systems IEEE Control

Systems 1991 httpwww2eceohio-stateedu~passinoPapersToPostIntro-Aut-Controlpdf

Arduino - HomePage Np nd Web 17 July 2012 lthttpwwwarduinoccgt Atlas-Scientific Home Np nd Web 17 July 2012 lthttpatlas-scientificcomgt Diver S AQUAPONICS - INTEGRATION OF HYDROPONICS WITH AQUACULTURE httpwwwacesedudeptfisherieseducationdocumentsHorticulturesystemsguidepdf Graber A Junge R ldquo Aquaponic Systems Nutrient recycling from fish wastewater by vegetable

productionrdquo Desalination 246147-156 012009 DOI 101016jdesal200803048

12

Losordo T Recirculating Aquaculture Tank Production Systems SRAC Publication No 4531992 httpuniversityuogeducalspeoplepubsaquac453recpdf

Tamaru C Challenges and Opportunities for Aquaponics in the College of Tropical Agriculture and Human Resources 2011 httpwwwctahrhawaiiedusustainagnewsarticlesV6-Tamaru-aquaponicpdf

Villarroel M Aquaponics integrating fish feeding rates and ion waste production for strawberry hydroponics 2011 httprevistasiniaesindexphpsjararticleview1758

Wardlow G Enhancing Student Interest in the Agricultural Sciences through Aquaponics J Nat Resour Life Sci Educ Vol 31 2002 httpswwwagronomyorgfilesjnrlseissues2002e00-15kpdf

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

9

attached to a small fluid collecting bottle which was used to house fish pellets and was inserted into a 12rsquo 4rdquo X 4rdquo The bottle would rotate 360 degrees 4 times a day Our third control included a 50 gallon storage container (acting as a reservoir) which we filled with water which will dispense water into fish tank when sonar sensors located under tank lid sensed a frac12rdquo drop in water Finally in order to maintain the proper dissolved oxygen levels a bubbler was added to fish tank both the reservoir and bubbler used a turn onoff power control Once cluster and controls were built and tested for accuracy we added disturbances to our tank these included fluctuating pH DO and water level conditions We made sure not to vary pH drastically as this would shock and possibly kill our fish Instead only a +- 6 change in pH was needed to activate control Observations were made and recorded onto our blog

Results Data was collected at two different time period once at 24hrs and another at 48hrs Both sets of data showed our sensor cluster working as programmed Graphs created show no major disturbance indicating no further breakdown of cluster (Figure 8 and Figure 9 in Appendix) Figure 6 was collected from a set of points of Figure 9 and an algorithm was developed to allow for a much smoother line graph Figure 6 shows temperature constant at 23C pH levels 72 and DO levels at 78 Similarly Figure 8 maintains temperature and DO levels through the tested time period but pH drops several decimal points but not significantly to propose a sensor cluster problem Figure 9 shows data without the algorithm Figure 10 to Figure 17 show our last set of data with individual readings for pH DO and temperature (Appendix) There is no evidence in graphs of fluctuation in sensors Figure 18 and Figure 19 show data for testing of our controls (Appendix)

Figure 6 Results showing temperature at 23C pH levels 72 and DO levels at 78

Discussion Our initial data collection comparing sensor cluster to PASCO gave us pretty good readings for the first 5 minutes of testing Dissolved oxygen pH and temperature probes of cluster gave less than a 3 error when compare to PASCO (Figure 6) The problem arose when left for more than

10

5 minutes and also having the DO and pH probes in the tank at the same time When each of these probes are taking live readings there is a voltage interference that then translates to a digital error reading The errors were significant more than a point off These problems required for Vardhman to isolate dissolved oxygen from pH using a 6N137 single-channel and utilizing a dual-channel HCPL2630 This change also isolated ground for each of the probes (Figure 9 Figure 10 and Figure 11)

Once our sensor cluster was finalized we collected 24hr data of our fish tanks conditions (Figure 7) The accompanying Figure 8 graph was produced using MATLAB The data did not report any errors although we determined that there were too many data points to be graphed so Vardhman decided that on future trials to develop an algorithm which would eliminate these points Also there are multiple 0 point values with pH reading but this is expected due to the sensitivity of these probes This hiccup is not enough to alter graph readings We made a second attempt at collecting data but this time leaving the sensor cluster activated for nearly 48hrs Once again we had reliable data (Figure 15 and Figure 16) There are no major points within graph where it becomes inactive We wanted to show a comparison between a graph with a developed algorithm and one without this function Figure 15 Figure 16 Figure 19 and Figure 20 show this comparison Figure 17 and Figure 21 show a partial collection of data

The difficulty in simulating each control is that there are many factors that come into play- most importantly time We needed to manipulate the environmental conditions in a lab that would otherwise be found in nature Also because we are working with parts that require a power source the use of multiple outlets and power strips made our testing area fairly tight and problematic Finally we are working with electrical components that we all know do not mix well with water so it took time when stationing for demonstration Our final circuit system unfortunately was not soldered together so we needed to connect the appropriate wires for each control--again taking time

We tested our controls by manipulating each in an isolated volume of water After adding a disturbance for pH there is no immediate control input instead there is a 2 min delay but we do continue to gather data into our database (Figure 22) The actuator only dispenses after the average results are collected This average if you recall are 10 data points or collections at 8 seconds apart So a total of 80 sec passes before there is some action from actuator Vardhman programmed the system this way to allow the added control (fluid etc) to diffuse through water before taking the appropriate next steps The disturbance in this experimental trial was added at 20 sec (pH right above 7) levels dropped to just under 7 (fluctuating a little) and after 2 minutes a volume of pH corrector was added system continued to collect data averaging points One factor different to this graph compared to all others is that Vardhmans algorithm allows for a much smoother sloped line and removes every data point collected every 8 sec that would otherwise show sharp and steep lines The graph also shows where control is turned off and levels rise back to normal The reestablished conditions of our sampled water is a reliable control system Similar to pH we used an isolated volume of water to test tank refill We used Velcro to constrain two sonars and pumped water from a reservoir We started our data collection with water height of 19 cm pump turned on for a total time of nearly two minute until the desired depth of 14 cm pump then turned off (Figure 23) You can see video of each control simulation under the appendix of this report

Conclusion In conclusion after testing sensor cluster at two time intervals 24hr and 48hr we are confident in its reliability and accuracy Data and graphs provided do not suggest speculation of its

11

dependability the clusters parts and software are also trustworthy as they are mass produced and there are a number of professions who utilize its capacity to operate and maintain high end expensive machines Each control was tested under a simulated field environment and each performed as expected Preparation leading to tests remains a hurdle as there are many components that play intricate roles in each controls operations The use of water around electrical components also limits portability but with given time positioning for simulation can be obtained The aquaponic system itself played a small role in each controls simulation as this project is itrsquos first of its kind so experimenting in controlled environments allowed for minimal fish and plant casualties Given the preparation and collaboration in finalizing this study future aquaponic control systems can be fully implemented with the desired expected results which include autonomy fish culture and plant ecology

Recommendations It is recommended when combining a traditional aquaponic system with automated control systems for there to be collaborators at either a university or professional level The design and creation of sensor clusters using arduino as a microprossesor and an Xbee shield will more than likely be beyond the average citizenrsquos knowledge Beginning with an indoor small scale prototype will most likely save you money and time plus implementation of control system will be more accessible to troubleshoot Research knowledge of running and maintaining an aquaponic system and learning how controls work is important for a successful integrated system

Acknowledgements RET (Research Experiences for Teachers) Site on Sensor Networks Electrical Engineering Department and Institute of Applied Sciences UNT Denton Texas This material is based upon work supported by the National Science Foundation (NSF) under Grant No 1132585 and the IEEE Control Systems Society (CSS) Outreach Fund Any opinions findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF or the IEEE We would like to thank UNTrsquos Electrical Engineering Department staff and graduate students for their support and expertise throughout the course of this project In particular Dr Yan Wan for her mentoring and workshops over system controls Vardhman Sheth for working with us on designing creating and executing our sensor cluster and individual controls Dr Thompson and Dr Acevedo for initiating this training and requiring the very best from each of the participating teachers We would also like to acknowledge all participating teachers for their encouragement and enthusiasm throughout the entire training

References Antsaklis P Passino K An Introduction to Autonomous Control Systems IEEE Control

Systems 1991 httpwww2eceohio-stateedu~passinoPapersToPostIntro-Aut-Controlpdf

Arduino - HomePage Np nd Web 17 July 2012 lthttpwwwarduinoccgt Atlas-Scientific Home Np nd Web 17 July 2012 lthttpatlas-scientificcomgt Diver S AQUAPONICS - INTEGRATION OF HYDROPONICS WITH AQUACULTURE httpwwwacesedudeptfisherieseducationdocumentsHorticulturesystemsguidepdf Graber A Junge R ldquo Aquaponic Systems Nutrient recycling from fish wastewater by vegetable

productionrdquo Desalination 246147-156 012009 DOI 101016jdesal200803048

12

Losordo T Recirculating Aquaculture Tank Production Systems SRAC Publication No 4531992 httpuniversityuogeducalspeoplepubsaquac453recpdf

Tamaru C Challenges and Opportunities for Aquaponics in the College of Tropical Agriculture and Human Resources 2011 httpwwwctahrhawaiiedusustainagnewsarticlesV6-Tamaru-aquaponicpdf

Villarroel M Aquaponics integrating fish feeding rates and ion waste production for strawberry hydroponics 2011 httprevistasiniaesindexphpsjararticleview1758

Wardlow G Enhancing Student Interest in the Agricultural Sciences through Aquaponics J Nat Resour Life Sci Educ Vol 31 2002 httpswwwagronomyorgfilesjnrlseissues2002e00-15kpdf

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

10

5 minutes and also having the DO and pH probes in the tank at the same time When each of these probes are taking live readings there is a voltage interference that then translates to a digital error reading The errors were significant more than a point off These problems required for Vardhman to isolate dissolved oxygen from pH using a 6N137 single-channel and utilizing a dual-channel HCPL2630 This change also isolated ground for each of the probes (Figure 9 Figure 10 and Figure 11)

Once our sensor cluster was finalized we collected 24hr data of our fish tanks conditions (Figure 7) The accompanying Figure 8 graph was produced using MATLAB The data did not report any errors although we determined that there were too many data points to be graphed so Vardhman decided that on future trials to develop an algorithm which would eliminate these points Also there are multiple 0 point values with pH reading but this is expected due to the sensitivity of these probes This hiccup is not enough to alter graph readings We made a second attempt at collecting data but this time leaving the sensor cluster activated for nearly 48hrs Once again we had reliable data (Figure 15 and Figure 16) There are no major points within graph where it becomes inactive We wanted to show a comparison between a graph with a developed algorithm and one without this function Figure 15 Figure 16 Figure 19 and Figure 20 show this comparison Figure 17 and Figure 21 show a partial collection of data

The difficulty in simulating each control is that there are many factors that come into play- most importantly time We needed to manipulate the environmental conditions in a lab that would otherwise be found in nature Also because we are working with parts that require a power source the use of multiple outlets and power strips made our testing area fairly tight and problematic Finally we are working with electrical components that we all know do not mix well with water so it took time when stationing for demonstration Our final circuit system unfortunately was not soldered together so we needed to connect the appropriate wires for each control--again taking time

We tested our controls by manipulating each in an isolated volume of water After adding a disturbance for pH there is no immediate control input instead there is a 2 min delay but we do continue to gather data into our database (Figure 22) The actuator only dispenses after the average results are collected This average if you recall are 10 data points or collections at 8 seconds apart So a total of 80 sec passes before there is some action from actuator Vardhman programmed the system this way to allow the added control (fluid etc) to diffuse through water before taking the appropriate next steps The disturbance in this experimental trial was added at 20 sec (pH right above 7) levels dropped to just under 7 (fluctuating a little) and after 2 minutes a volume of pH corrector was added system continued to collect data averaging points One factor different to this graph compared to all others is that Vardhmans algorithm allows for a much smoother sloped line and removes every data point collected every 8 sec that would otherwise show sharp and steep lines The graph also shows where control is turned off and levels rise back to normal The reestablished conditions of our sampled water is a reliable control system Similar to pH we used an isolated volume of water to test tank refill We used Velcro to constrain two sonars and pumped water from a reservoir We started our data collection with water height of 19 cm pump turned on for a total time of nearly two minute until the desired depth of 14 cm pump then turned off (Figure 23) You can see video of each control simulation under the appendix of this report

Conclusion In conclusion after testing sensor cluster at two time intervals 24hr and 48hr we are confident in its reliability and accuracy Data and graphs provided do not suggest speculation of its

11

dependability the clusters parts and software are also trustworthy as they are mass produced and there are a number of professions who utilize its capacity to operate and maintain high end expensive machines Each control was tested under a simulated field environment and each performed as expected Preparation leading to tests remains a hurdle as there are many components that play intricate roles in each controls operations The use of water around electrical components also limits portability but with given time positioning for simulation can be obtained The aquaponic system itself played a small role in each controls simulation as this project is itrsquos first of its kind so experimenting in controlled environments allowed for minimal fish and plant casualties Given the preparation and collaboration in finalizing this study future aquaponic control systems can be fully implemented with the desired expected results which include autonomy fish culture and plant ecology

Recommendations It is recommended when combining a traditional aquaponic system with automated control systems for there to be collaborators at either a university or professional level The design and creation of sensor clusters using arduino as a microprossesor and an Xbee shield will more than likely be beyond the average citizenrsquos knowledge Beginning with an indoor small scale prototype will most likely save you money and time plus implementation of control system will be more accessible to troubleshoot Research knowledge of running and maintaining an aquaponic system and learning how controls work is important for a successful integrated system

Acknowledgements RET (Research Experiences for Teachers) Site on Sensor Networks Electrical Engineering Department and Institute of Applied Sciences UNT Denton Texas This material is based upon work supported by the National Science Foundation (NSF) under Grant No 1132585 and the IEEE Control Systems Society (CSS) Outreach Fund Any opinions findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF or the IEEE We would like to thank UNTrsquos Electrical Engineering Department staff and graduate students for their support and expertise throughout the course of this project In particular Dr Yan Wan for her mentoring and workshops over system controls Vardhman Sheth for working with us on designing creating and executing our sensor cluster and individual controls Dr Thompson and Dr Acevedo for initiating this training and requiring the very best from each of the participating teachers We would also like to acknowledge all participating teachers for their encouragement and enthusiasm throughout the entire training

References Antsaklis P Passino K An Introduction to Autonomous Control Systems IEEE Control

Systems 1991 httpwww2eceohio-stateedu~passinoPapersToPostIntro-Aut-Controlpdf

Arduino - HomePage Np nd Web 17 July 2012 lthttpwwwarduinoccgt Atlas-Scientific Home Np nd Web 17 July 2012 lthttpatlas-scientificcomgt Diver S AQUAPONICS - INTEGRATION OF HYDROPONICS WITH AQUACULTURE httpwwwacesedudeptfisherieseducationdocumentsHorticulturesystemsguidepdf Graber A Junge R ldquo Aquaponic Systems Nutrient recycling from fish wastewater by vegetable

productionrdquo Desalination 246147-156 012009 DOI 101016jdesal200803048

12

Losordo T Recirculating Aquaculture Tank Production Systems SRAC Publication No 4531992 httpuniversityuogeducalspeoplepubsaquac453recpdf

Tamaru C Challenges and Opportunities for Aquaponics in the College of Tropical Agriculture and Human Resources 2011 httpwwwctahrhawaiiedusustainagnewsarticlesV6-Tamaru-aquaponicpdf

Villarroel M Aquaponics integrating fish feeding rates and ion waste production for strawberry hydroponics 2011 httprevistasiniaesindexphpsjararticleview1758

Wardlow G Enhancing Student Interest in the Agricultural Sciences through Aquaponics J Nat Resour Life Sci Educ Vol 31 2002 httpswwwagronomyorgfilesjnrlseissues2002e00-15kpdf

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

11

dependability the clusters parts and software are also trustworthy as they are mass produced and there are a number of professions who utilize its capacity to operate and maintain high end expensive machines Each control was tested under a simulated field environment and each performed as expected Preparation leading to tests remains a hurdle as there are many components that play intricate roles in each controls operations The use of water around electrical components also limits portability but with given time positioning for simulation can be obtained The aquaponic system itself played a small role in each controls simulation as this project is itrsquos first of its kind so experimenting in controlled environments allowed for minimal fish and plant casualties Given the preparation and collaboration in finalizing this study future aquaponic control systems can be fully implemented with the desired expected results which include autonomy fish culture and plant ecology

Recommendations It is recommended when combining a traditional aquaponic system with automated control systems for there to be collaborators at either a university or professional level The design and creation of sensor clusters using arduino as a microprossesor and an Xbee shield will more than likely be beyond the average citizenrsquos knowledge Beginning with an indoor small scale prototype will most likely save you money and time plus implementation of control system will be more accessible to troubleshoot Research knowledge of running and maintaining an aquaponic system and learning how controls work is important for a successful integrated system

Acknowledgements RET (Research Experiences for Teachers) Site on Sensor Networks Electrical Engineering Department and Institute of Applied Sciences UNT Denton Texas This material is based upon work supported by the National Science Foundation (NSF) under Grant No 1132585 and the IEEE Control Systems Society (CSS) Outreach Fund Any opinions findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF or the IEEE We would like to thank UNTrsquos Electrical Engineering Department staff and graduate students for their support and expertise throughout the course of this project In particular Dr Yan Wan for her mentoring and workshops over system controls Vardhman Sheth for working with us on designing creating and executing our sensor cluster and individual controls Dr Thompson and Dr Acevedo for initiating this training and requiring the very best from each of the participating teachers We would also like to acknowledge all participating teachers for their encouragement and enthusiasm throughout the entire training

References Antsaklis P Passino K An Introduction to Autonomous Control Systems IEEE Control

Systems 1991 httpwww2eceohio-stateedu~passinoPapersToPostIntro-Aut-Controlpdf

Arduino - HomePage Np nd Web 17 July 2012 lthttpwwwarduinoccgt Atlas-Scientific Home Np nd Web 17 July 2012 lthttpatlas-scientificcomgt Diver S AQUAPONICS - INTEGRATION OF HYDROPONICS WITH AQUACULTURE httpwwwacesedudeptfisherieseducationdocumentsHorticulturesystemsguidepdf Graber A Junge R ldquo Aquaponic Systems Nutrient recycling from fish wastewater by vegetable

productionrdquo Desalination 246147-156 012009 DOI 101016jdesal200803048

12

Losordo T Recirculating Aquaculture Tank Production Systems SRAC Publication No 4531992 httpuniversityuogeducalspeoplepubsaquac453recpdf

Tamaru C Challenges and Opportunities for Aquaponics in the College of Tropical Agriculture and Human Resources 2011 httpwwwctahrhawaiiedusustainagnewsarticlesV6-Tamaru-aquaponicpdf

Villarroel M Aquaponics integrating fish feeding rates and ion waste production for strawberry hydroponics 2011 httprevistasiniaesindexphpsjararticleview1758

Wardlow G Enhancing Student Interest in the Agricultural Sciences through Aquaponics J Nat Resour Life Sci Educ Vol 31 2002 httpswwwagronomyorgfilesjnrlseissues2002e00-15kpdf

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

12

Losordo T Recirculating Aquaculture Tank Production Systems SRAC Publication No 4531992 httpuniversityuogeducalspeoplepubsaquac453recpdf

Tamaru C Challenges and Opportunities for Aquaponics in the College of Tropical Agriculture and Human Resources 2011 httpwwwctahrhawaiiedusustainagnewsarticlesV6-Tamaru-aquaponicpdf

Villarroel M Aquaponics integrating fish feeding rates and ion waste production for strawberry hydroponics 2011 httprevistasiniaesindexphpsjararticleview1758

Wardlow G Enhancing Student Interest in the Agricultural Sciences through Aquaponics J Nat Resour Life Sci Educ Vol 31 2002 httpswwwagronomyorgfilesjnrlseissues2002e00-15kpdf

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

13

Appendix A Additional Figures

Figure 7 Preliminary data findings comparing PASCO probe ware to early face sensor cluster for 5 minutes

Figure 8 Early data collection from sensor cluster for a period of 24 hrs (from left to right temperature pH and

dissolved oxygen)

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

14

Figure 9 Early data collected from sensor cluster for a period of 24 hrs (blue- temperature green- dissolved oxygen red-

pH)

Figure 10 Because of voltage interference between pH and dissolved oxygen probes while taking live readings in fish

tank Vardhman isolated each of these probes voltage using the protocol below

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

15

Figure 11 Dissolved oxygen isolation

Figure 12 pH isolation

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

16

Figure 13 Control circuit for DO

Figure 14 Control circuit for pH

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

17

Figure 15 Circuit for food dispenser- The dispenser is attached to motor the dispenser activates every 24hrs from the

start of the system

Figure 16 Nearly 48hrs of data collection with pH temperature and DO sensors as well as their respective controls

(note temperature did not have a control)

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

18

Figure 17 Temperature with control algorithm

Figure 18 Data collected every 8 seconds

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

19

Figure 19 pH without a control (in red bottom line) pH with control (in blue top line)

Figure 20 pH signal obtained without processing by algorithm

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

20

Figure 21 pH signal obtained with processing by algorithm

Figure 22 Temperature values

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

21

Figure 23 Temperature Controlled

Figure 24 Water level Controlled

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

22

Figure 25 Dissolved Oxygen

Figure 26 Transients of control of pH

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

23

Figure 27 Water Control Transients

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

24

Appendix B Links for video Video for water refill httpwwwyoutubecomwatchv=AKInu9I2P3Yampfeature=youtube Video for dissolved oxygen httpyoutubeODVzNSf-Km4 Video for pH httpwwwyoutubecomwatchv=L-AN6qAb5Ws

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

25

Appendix C Arduino Code RET Project 2013 Arduino Code for Aquaphonics Ecosystem to monitor temp pH Dissolved oxygen and Water level of the aquarium and also control pH Dissolved Oxygen and Waterlevel include ltSoftwareSerialhgt add the soft serial library include ltLiquidCrystalhgt include ltContinuousRotationServohgt include ltDistanceSRF04hgt ContinuousRotationServo Servo LiquidCrystal lcd(8 9 13121110) Defining RX and TX pin define rxpinpH 4 set the RX pin to pin 4 - pH define txpinpH 5 set the TX pin to pin 5 -pH define rxpinDO 2 set the RX pin to pin 2 - DO define txpinDO 3 set the TX pin to pin 3 - DO SoftwareSerial pHserial(rxpinpH txpinpH) enable the soft serial port SoftwareSerial DOserial(rxpinDO txpinDO) DistanceSRF04 Dist int distance Sonar Sensor String sensorstringph = a string to hold the data pH String sensorstringDO = a string to hold the data pH float pHvaluenewvalue1 float DOvaluenewvalue2 char pHbuffer[4] char DObuffer[4] char buffer[6] String temp_str float tempnewvalue3 float newDOvalue[10] float DOstore[9] float newpHvalue[10] float pHstore[9] float newtemp[10] float tempstore[9]

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

26

int printtime=0 int temptime=0 int time=1 int pHcheck=0 if 1 then pH control mechanism is turned on int DOcheck=0 if 1 then DO control mechanism is turned on int watercheck=0 if 1 then water pump from reservior is turned on int pHtime=1 for pH control int foodtime=1 void setup() Serialbegin(9600) pHserialbegin(38400) DOserialbegin(38400) Distbegin(A5A4) for Sonar Sensor pinMode(A1OUTPUT) pH Control pinMode(A2OUTPUT) DO Control pinMode(A3OUTPUT) water level control lcdbegin(20 4) 20 x 4 LCD Display Servobegin(6) pinMode(13 OUTPUT) to crosscheck when the sensors get executed cli() Initialize timer in compare register mode set timer1 interrupt at 025 Hz TCCR1A = 0 TCCR1B = 0 TCNT1 = 0 set compare match register for 025Hz increments OCR1A = 62499 timer interrupt every 4 seconds 6249 = (1610^6) (0251024) - 1 (must be lt65536) turn on CTC mode TCCR1B |= (1 ltlt WGM12) Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 ltlt CS12) | (1 ltlt CS10) enable timer compare interrupt TIMSK1 |= (1 ltlt OCIE1A) sei() ISR(TIMER1_COMPA_vect)

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

27

time=time+1 foodtime=foodtime+1 void loop() for our servo it rotates 2 times once in a day if(foodtimelt5) ServorotateRight(25100) else Servorotate(1) need to calibrate my servo stops at value 1 if(foodtime==21600) foodtime=1 Check the water level in every main loop apart from the timer distance = DistgetDistanceCentimeter() if(distancegt=20) digitalWrite(A3HIGH) watercheck=1 else digitalWrite(A3LOW) watercheck=0 start() void start() taking reading after every 8 seconds if (time2==0) digitalWrite(13HIGH) digitalWrite(A3LOW) turning the water level pump off as taking values may take some time

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

28

readings() sensorstringDOtoCharArray(DObuffer6) DOvalue=atof(DObuffer) DOcorrection() sensorstringphtoCharArray(pHbuffer6) pHvalue=atof(pHbuffer) pHcorrection() printtime=printtime+1 temptime=temptime+1 distance = DistgetDistanceCentimeter() lcddisplay() display on LCD screen pHtime=pHtime+1 sendxbee() Send data to Xbee if(printtimegt=9) printtime=9 if(temptimegt=4) temptime=4 time=1 pHcheck=0 else digitalWrite(13LOW) function to read temperature float read_temp(void) digitalWrite(A0 LOW) float v_out float temp delay(2) v_out = analogRead(0) return value from 0 to 1023 v_out=0048 v_out=1000 temp= 00512 v_out -205128 return temp fundtion to read pH String pHreading(void) String value=

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

29

delay(500) pHserialprint(r) pHserialprint(temp_str) pHserialprint(r) pHseriallisten() delay(500) while (pHserialavailable()) while a char is holding in the serial buffer char inchar = (char)pHserialread() get the new char value += inchar add it to the sensorString delay(500) return value function to read DO String DOreading(void) delay(500) String value= DOserialprint(r) DOserialprint(temp_str) DOserialprint(r) DOseriallisten() delay(500) while (DOserialavailable()) while a char is holding in the serial buffer char inchar = (char)DOserialread() get the new char value += inchar add it to the sensorString delay(500) return value take all readings void readings() temp=read_temp() tempcorrection() temp_str = dtostrf(newvalue342buffer) giving the averaged value as input for both pH and DO delay(500) sensorstringDO=DOreading() delay(500) sensorstringph=pHreading()

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

30

function to Display on LCD void lcddisplay() lcdsetCursor(00) lcdprint(Temp) lcdprint(newvalue33) lcdsetCursor(01) lcdprint(pH) lcdprint(newvalue12) lcdsetCursor(02) lcdprint(DO) lcdprint(newvalue23) lcdsetCursor(03) lcdprint(Water level) lcdprint(distance) function to send data void sendxbee() Serialprint(H) Serialprint() Serialprint(newvalue32) Serialprint() Serialprint(pHcheck) Serialprint() Serialprint(newvalue12) Serialprint() Serialprint(DOcheck) Serialprint() Serialprint(newvalue22) Serialprint() Serialprint(watercheck) Serialprint() Serialprint(distance) Serialprint() Serialprintln() avergaing algorithm void DOcorrection()

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

31

float value=0 int j newDOvalue[printtime]=DOvalue if(printtime==9) for(j=0jlt=printtimej++) value=value+newDOvalue[j] newDOvalue[printtime]= value10 for(j=0jlt=8j++) DOstore[j]=newDOvalue[j+1] newDOvalue[j]=DOstore[j] if(newvalue2lt7) digitalWrite(A2HIGH) DOcheck=1 else digitalWrite(A2LOW) DOcheck=0 newvalue2=newDOvalue[printtime] void tempcorrection() float value=0 int j newtemp[temptime]=temp if(temptime==4) for(j=0jlt=temptimej++) value=value+newtemp[j] newtemp[temptime]= value5 for(j=0jlt=3j++)

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

32

tempstore[j]=newtemp[j+1] newtemp[j]=tempstore[j] newvalue3=newtemp[temptime] void pHcorrection() float value=0 int j newpHvalue[printtime]=pHvalue if(newpHvalue[printtime]==0) if(printtime==0) newpHvalue[printtime]= 711 731 intially measure the pH reading else newpHvalue[printtime]= newpHvalue[printtime-1] if(printtime==9) for(j=0jlt=printtimej++) value=value+newpHvalue[j] newpHvalue[printtime]= value10 for(j=0jlt=8j++) pHstore[j]=newpHvalue[j+1] newpHvalue[j]=pHstore[j] newvalue1=newpHvalue[printtime] if(pHtimegt=3600) two minutes time to check pH if(newvalue1lt=7) pH condition corrected pH value digitalWrite(A1HIGH) delay(700)

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

33

digitalWrite(A1LOW) pHcheck=1 pHtime=0 else digitalWrite(A1LOW) pHcheck=0 in case pHtime goes out of range without going below the reference level if(pHtimegt=32765) int range pHtime=3600 newvalue1=newpHvalue[printtime] RET Project 2013 Processing Code to receive data from the aquaphonics system Also upload the data in twitter and create the database of the received data import processingserial final int Line_Feed=10 final int BAUD_RATE=9600 get all this key from twitter final String CONSUMER_KEY= final String CONSUMER_SECRET= final String ACCESS_TOKEN= final String ACCESS_TOKEN_SECRET= Serial arduinoPort receive data from xbee PrintWriter output collect data to txt file char HEADER=H String temp String pH String DO

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

34

String Water String pHcheck String DOcheck String watercheck int num=0 int printtime=0 void setup() size(200200) output = createWriter(datadatatxt) println(Seriallist()) arduinoPort = new Serial(this Seriallist()[1] 9600) arduinoPortbufferUntil(Line_Feed) void draw() void serialEvent(Serial port) final String arduinoData = portreadStringUntil(10) if(arduinoData = null) final String[] data = arduinoDatasplit() if(data[0]charAt(0) == HEADER ampamp datalengthgt3) temp=data[1] pHcheck=data[2] pH=data[3] DOcheck=data[4] DO=data[5] watercheck=data[6] Water=data[7] for(int i=1iltdatalengthi++) println(readings+i+=+data[i]) result[i-1]=data[i] outputprint(+data[i]) if(printtimegt=150) tweetAlarm() printtime=0 num=num+1 println() printtime=printtime+1

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code

35

outputprintln() outputflush() void tweetAlarm() String times=IntegertoString(num) String s1 = Temp String s2 = pH String s3 = DO String s4 = Water level String sc2 String sc1 = s1 + s2 if(pHcheckequals(1)== true) String s5=pH control on sc2 = times + s1 + temp + s2 + pH + s3 + DO + s4 + Water + s5 else sc2 = times + s1 + temp + s2 + pH + s3 + DO + Water if(DOcheckequals(1)== true) String S6=DO control on sc2 = sc2 + S6 TwitterFactory factory = new TwitterFactory() Twitter twitter=factorygetInstance() twittersetOAuthConsumer(CONSUMER_KEY CONSUMER_SECRET) AccessToken accessToken = new AccessToken(ACCESS_TOKEN ACCESS_TOKEN_SECRET) twittersetOAuthAccessToken(accessToken) try Status status=twitterupdateStatus(sc2) println(Successful updation of values) catch(TwitterException e) eprintStackTrace()

  • Acknowledgments
  • Abstract
  • Introduction
  • Literature Review
  • Aquaponics Classroom Model
  • Methods
  • Results
  • Discussion
  • Conclusion
  • Recommendations
  • Acknowledgements
  • References
  • Appendix A Additional Figures
  • Appendix B Links for video
  • Appendix C Arduino Code