final report cocc greenhouse it group

Upload: richard-anish

Post on 03-Jun-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    1/26

    COCC Physics 213

    Fall Term 2012

    Final ReportAlexander HogenJames Preston

    Tracie Emick

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    2/26

    1 | P a g e

    Table of ContentsIntroduction.................................................................................................................................... 2

    Section 1: Project Goals & Design.................................................................................................. 2

    Project Goals................................................................................................................................. 2

    Part 1: Data Acquisition................................................................................................................. 2Part 2: Website Integration............................................................................................................ 2

    Part 3: Control of External Systems................................................................................................. 3

    General System Overview............................................................................................................... 3

    Voltage Divider.............................................................................................................................. 3

    RC Circuit....................................................................................................................................... 5

    Additional Information................................................................................................................... 6

    Sources......................................................................................................................................... 6

    Section 2: Building the System...................................................................................................... 7

    The Big Picture............................................................................................................................... 7Host computer............................................................................................................................... 8

    Website......................................................................................................................................... 8

    Sensors.......................................................................................................................................... 9

    CO2and Temperature.................................................................................................................... 9

    Light......................................................................................................................................... 10

    Soil Humidity............................................................................................................................. 10

    Wind Speed............................................................................................................................... 11

    Microcontrollers.......................................................................................................................... 12

    Prototype.................................................................................................................................... 12Major Setbacks............................................................................................................................ 13

    Section 3: Looking to the Future.................................................................................................. 14

    Webcam...................................................................................................................................... 14

    Website....................................................................................................................................... 14

    Control of External Systems.......................................................................................................... 15

    Weather Station.......................................................................................................................... 15

    wViewWeather............................................................................................................................ 15

    Other Ideas.................................................................................................................................. 15

    Conclusion................................................................................................................................... 16Appendix A - Programming Code................................................................................................ 17

    Appendix B - Computer Information........................................................................................... 22

    Appendix C - Sensors and Parts................................................................................................... 23

    Appendix D - Voltage Divider Maple Worksheet........................................................................ 25

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    3/26

    2 | P a g e

    Introduction

    For the Fall term of 2012, the COCC Physics 213 class was assigned a term-long project

    that turned out to be quite interesting and engaging. The project centered on COCCs

    greenhouse, and our portion was to come up with a way to automate many of the functions

    within the greenhouse. The idea was to gather sensor data from the interior and possibly

    around the exterior of the greenhouse, and then have systems act on that data. As an example,

    if the greenhouse interior is too warm, windows would automatically open up to create a cross-

    flow of air, or possibly the HVAC system would turn on to actively cool the interior. Another

    example would be to measure soil moisture and have an irrigation system turn on if the soil is

    too dry. With todays technology all of this is possible, even when limited by budget

    constraints.

    Section 1: Project Goals & DesignProject Goals

    Part 1: Data Acquisition

    Our primary goal was to implement a system that will monitor and log different

    environmental variables within the greenhouse environment. A list of the potential

    sensors that could be included follows. The reader should be aware that at this point

    we were just brainstorming and the reasoning behind wanting some of these may not

    be obvious. We felt that it was better to start with too many and eliminate those that

    we determined would not be needed.

    Interior room temperature Exterior temperature Interior humidity level Soil humidity/moisture level Oxygen level Methane level Carbon dioxide level Wind speed monitor Light level sensor IR counter at door (counts the number of visitors coming/going)

    Part 2: Website Integration

    The second part was to take the data acquired in Part 1 and display it on a

    website for all to view. Our wish was to incorporate this project within COCCs existing

    website.

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    4/26

    3 | P a g e

    Part 3: Control of External Systems

    Our last goal was to provide a means by which the data provided in Part 1 of the

    project can be used to actually control different external systems, such as heating,

    cooling, and irrigation. For example, if the data coming from the humidity sensor reads

    too low (data acquisition), then it would trigger the sprinkler system to come on for aset amount of time (control). This has almost unlimited potential.

    From the outset, we have gone forward with the intent of trying to reach the goals of

    Parts 1 and 2 in terms of a fully functional system. However, our goal for Part 3 was that of

    building a system that is capable of controlling external systems in the future, with no intention

    of actually controlling any systems at this time. We knew from the beginning that we would

    likely not have enough time to give Part 3 an honest try, and because of that, we leave it for

    future groups to ponder.

    General System Overview

    An overview of the system would begin with sensors in the greenhouse that monitor

    environmental conditions. These sensors would be connected to and read by a microcontroller

    that then sends the data to a computer for it to be logged, plotted and then displayed on a

    website. In order to construct the system, we would need to acquire a computer, a

    microcontroller, and either construct or acquire the sensors. We would also need to obtain

    software that could communicate with the microcontroller, as well as figure out how to display

    the data on a website.

    Voltage Divider

    Most microcontrollers have a few analog

    pins which can read and store voltage levels

    produced by a sensor circuit. Most of the sensors

    we picked out change their resistance as

    conditions change. We can easily extract data

    from these sensors by constructing a voltage

    divider circuit and connecting the analog pin of

    the microcontroller to the dividing point.

    If we subject the sensor to the extreme high and extreme low expected conditions, we

    can measure the high and low resistance values of the sensor with a multi-meter. We will

    already know the initial voltage at the power source. With that information, we can determine

    the voltage at the divide point by using the equation V=I*R.

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    5/26

    4 | P a g e

    To find the voltage at the divide, we would first determine the current draw of the

    circuit, given by

    . The Rtotal value, in this case, is the total resistance of the circuit

    (R1+R2). We would already know the voltage of our power source, so we calculate the current

    draw of the circuit, which we will call IC. Knowing the current draw of the entire circuit allows us

    to calculate the voltage drop at any point. The only interestingpoint in this circuit is wherewe would connect the analog pin of the microcontroller. The potential before R1 (to the left) is

    the same as the voltage source and the potential after R2 (to the right) is always at 0. In

    between, the voltage is given by the equation Vdrop=IC*R1. Using all of the above equations, we

    can come up with a formula for Vdropin terms of the resistance values like this.

    At this point, we would place the sensor in some situation, while measuring the

    resistance using a multi-meter. We measured the resistance of a photoresistor with a

    household light on and then placed a finger over it and measured again. Under normal light the

    resistance was 8.58 K and covered it was 46.3 K. During this test, R2 = 1 K. Since we know

    that the PICAXE has a 5 V output supply, we can calculate a voltage output at the analog pin

    connecting point using the equation we just derived above.

    We have a range of 4.5 V4.9 V at the drop point under these circumstances. When the

    PICAXE reads a value from its analog pin (ADC pin) the value it returns is relative to the

    reference voltage which, in this case, is 5 V. So, when the voltage at the drop point is closer to 5

    V, the ADC pin reads a small value. When the voltage drop is farther from the referencevoltage, the ADC pin reads a larger value. When we ran our experiment in the room, the PICAXE

    returned 100 for bright light and 16 for dim light.

    We plan to use this method to read data from our light and temperature sensors.

    Additionally, we wrote a Maple worksheet to aid in calculating the voltage drop values so that

    we could easily check to see if the output voltage would be too high for the microcontrollers or

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    6/26

    5 | P a g e

    not. This worksheet is included in the project files in Appendix D. It should be noted that with a

    higher value for R2, the rage of values at the drop point will be greater. This could be useful to

    obtain a higher degree of sensitivity, if the situation required it.

    RC CircuitFor other sensors, we can use an RC (resistor and capacitor) circuit, with one of the

    components being variable and the other constant. Here are the two possible circuits.

    We notice that we can use the capacitive time constant equation ( =RC ) to determine

    the value of the unknown/changing element if we know at least two of the variables. We

    already know the value of one of the components. If we can find a suitable value for , we can

    plug numbers into the equation and solve for the unknown/changing element. First, well need

    to understand some basic ideas about microcontrollers.

    A digital pin on an average microcontroller is capable of four different operatingconditions. In output mode, it is capable of being in either high or low position (on or

    off). In input mode, it can read either a one or a zero (on or off). There is a threshold

    voltage level, which differs from microcontroller to microcontroller, that determines whether

    the microcontroller will read a one or a zero. As an example, lets say that this threshold level

    on our PICAXE is about 2.5 V (which it isnt).Below this voltage, the PICAXE will read a 0.

    Above 2.5 V, it will read a 1.

    To determine the value of the variable element in the circuit above, the microcontroller

    first charges the capacitor by setting the pin to output and then turns it on ("high"). The RC

    circuit now has potential energy due to the charged capacitor. After a short period of time, the

    microcontroller will set the pin to input/low. Since both ground and the input pin now have the

    same potential, the energy has nowhere to flow. The capacitor can only discharge through the

    resistor, which is connected in parallel across its terminals. The microcontroller instantly starts

    a timer and counts how many units of time go by before the capacitor has discharged enough

    energy through the resistor that the RC circuit potential drops below the PICAXEs threshold

    and the microcontroller reads a 0 on that pin.

    Using the time value the microcontroller just calculated and the value of the fixed

    component in the circuit, we can use the capacitive time constant equation and solve for theunknown component. In our case, the unknown component could be the air humidity sensor,

    the soil humidity sensor, the light sensors, or almost any of the other sensors we are using.

    However, we will use this concept only with the air humidity sensor.

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    7/26

    6 | P a g e

    Additional Information

    Obviously when starting any project there is a tendency to think that you know what

    you will need. In our case, we made decisions about the hardware (specifically the

    microcontroller) based on the number of sensors that we thoughtthat we would need. In

    hindsight, buying a larger Arduino would probably have been a better choice from the outsetversus buying a smaller Arduino and adding the PICAXE. Future-proofing can be a difficult issue,

    especially when budget constraints play a role.

    Sources

    Megunolink: http://www.blueleafsoftware.com/Resources/EmbeddedSand/MegunoLink

    Arduino: http://www.arduino.cc/

    GardenBot Project: http://gardenbot.org/about/

    Picaxe: http://www.picaxe.com/

    Linux (Ubuntu): http://www.ubuntu.com/wView: http://www.wviewweather.com/

    http://www.blueleafsoftware.com/Resources/EmbeddedSand/MegunoLinkhttp://www.blueleafsoftware.com/Resources/EmbeddedSand/MegunoLinkhttp://www.arduino.cc/http://www.arduino.cc/http://gardenbot.org/about/http://gardenbot.org/about/http://www.picaxe.com/http://www.picaxe.com/http://www.ubuntu.com/http://www.ubuntu.com/http://www.wviewweather.com/http://www.wviewweather.com/http://www.wviewweather.com/http://www.ubuntu.com/http://www.picaxe.com/http://gardenbot.org/about/http://www.arduino.cc/http://www.blueleafsoftware.com/Resources/EmbeddedSand/MegunoLink
  • 8/12/2019 Final Report COCC Greenhouse IT Group

    8/26

    7 | P a g e

    Section 2: Building the System

    The Big Picture

    Sensors: The pieces of hardware that will take environmental readings (temperature,

    humidity, light...). These represent the most basic part of the design. Most are essentially some

    type of resistor that reacts to the change in the environment. For example, a heat sensor

    changes resistance as the heat changes.

    External Devices: Hardware that will control the environment (HVAC, Solar Angle ).

    These devices are what control the environment of the greenhouse and could be managed by

    the microcontroller.

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    9/26

    8 | P a g e

    Microcontroller: A small processor that can read (sensors) and control (External

    Devices) direct hardware. The microcontroller is kind of the half-brain of our system. Our

    microcontroller will take sensor readings and could potentially control the environment of the

    greenhouse.

    With this setup, we can control the environmental devices and get data from our

    sensors. Once on the computer, the collected data can be published to a website as well as be

    used to monitor and control the environment in the greenhouse.

    Host computerOne of the difficulties with this project comes with the communication between the

    microcontroller and host computer. There are very few programs that have been written with

    the goal of communicating with the Arduino and logging the data that it captures, with most

    successful systems having been written from scratch by amateur programmers for their

    personal use. Our original plan involved using a program called wViewWeather that requires a

    Linux operating system, but prior to acquiring the host computer, we found a Windows-based

    program called Megunolink that can communicate directly with and log data from the Arduino.

    To be sure that all bases were covered, we decided to dual-boot the computer with Linux just in

    case it did not work out. It would be prudent for future groups to investigate alternative

    options that may be available to them that do not exist at this point in time. A listing of our

    current hardware and software specifications is contained within Appendix B at the end of this

    report.

    WebsiteWe had thought that the website would be the easiest part of this project. While that

    may still be the case, it turned out to be much trickier than we first thought. In recent years,

    COCC has had what can only be accurately described as massive intrusions into its website and

    databases. Because of that, COCCs ITS department has greatly hardened its security around

    these resources and does not open them for anyone, at least not for a group of physics

    students. So we needed another plan. What COCC could provide was a static page that would

    display images linked from another website. And so the question became how do we take that

    raw data and turn it into an image of a plot?

    We examined a number of options, including writing a script that would dump the data

    into a SQL database, then using some other tool or possibly writing another script that would

    plot the data. This would not be a simple approach by any definition. After much searching, we

    found a Windows-based program called Megunolink. This program could talk directly to the

    Arduino, log its data, export it to a text file, plot the data, and export the plot into an image file.

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    10/26

    9 | P a g e

    Megunolink does exactly what we need it to do but there is one drawback. There is no

    automatic export function, so the data plot would need to be manually exported to be viewed

    on the website. We found a workaround for this using software called AutoIt. It is a scripting

    program used for automating the Windows GUI. With this software we will be able to save the

    plot to a networked folder and be able to display it on the web page.

    For the website itself, we decided against trying to integrate with COCC and instead

    chose to utilize Google Sites. It has many limitations, but in the end allowed us to get a

    functional website up quickly and easily. We set up the host computer with both Google Drive

    and Picasa, which run automatically after logging in. Both programs sync files from the PH213

    Greenhouse Project folder, which is located on a separate partition on the host computers

    hard drive. Picasa allows us to sync pictures in a certain folder up into a web album. This web

    album is easily embedded in other web pages. Google Drive allows us to keep a local copy of all

    project files on the computer, as well as backed up in the cloud.

    SensorsWhen we were brainstorming about possible sensors, we had

    many ideas which were mentioned in Section 1 of this report. We

    narrowed these options down by creating and sending a survey to the

    rest of the class to assess the needs of the other greenhouse groups. We

    would have liked to have more feedback than what we received, but we

    used what information we did receive and narrowed the list down to light level, indoor/outdoor

    temperature, indoor air humidity, soil humidity, carbon dioxide, and outdoor wind speed. With

    this list, we searched for the parts required and created a budget. We minimized the cost as

    much as we could by making many of the sensors ourselves. The final total came just under

    $94. The exact list is summarized in Appendix C.

    CO2and Temperature

    When our parts came in, we started assembling the sensors. The carbon dioxide,

    air humidity, and thermometer sensors are fairly easy components to use. However,

    because of some programming difficulties described

    later, we were unable to get the air humidity sensor

    working. With a couple basic components (i.e.resistors/capacitors/wires), we had the carbon dioxide

    sensor hooked up to the Arduino and the three

    thermometer sensors connected to the PICAXE. Both of

    these sensors send basic analog data so by connecting

    them to the analog pins on the microcontrollers, we were

    Air Humidity Sensor

    Carbon Dioxide Gas Sensor

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    11/26

    10 | P a g e

    able to receive sensor values fairly quickly.

    Light

    The other sensors required some assembly. For the light

    sensors, we thought about using a photoresistor (sometimes called a

    light dependant resistoror LDR) and a capacitor connected in parallel.

    By using the RC Circuit method, described in Section I, we would be

    able to read the resistance. However, we found it would be much

    simpler to wire the LDR in series with a resistor and use the Voltage

    Divider method, also described in Section I.

    Soil Humidity

    Both the wind speed sensor and the soil humidity sensors we built ourselves. We

    did some research and found that sensing soil humidity is as simple as sticking two wires

    in the ground and measuring the resistance across the exposed ends at the bottom. Thisworks because water conducts electricity, so when there is more water, the resistance

    drops and vise versa. We again used the Voltage Drop method by connecting the two

    probes in series with resistor, the probes being first in the series. The probes were

    constructed out of standard 14 gauge copper wire used in residential electrical wiring

    with the last couple centimeters of insulation

    stripped off. We stuck these probes in a block of

    foam in order to keep them equally spaced from

    one another. If the leads are at an angle from one

    another in the soil, then it will skew the readings.After soldering some smaller wires to the probes,

    we stuck the sensor in a freshly-watered potted

    plant, wired up the circuit and used a BASIC

    Stamp 2 microcontroller to read data over a

    couple hours.

    For the test, we actually used the RC Time

    idea, instead of the Voltage Divider method we

    plan on using for the actual setup, so the

    numbers will turn out different. However, the

    graph below shows how the soil dried out and

    demonstrates that the sensor actually works.

    Photoresistor

    DIY Soil Moisture Sensor

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    12/26

    11 | P a g e

    We planned to test the sensor to find ranges of values and assign a category to

    that range, as these sensors dont need to be precise. This is a hypothetical example but

    describes the concept we intended on implementing.

    Microcontroller Value Moisture Category

    400-500 Fairly Wet

    300-400 Adequately Wet

    200-300 Moist

    100-200 Dry

    Wind Speed

    The last sensor we were going to construct

    ourselves was the wind speed sensor. We based

    our ideas off of a project posted on Hackers

    Bench1. The underlying sensor is a hall-effect

    sensor, which senses significant changes inmagnetic fields. This device is used in automotive

    camshaft sensing and other similar settings to

    measure rotational speeds. A magnet is fixed on

    the rotating structure and is positioned so that it

    1http://www.hackersbench.com/Projects/anemometer/

    Hall-effect Sensor

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    13/26

    12 | P a g e

    passes by the hall-effect sensor as it spins. The hall-effect sensor will then output values

    to a microcontroller. In our setup, the magnet would most likely be glued to the shaft of

    the structure, which would be spun by the wind driving the metal ladles around.

    However, we were unable to build or test this device.

    MicrocontrollersWe chose to use two different microcontrollers: the Arduino and PICAXE. The Arduino

    serves as the brain while the PICAXE collects the data.

    They communicate through a serial data connection. For this link there is only one data

    line required for one-way communication. The PICAXE takes sensor readings and sends them

    over the serial bus while the Arduino just listens for the data. The data is formatted as follows:

    SensorType, SensorValue. These values are sent in an ASCII character format. Once the Arduino

    receives a complete set for any sensor, it then reformats the sequence to be useable by

    Megunolink. That format is: {SensorType, T, SensorValue}. In the future, the Arduino will need

    to control external devices, in which case there will also need to be a protocol in the code for

    sending the Arduino commands. This format could closely follow the current receive protocol.

    The code for both Arduino and PICAXE can be found in Appendix A.

    Prototype

    Our current prototype consists of the Arduino

    and PICAXE microcontrollers linked together. The

    PICAXE takes care of all the sensor data and then

    sends it to the Arduino. Below are the PICAXE pin-out

    diagram and a chart showing where to connect each

    sensor:

    T = Temperature

    L = Light

    SH = Soil Humidity

    AH = Air Humidity

    ID PIN SENSOR ID PIN SENSOR- +V - - 0V -- C.5 RX - B.0 TX1 C.4 SH 1 6 B.1 T 12 C.3 SH 2 7 B.2 T 23 C.2 SH 3 8 B.3 T 34 C.1 SH 4 9 B.4 L 15 C.0 AH 1 10 B.5 L 2

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    14/26

    13 | P a g e

    Once all the sensors have been wired onto the PICAXE it is time to connect the Arduino.

    Only 2 pins are needed for the communication from the PICAXE to the Arduino (Arduino to

    PICAXE would require 1 more pin). These two pins are ground (GND) and digital pin 2 (Used as

    RX line). The connection is simple:

    1. Connect the Arduino ground pin (GND) to the PICAXE ground pin (0V or #14).2. Connect Arduino digital pin 2 to PICAXE pin B.0 (pin 13).

    If everything was done correctly, you should have successful one-way communication

    from the PICAXE to the Arduino. The next step is to load the software onto the

    microcontrollers. A tutorial on how to do this can be found on the Arduino and PICAXE

    websites:

    http://arduino.cc/en/Guide/HomePage

    http://www.picaxe.com/Getting-Started/PICAXE-Manuals/

    The PICAXE (.bas) file and the Arduino (.ino) file can be found on the Google drive for

    this project. These files can be downloaded to their respective microcontrollers after the

    programming interface software is installed on the PC. Later on it might be necessary to add

    sensors and or external devices. There are many pins available on the Arduino for any external

    control devices but these devices must be integrated into the current serial protocol. First we

    will discuss how the sensor data is sent to the Arduino from the PICAXE. The data is encoded

    into two fields: SensorType, SensorValue. These are sent as ASCII characters in the following

    format:

    SensorType, SensorValue,

    For example if you received 2, 100, this would mean that soil humidity 1 sensor shows

    a value of 100. This data is interpreted by the Arduino and then reformatted to be sent to the

    computer. The format for the Arduino to computer is similar but slightly different:

    {SensorType, T, SensorValue}

    This format was chosen solely to work with Megunolink. In the future this could be

    changed to work with other monitoring programs or a self-built one. At this point in the project

    this works well since Megunolink can create plots which are great for data collection.

    Major SetbacksWe had a few major setbacks in this project, and would likely have made some different

    choices were we to do this again. The first challenge involved the hardware that we chose to

    use; specifically the microcontrollers. The Arduino is a widely-used open source microcontroller

    with many built in libraries and functions. The PICAXE is a more basic microcontroller that

    http://arduino.cc/en/Guide/HomePagehttp://arduino.cc/en/Guide/HomePagehttp://www.picaxe.com/Getting-Started/PICAXE-Manuals/http://www.picaxe.com/Getting-Started/PICAXE-Manuals/http://www.picaxe.com/Getting-Started/PICAXE-Manuals/http://arduino.cc/en/Guide/HomePage
  • 8/12/2019 Final Report COCC Greenhouse IT Group

    15/26

    14 | P a g e

    requires much more work to implement certain tasks. Our major problem was the link between

    the two and the fact that they were not designed to work together. They are coded in different

    languages and work differently, which posed a problem when trying to talk back and forth

    between the two. With enough time, we were able to eventually get the communication

    working but in hindsight probably should have done things differently. Instead we should haveeither used two Arduinos or a higher performance Arduino, eliminating the need of any

    controller to controller communication.

    A second setback involved the link between the microcontrollers and the website. We

    researched heavily on this subject and found a way to overcome this issue. Using Megunolink in

    combination with AutoIt we can get data plots published but a better method should be

    implemented in the future. Optimally we would like the data to be imported into a SQL

    database. This would make the data much more accessible to the world and portable if the

    website needed changing, and it could possibly make the data easier to extract when using it

    for control of external devices. Therefore it is our recommendation that future groups addressthis issue as one of their primary goals.

    Section 3: Looking to the Future

    As much as we wanted to, we could not accomplish all of our goals within the scope of a

    single COCC term. But we have put together a few ideas that will hopefully give future groups

    some thought in terms of what direction that they may want to take this project.

    Webcam

    The idea of a webcam in the greenhouse was there from the beginning, but because of

    budget constraints it was moved into the future ideas category at a very early point. It is

    something that, while not necessary to any control over the functionality of the greenhouse,

    could prove to be a valuable addition since a person can get a visual idea of what might be

    happening.

    Website

    One of the bigger difficulties with this project actually became integration with COCCs

    website. While we wanted this to become part of COCCs site for obvious reasons, using

    Google Sites proved to be a much easier solution for the short term. For the long term

    however, a more robust solution would be recommended. Utilizing a SQL database along with

    PHP scripting would be one popular current way to do this. This would open up so many

    avenues and possibilities in terms of how the data can be displayed and what tools can be used

    to do it. We realize that there are cost issues around hosting and domain name acquisition, but

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    16/26

    15 | P a g e

    we are all confident that overcoming those obstacles will not prove to be too difficult for future

    groups.

    Control of External Systems

    As mentioned earlier, we envisioned that we would leave this system ready for others tostart building the tools that would control external systems. One suggestion that we make is to

    utilize a second microcontroller to control external systems such as irrigation or HVAC. A

    second software application would likely be needed that would be capable of taking the data

    logged by Megunolink. External systems include (but are not limited to):

    HVAC - heating & cooling Irrigation Lighting Solar panel angle

    Weather Station

    Early on we looked closely at using a weather station instead of the Arduino to capture

    and log data. This would still be on the table, if the group wanted to use the existing Arduino

    card for control. The advantage to using a weather station is that it potentially opens up a lot

    of capability on the software side in terms of what can be logged and how the data can be used.

    There are many good models, and in our research it looked like the Davis brand was particularly

    well-thought-of. There is a lot of software out there built for use with weather stations (such as

    wViewWeather among others), but not so much for the Arduino. So this could be a viable

    solution for a group looking to move into the control portion of the project. There is a

    document in the Google Drive (Appendix B) that lists our research surrounding this idea.

    wViewWeather

    The original software that we considered is called wViewWeather. It is Linux-based and

    while it is a weather program, many, many people are using it to monitor greenhouses. While it

    could be potentially difficult to set up and does require Linux, it looks like it has the potential to

    be quite powerful for our purposes, and future groups may want to consider it. The reader

    should note that the host computer was set up as a dual-boot system with Linux (Ubuntu)

    installed, so outside of potentially needing updates it is ready to go in that sense.

    Other Ideas

    In trying to plan for the future, we came across a lot of ideas for how this project could

    evolve and be an asset to COCC. One such idea is that this project could branch into an actual

    weather station for the college. And while we could not think of any community-based project

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    17/26

    16 | P a g e

    that could come of any of this, it stands to reason that getting the community at large involved

    could lead to some interesting ideas.

    Conclusion

    In conclusion, this project will be of tremendous value to COCC. Going forward, it canobviously be used as a great teaching tool for many other disciplines outside of physics and

    could inspire more community involvement in the greenhouse itself. The culinary department

    is very interested in what is happening with the greenhouse, and there has also been interest

    expressed from the CIS department in terms of getting involved with some of the programming

    aspects.

    Overall, the three of us really enjoyed this experience. While it was frustrating at times,

    that is part of the programming experience, which is about problem solving. Getting the two

    microcontrollers to talk to each other or spending what seemed like weeks looking for software

    that we could use to get the host computer to talk with the Arduino as well as provide the

    other needed functions, were both examples of things that really frustrated all of us. But as any

    programmer knows, when you actually solve the problem and get things working, it is an

    incredibly gratifying experience.

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    18/26

    17 | P a g e

    Appendix A - Programming Code

    Arduino Code

    Receive and Display Data

    Receives data sent by the PICAXE and passes it on to the computer to be processed/stored.

    #include //Setup the software serial port on pins 2 and 3//Used for communicating with PICAXESoftwareSerial mySerial(2, 3); //Rx, TxString data[2]; //Array to hold the sensor type and valueString serialDataIn; //String to hold the received dataint counter; //Used to index data[]char inbyte; //Current character received by serialString sensorValues[2][10]; //Array of all our sensor readingsvoid setup()

    {// set the data rate for the serial portSerial.begin(9600);// set the data rate for the SoftwareSerial portmySerial.begin(9600);counter = 0; //Zero the counterserialDataIn = String("");

    }void loop() // run over and over{

    //Check if the counter has reached 2if(counter > 1){counter = 0; //Reset it

    }//If this is true the PICAXE is sending dataif(mySerial.available()){inbyte = mySerial.read(); //Read character from PICAXE//If the character is an integer...

    if(inbyte >= '0' & inbyte

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    19/26

    18 | P a g e

    data[counter] = String(serialDataIn);counter += 1; //Index the counter//If the counter > 1 we have received a complete readingif((counter > 1) & (data[0].length()

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    20/26

    19 | P a g e

    PICAXE-14M2 Code

    NOTE: All PICAXE code for this project should begin with the following statement:

    setfreq m16

    This is because the PICAXE will default to running at 4 MHz, whereas the Arduino operates at 16

    MHz. By using this command, we overclock the PICAXE to run at 16 MHz. With both

    microcontrollers running at the same clock speed, it is much easier to communicate between

    the two.

    Temperature Sensor

    'Temperature Sensor - Read and Display.bas#picaxe 14m2setfreq m16symbol TX = C.1symbol ID = b0symbol value = w1symbol T1 = b.1symbol LED = b.5 'LED has positive lead on pin "b.5" and is

    'connected to resistor running to ground.'This simply indicates when the PICAXE is'sending data, for debugging purposes.

    let ID = 1 'The ID value of the first temp sensor is "1"let value = 0 'Initialize the variable to store the sensor value

    low T1 'Make sure the temp sensor pin isn't sending'a voltage output.

    main:readadc10 T1,value 'Read the value from ADC pinvalue=value-158 'Adjust by calibration number

    'That calibration number is determined by testing'the output value and comparing it to the real'temperature in the environment.'CalVal = Value - RealTemp

    ID = 6

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    21/26

    20 | P a g e

    goto send 'Send to computer, one reading per linepause 100goto main 'Go get some more data! (I.E. do it again)

    send:high LEDserout TX, T9600_16,(#ID, ",", #value, ",") 'Send "ID" and "value"

    'formatted as an ASCII value'on TX pin at a 9600 baud

    rate'Comment the following line out if using pin B.0 as the TX pin. This'is used only if the PICAXE is connected to the computer for debugging

    'purposes.sertxd (#ID, ",", #value, ",", cr, lf) 'Since the PICAXE is running

    at'16 MHz, this data is sent to'the computer at a baud rate

    of'19200

    low LEDpause 1000goto mainLight Sensor

    This code is the programming platform for all the sensors that are read using a voltage divider

    concept. The list of sensors that use a voltage dividing circuit can be found in Appendix C.

    'Light Sensor - Read and Display.bassetfreq m16#picaxe 14m2 'Restrict PICAXE Type#terminal 19200 'Open terminal with selected baud rate

    'LDR (photoresistor) and 220 ohm resistor in series across'+V and ground. L1 pin connected at voltage divider.

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    22/26

    21 | P a g e

    Symbol L1=B.4Symbol TX=C.1Symbol ID=b0Symbol value = w0let ID = 9main:

    'The circuit described above is a voltage divider. Analog pin C.0'is connected to the junction between the LDR and the resistor.readadc10 L1,value 'Read the valueserout TX, T9600_16,(#ID, ",", #value, ",") 'Send "ID" and "value"

    'formatted as an ASCII value'on TX pin at a 9600 baud

    rate'Comment the following line out if using pin B.0 as the TX pin. This code'is used only if the PICAXE is connected to the computer for debugging

    'purposes.sertxd (#ID, ",", #value, ",", cr, lf) 'Since the PICAXE is running at

    '16 MHz, this data is sent to'the computer at a baud rate of'19200

    goto main 'Go get some more data! (I.E. do it again)

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    23/26

    22 | P a g e

    Appendix B - Computer Information

    Computer Specifications

    Hardware

    System: Dell Optiplex 745 CPU: Intel Core 2 6300 @ 1.86 Ghz Hard Drive: Western Digital WD800 80 Gb RAM: 2 Gb DDR2 PC-5300 / 333Mhz (2 sticks) Video: Radeon X1300 400 Mhz / 256 Mb Wireless: Linksys WMP54G PCI v4.1 Optical drive: DVD-RW

    Software (dual booted Windows Vista & Linux)

    OS: Windows Vista Home Basic SP2 32 bit OS key: MDRM9-RMHQ7-23G93-6DXYR-V4M44 Megunolink: Picaxe software: Arduino software: Linux: Ubuntu v12.04 LTS (username: Dell Computer, password:

    password)

    Greenhouse IT Accounts

    We set up a GMX email account for the group so that we wouldn't have to use any personalemail addresses for this project. With the GMX address, we were able to sign up for a Google

    account, which allowed us to use Google Drive for syncing documents/folders and Picasa for

    syncing pictures. Specific account information is provided below.

    GMX Email (https://www.gmx.com)

    Address/Username: [email protected] Password: 1027Trenton Security question: What city were you born in? Answer: Bend Contact email (if locked out of account): Ralph Tadday

    Google/Picasa

    Username: [email protected] Password: 1027Trenton

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    24/26

    23 | P a g e

    Appendix C - Sensors and Parts

    Organizational Schematic

    Devices Used

    NameNumber

    Used

    # of pins

    on device

    Circuit

    type

    Used

    with

    Arduino UNO 1Dig I/O - 14

    Alg In - 6

    PICAXE-14M2 1 10 I/O

    CO2 | GE Telaire T6004 1 12 Analog In Arduino

    LM34 Thermometer 3 3 Analog In PICAXE

    HS1101 Air Humidity 1 2 RC Time -

    Hall Effect - Melexis 90217

    (rotor speed)1 3 Analog In Arduino

    Photoresistor 2 2Voltage

    DropPICAXE

    Soil Probes 3 2Voltage

    DropPICAXE

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    25/26

    24 | P a g e

    Device Datasheets

    Arduino UNO

    PICAXE-14M2

    CO2 | GE Telaire T6004

    LM34 Thermometer

    HS1101 Air Humidity< http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/27920_HS1101-

    Datasheet.pdf >

    Melexis 90117 Hall Effect SensorBudget

    Sensor Distributor Obtained CountPrice

    ea.Shipping Subtotal

    Thermometer EBay X 4 $2.25 $0.00 $9.00

    Humidity EBay X 1 $3.98 $0.00 $3.98

    Carbon DioxideAll

    ElectronicsX 1 $10.00 $7.00 $17.00

    Photoresistor COCC X 4 $0.00 $0.00

    200-300 Ohm Resistor COCC X 4 $0.00 $0.00

    Stainless Ladle Dollar Tree X 4 $1.00 $0.00 $4.00

    Hall Effect Sensor EBay X 1 $1.63 $2.00 $3.63

    Arduino UNO Amazon X 1 $19.99 $0.00 $19.99

    PICAXE -14M2 Cana Kit Inc. X 1 $4.95 $6.50 $11.45

    PICAXE-14 Project Board EBay X 1 $3.41 $6.34 $9.75

    PICAXE Programming

    CableCana Kit Inc. X 1 $7.95 $6.50 $14.45

    Total: $93.25

  • 8/12/2019 Final Report COCC Greenhouse IT Group

    26/26

    25 | P

    Appendix D - Voltage Divider Maple Worksheet:

    >

    Voltage at the power source

    >

    Resistance of R1 at min (a) and max (b) values IN OHMS.

    NOTE: Include a decimal point in these two numbers. Maple will then

    calculate decimal numbers instead of leaving everything as a fractions.

    >

    >

    Value of R2 IN OHMS

    >

    Calculate the current draw for the high and low resistance circuit.>

    >

    Calculate the voltage drop for the high and low resistance circuit.

    >

    >