Introduction: Plantduino Greenhouse



UPDATE 7/9/11: The AC power fed relay has been replaced with a DC battery fed relay system as shown in step 10.

UPDATE: We have been selected as finalists in the microcontroller contest! Thank you for voting and rating. Thank you also for all the feedback on the safety of out relay system. We hope the new instructions are clear.We will be continually updating as we make progress on the new design.

Hello Everyone!

My name is Clover and I am in love with vascular plants and robots.


This summer I wanted to combine my two loves of plant science and engineering. Thus I am constructing my very own greenhouse in my backyard. I am an undergrad, and as any former student knows, this means I move around constantly, and I am not always around to take care of my vegetable garden. I love my plants but since I am moving back to school in July, and my family is unreliable, I need a way to make sure that they are taken care of. Enter Arduino!

I have constructed an automated watering and temperature system. This includes sensors that will turn the systems on only when needed. This is essential when the ever-changing New England weather demands some intelligence in watering and heating patterns.

This is my first project using an Arduino so I am using wonderful articles from MAKE and Instructables as very helpful templates. Already the Instructables, MAKE, and Ladyada blogs have been ridiculously helpful so, worry not biology nerds, you too can show the engineers just how awesome we are!

Step 1: Plant Science 101

One facet of this project is to grow my own vegetables and do some scientific experiments.
Warning! Science...
Sources: Much of this information/ images came from Northeastern Univesity Professor Donald Cheney's Plant Science lecture and the textbook Botany which is linked in the more information section.

Greenhouses
There are a lot of reasons that I am building a greenhouse. Greenhouses are a really cool way to grow larger and healthier plants faster and artificially extend the growing season. Greenhouses work by using a transparent airtight cover to trap in light and moisture to create a mini- ecosystem that is separate from the environment around the greenhouse. Heat is generated both from the sun’s rays that penetrate the greenhouse but do not escape as well as the trapped heat given off by the plants during their biological processes such as photosynthesis. This results in a very fascinating microclimate. This general idea of a layer of material trapping in heat and increasing the climate below is why sometimes global warming is called “the greenhouse effect” by people who like to oversimplify complicated climate phenomena.

Greenhouses can be made of glass or plastic. They create a controlled microclimate that makes experiments and procedures such as grafting or tissue cultures easier to perform. 

Plant Anatomy and Physiology
Vascular Plants (plants that have stems and roots) develop mostly from seeds (a lot of nonvascular plants like mosses and ferns develop from spores which work a little differently).  A seed consists of three types of tissues. The epidermal tissue is the outer layer for protection against the elements. This is usually embodied in the hard seed coat (Think the hard shell around sunflower seeds). The middle layer is called the ground tissue. The ground tissue is where photosynthesis takes place. The vascular tissue is in the very middle of the plant body and is where nutrients and water are conducted and stored.  The roots are the first thing to grow out of the seed. The roots are made up of the same tissues except on the tips of the root is a number of epidermal cells called the root cap that are made to die and be ripped apart as the root burrows through the ground. The roots provide water and nutrients to the plant. Sometimes nutrients can be stored in the roots such as in the case of root vegetables like carrots or turnips. 

The stem of the plant grows from what is called the coteledon in the seed. Longitudal growth is initiated by the apical meristem which is the primary growth bud. Lateral meristems are responsible for making the plant larger in diameter. There are two structures called the auxillary buds that grow on both sides of the main meristem. In case the axial bud is cut off for some reason the surrounding auxillary buds take over and grow the plant in a new direction. This is how pruners reroute tree growth by cutting off certain branches. 

NOTE ABOUT WEEDING: This anatomical knowledge is very useful when you are weeding- particularly with grass. Grass is a special category of plants called a monocot. With grass the meristem is on the bottom of the grass blade which is why it grows even if it is cut. So do not just rip out the grass blade but make sure you get at the root system too. 

Gardening: Plant Nutrients

Even though most plants grow well with just old fasion dirt and water there are a lot of other things that they need to grow and produce good fruits. These are broken up into two catagories: Macronutrients which take up more then .5% of a plant's dry mass and Micronutrients which are only present in trace amounts. Some macronutrients that are essential for all plants are Nitrogen, Magnesium, and Sulfur . Sulfur is in proteins and vitamins. Magnesium is in the chloraphyll which are involved in photosynthesis.  All of these are found in the soil. Plants are also about 45% Carbon which comes from the CO2 in the air and 45% Oxygen which comes from water and air. Some micronutrients that plants need are Boron, Chlorine, Manganese, Iron, Copper, and Zinc. All of those are naturally occuring in soil but the most important one is Iron. Iron deficiencies lead to a yellowing of the leaves. Fertilizers usually provide all the minerals needed for a plant to survive. The ratio of Nitrogen, Phosphorus, and Potassium are listed in that order on most fertilizer bags in ration form. For example: 10:20:10= ratio of N:P:K. 

Photosynthesis
Photosynthesis is how plants turn sunlight into sugars. The chemical equation is 6CO2 +6H2O --> sunlight--> C6H12O6 +6O2. Photosynthesis happens in two stages: The dark and the light. First is the light stage where , as the name implies, the sunlight is needed. What happens is electrons are taken from the water molecule and excited in photosystem 2. Then the electrons are transported down what is called the electron transport chain. This chain is nothing more then a series of oxidation and reduction reactions that progressively bring the electrons down into a less excited state. Once the electrons hit photosystem 1 they are excited again and go down another smaller electron transport chain. While the electrons are moving from a more excited state to a less excited state they are also turning a substance called NADP+ (Nicotinamide adenine dinucleotide phosphate) into NADPH. This is used in the dark stage, also known as the calvin cycle. The Calvin Cycle is a series of modifications starting with a reaction with starting material RuBP (Ribulose bisphosphate) and Carbon dioxide using a series of enzymes and redox reactions. It is called a cycle because after the sugar is produced the starting material RuBP is again synthesized. For every round of the carbon cycle there is 1 sugar derivative output and 3ATP (the source of our life's energy). So it takes 6 rounds of the Calvin Cycle to create one glucose molecule. There are a lot of plants that utilize different variations of this cycle.

pH
Part of my experimentation is to come up with a low tec pH monitor for the soil. pH measures relative acidity by taking the log of the concentration of hydrogen molecules present. pH is measured on a 14 point scale with 1 being very acidic and 14 being very basic. Water is neutral or 7. I measured the acidity of my soil with an at home pH kit that I bough on amazon for $5. The acidity of my soil was about 6.5 which is perfect for the types of plants I am growing (strawberries, peas, basil, broccoli). If there is a problem with your plants and the fertilizer is fine I would suggest checking the pH. 


Step 2: Build a Garden/ Plant Seeds

My garden is in  a raised bed. Raised beds are when you plant your garden in a wooden frame that is above ground level. The nice thing about raised beds is that they are easier to maintain because they can block weeds. Also, you fill it with whatever soil you have instead of the soil that you are blessed to be living on. In the case of my New England house, the infamously horrible soil makes a raised bed the obvious choice. 

Building a Raised Bed
To build a raised bed, dig out a patch of land the size you want your garden to be. Then build a wooden frame that fits the perimeter of your garden. A cool trick is to put some burlap or pebbles on the bottom-most layer of your garden. This way the grass won't grow back up through your garden. Putting down a bottom layer is not necessary and I did not do that in my garden. However, if you have the time, it will save you a lot of work later. 

I have provided a link to a more step by step format for more specific details. I am doing this because the making of the garden was done the previous year before the greenhouse project. Here is a great website for these steps:
http://www.thisoldhouse.com/toh/how-to/intro/0,,1615067,00.html  (this provides instructions for a slightly more elaborate garden than I built). 

Soil
The mixture of soil that I use is a mixture of garden soil and peat moss. I also mix in some miracle grow potting soil. Dump a large lump of each soil into the garden and then mix it up with a large shovel or trowel. After it is mixed, spread it out over your garden evenly. This would be a good time to test the pH of your soil mixture. It should be between 6.5-7.5. You can test this by purchasing a pH soil tester. I bought the Luster Leaf 1612 Rapitest pH Soil Tester from Amazon for about $5. It is not the most precise way to measure pH, but it gives you a nice range. Also, this test has a chart with what to add if your soil is too basic or acidic. 

Seed Planting
Planting seeds is very easy. In all cases, read the back of the packet your seeds came in. There should be a chart with depth and spacing requirements for that particular plant. Absolutely follow those spacing requirements or you are going to have  a lot of trouble down the road. Also, only plant one or two seeds per spot. I made the mistake of planting a bunch of strawberry seeds in one plot (the seeds were so small!!!) and I have about 10 tiny strawberry plants that can't get any bigger because they are entangled in each other and there are not enough resources for them all.  Right after you plant them, make sure the soil is thoroughly moist. Watering is important and for most plants, should be daily. However, the plants are delicate, especially when they are developing stem systems, so water carefully.

Step 3: Build a Greenhouse: Step 1 Materials

-two 10 foot long, ½ inch diameter PVC pipes

-three 40 inch long, ½ inch diameter PVC pipes

-Roughly twenty-five 6 inch long Zipties

-at least 9 by 12 feet painters clear painter’s plastic tarp 3mm thick

-Waterproofing Tape  

-Duct Tape

-Industrial VelCro 

Tools:

Hacksaw

Scissors

Staple Gun

Measuring Tape

Step 4: Build a Greenhouse: Step 2 Build the Frame

1) First we measured my garden which is about 1 square meter (tiny I know). Then we used complex integration and approximation to measure the arc length of the frame. Just kidding. We just used a tape measure to approximate and then just used the 10 foot measurement that the PVC came in.

2) We used the hacksaw to cut the ends of the PVC pipe at an angle so that they could be easily stuck into the ground. To do this, start about 3 inches from the bottom of the pipe and cut away from yourself at an angle.

3) Stick both ends of the pipe into the ground at opposite sides so that it makes a nice arc. We placed one arc behind and one in front of the garden. We measured three inches to the left and then another three inches away from the garden corners.

4) Next we placed one 40 inch PVC across the top in the center of the arc. We duct taped the ends to the arc.


Step 5: Build a Greenhouse: Step 4 Lay the Plastic

Next we cut a large portion of the plastic to cover the frame. In all honesty we gestimated the size. Once we draped it over the greenhouse, we secured it with zipties and cut off the excess on either side. We needed two people for the zipties because one person had to keep the side taught the entire time. We secured the plastic to wooden frame of the garden using the staple gun.


Step 6: Build the Greenhouse: Step 5 Add the Back and the Door

To make the end pieces we cut a small piece of the plastic and then draped it over the frame making sure it could touch the ground. Then we simply just ziptied it to the PVC frame, making sure the plastic was held firm.

As we ziptied the back wall we held the plastic as tight as we could. For the front, we left some slack so that the doors could close all the way. 

Finally we cut a slit in the front to make the doorway and secure the tear with pieces of duct tape. 

We lined the duct tape with the industrial Velcro so that the door can be opened and closed securely. 

Step 7: Build the Greenhouse: Step 7 Make It Airtight/waterproof

To seal the sides of the greenhouse, wrap the waterproofing tape around the perimeter of the frame so that there are no openings in the plastic. 

Step 8: Build a Greenhouse: Step 8 Dig a Trench

Around the perimeter of the garden dig up the grass so that it does not encroach on the garden. I filled the trench with blue stone. Then we dug another small narrow trench so that we could put the wires that connect the sensors to the birdhouse underground. We needed to do that because when my dad mows the lawn any loose wire can be easily caught. We put the wires through PVC pipe to protect them from any sort of natural damage (insects, water, etc). We then buried the PVC pipe in the ground from the deck to the greenhouse (about a yard total). 

Step 9: Watering System: Step 1 Materials

Parts:

Outlet box

Outlet (2 plugs for water and heat or four plugs for water, heat, lighting, and fan)

120v wall plug (can be hacked from pretty much anything. This one was taken from some computer speakers.)

14 gauge wire

5 volt relays (same number as number of individual outlet plugs)

22 gauge wire

solenoid valve

wall wart for solenoid valve (ours was 12 volts)

Screwdriver

Wire cutters/ Strippers

Glue Gun

For testing:

Arduino

Breadboard

(optional) small LED light

Step 10: Watering System: Step 2 Build a Relay Box

Originally the valve and relay system was controlled by AC power from the wall. The breadboard layout below shows how to connect the valve and relay system using dc power from a battery. The battery is over 12v and the regulator is a 12 volt regulator. The solenoid represents the solenoid valve. The relay is activated by 5 volts. The 12 volts coming out of the regulator go to the arduino power and the relay. The blue wires coming from the relay attach to the arduino ground and a digital pin which control the relay state.

Step 11: Watering System: Step 3 Connect the Valve

You need to connect the valve to the relay box so that the valve will receive power and control the flow of the water. To do this you connect the valve to a 12 volt wall wart. The wall Wart can then be directly plugged in to the relay box.

1) cut the jack of the wall wart off with wire cutters
2) strip back the plastic to expose the red and black power and ground wires
3) Strip the black and red wire so that they can wrap through the holes in the valve solder terminals.
4) Solder the red wire to one of the terminals and the black wire to the other terminal.
5)Test to make sure it works
6) Hot glue the solder joints so that the electricity won't electrify things it's not supposed to.
7)Plug the wall wart into the relay box!

Step 12: Watering System: Step 4 Moisture Sensors

I first soldered a wire to each of two galvanized nails. This took a couple of tries but the secret is to scrape off some of the galvanized coating from where you want to solder with a knife. This helps the solder stick to the nail.

Next, hook the nails up to the breadboard and the breadboard to the arduino. Check out the pictures for a diagram. We connected the nails to analogue input 0 and used the pin 13 LED as an output.

 

Then be joyful and celebrate.
 

Step 13: Watering System: Step 5 Write the Code

int moistureSensor = 0;
int moisture_val;


void setup() {
Serial.begin(9600); //open serial port
pinMode (13, OUTPUT);
}

void loop() {
moisture_val = analogRead(moistureSensor); // read the value from the moisture-sensing probes
Serial.print("moisture sensor reads ");
Serial.println( moisture_val );

delay(1000);
if (moisture_val < 600){
  digitalWrite (13, HIGH); //soil is too dry- turn on LED
}else{
  digitalWrite (13, LOW); // soil is saturated- turn off LED
}

}

Test the nails using dry, perfect, and water saturated soils. You will want to calibrate your soils to your own watering habits and garden needs. These numbers are completely dependent on your own nail specs though.

Step 14: Watering System: Step 6 Bring It All Together

We had to buy a nozzle that connected the solenoid valve to the hose. The irrigation drip tubing we bought at home depot attached perfectly to the other end of the valve. You can make your own irrigation tubing by buying some plastic or rubber hose and poking holes into it. Plug the 12V wall wart into the relay box. Make sure you use the socket that is connected to the right arduino ports. For our relay box the top outlet goes to the bottom set of wires and the bottom outlet goes to the top set of wires. 

Step 15: Plantduino: Step 1 Materials

1. perfboard

2. ribbon cable

3. 16 by 2 lcd

4. 10k potentiometer or patience and a resistor

5. female barrel jack

6. 7805 power regulator

7. (2) 10uF capacitors

8. Atmega 328 with arduino bootloader preloaded onto the chip

9. 28 pin dip socket

10. (7) 2-pin 5mm pitch screw terminals

11. (4) diodes

12. 22 gauge solid core wire

13. ftdi serial to usb break out board

14. 16 MHz crystal

15. (2) 22 pF (that’s picofarad not microfarad) capacitors

16. 100 nF capacitor

17. (4) 10k resistors

18. (11) female pin headers

19. (17) male pin headers

20. also, breadboards never hurt

(you will also need sensors but these are not technically part of the plantduino)

Step 16: Plantduino: Step 2 Schematics

We have broken down the schematics so you can check them out piece by piece. If you can't make out the images, go to revoltlab.com and check out the larger images. These schematics were made with Fritzing! Fritzing is a great opensource schematic/ pcb/ and breadboard layout program.

The text in each schematic is reproduced below:

Picture 1 (Analog sensor) Connect pins 23, 24, and 25 to screw terminals as shown. These pins are the analog pins used for the sensors (moisture, temperature, and light). R1 is 10k ohms. Do not connect all the sensors to the same screw terminal. Three terminals each with two sockets are needed to connect all three sensors.

Picture 2 (Crystal/ Timing) The crystal and capacitors connect to pins 9 and 10 as shown. These will help the microcontroller keep proper time. C1 and C2 are 22pF. The crystal is 16Mhz.

Picture 3 (LCD pins) The power and ground on the left of the LCD in this diagram supply power to the back light. DB7, DB6, DB5, and DB4 communicate with the microcontroller to display text. Vo is the contrast pin. You will have to experiment with different resistors to see which gives your LCD the best contrast. You can also use a 10k potentiometer if you wish. The LCD will be connected to arduino pins 7, 8, 9, 10, 11, and 12 which are shown here on the atmega pins 13 through 18.

Picture 4 (Power Regulation) The power plug is supplying 9 volts to the 7805 power regulator. 9 volts goes "IN". The ground of the 9 volt power plug goes to the middle "GND" pin of the regulator. "OUT" supplies 5 volts to the microcontroller. C1 and C2 both have their negative leads connected to ground. The power plug and microcontroller share the same ground. C1 has its positive lead connected to 9 volts. C2 has its positive lead connected to 5 volts. Both C1 and C2 are 10uF.

Don't forget to connect the power and ground on the other side of the chip!

Picture 5 (Programming pins) The arrows above are male headers used for reprogramming the board. 8 is ground. 7 is 5 volts. 3 is TX. 2 is RX. 1 is reset. R1 is 10k ohms. C1 is 100nF.

Picture 6 (Relay pins) Connect pins 5, 6, 11, and 12 to their own screw terminals as shown with pin 5. These correspond with arduino pins 3, 4, 5, and 6 and will be used for controlling the relays.

Step 17: Plantduino: Step 3 Assembly Tips and Tricks


For a full tutorial on making a generic arduino clone, check out the perfduino . The plantduino is an customized version of the perfduino.

Tip #1 : Breadboard before you solder! Make sure your parts can work before you melt them to metal.

Tip #2 : Go through the pictures and read the tags. 

Tip #3 : I chose a large perfboard for this project because of all the external connections. Make sure you leave room in your layout for the LCD.

Tip #4 : Analog inputs are on the right. Digital outputs are on the left. I did this because the analog pins are all on the right of the atmega chip.

Tip #5 : Start with the power supply. This will determine where you place other components.

Tip #6 : While soldering the male headers to the LCD ribbon cable, keep them set in the female headers. This will prevent them twisting around in the heated plastic.

Tip #7 : While every component is important, the 100nF capacitor and 10k resistor coming from the reset pin (pin 1) are absolutely vital! Your plantduino will not program without them!

Tip #8 : Connect the LCD wires on the back side of the board! It will save a lot of space and make it possible to examine your board for more than five seconds without losing normal human cognitive ability.

Tip #9 : This power jack will save you space. I got the large one for the sake of shipping costs.

Step 18: Birdhouse: Creation and Installation

We bought a birdhouse from Michael's Craft Store to put all of the electronics in. You can use whatever enclosure you feel works for your home or environment. Here is what we did.
Materials: 
1 wooden house cd holder- unpainted- Micheal's Craft Store
Oil paint
Paintbrushes
Drill
Screwdriver
Nails (any size)
Screw (any size)
Hacksaw
Plywood Sheet (16 inches by 14 inches)- from Micheal's craft store
Hinges- bought from home depot
Magnetic door clasps- bought from home depot
Clear Plastic Portfolio envelope

Steps:
1) Paint the Birdhouse: We used oil paints because they are harder for the rain to wash off. Be warned, they take a very long time to dry. 
2) Cut the doors: Using a hacksaw I cut the doors out of a piece of plywood. 
3) Attach the hinges- I bought a pair of really small hinges at home depot. The screwed on side of the birdhouse and then on the side of the doors. 
4) Glue on the Magnetic Door Clasps- The magnetic clasps keep the doors shut. However, the magnets are very strong. You can increase and decrease the force of the magnet by limiting the exposure the magnet and the clasp have. We just hot glued these two pieces on. 
5) Weatherproof the birdhouse- We used the plastic from a clear plastic portfolio envelope   to coat the windows and other exposed areas of the birdhouse. 
6) Cut holes- We used a drill to drill two holes into the bottom of the birdhouse and two in the second story floor. The holes on the bottom floor of the birdhouse are for the wires from the nails and the thermistor in the greenhouse that are connected to the Garduino microcontroller. The wires connecting the relay box to the micro-controller go through there too. 
7) Nail the birdhouse to a sturdy spot- We nailed the birdhouse to the support beam on my deck. We nailed the bottom and the back to make sure it won't blow away.
8) Put the relay box into the birdhouse. We put it into the bottom floor. We strung the power cord through one of the windows of the house. 
9) Put the microcontroller into the box. We put it in the top floor. 

Step 19: Creating the Birdhouse Motherboard

Step 20: Video

http://youtu.be/hdojUHjg35g

Step 21: Final Thoughts/ Additional Reading

Adding Light and Temperature regulation:
This link shows how to include photoresistors and 10K  thermistors as analog inputs. Using these tools you can regulate the light and temperature of the greenhouse.

For more information:
On watering systems:
Garduino project in Make Magazine

On plant biology/ botany
My plant biology textbook website

On electronics
Sparkfun
Make Magazine


On Arduino:
Arduino playground and forums  
Adafruit