Vol. 18: The Garduino Garden Controller
Geeked-out gardening: use a microcontroller and simple sensors to give plants exactly the water and light they need.
By Luke Iseman
Photos by Luke Iseman, Michael T. Carter, Ed Troxell
Illustrations by Gerry Arrington, Timmy Kucynda
Digital Edition
SUBSCRIBERS:Read this article now in your digital edition!
Get Make:
Subscribe to MAKE and get the best rate!
+ Downloads & Extras:
Most Recent Run-Time Code (updated May 2, 2009)
//include the datetime library, so our garduino can keep track of how long the lights are on #include//define analog inputs to which we have connected our sensors int moistureSensor = 0; int lightSensor = 1; int tempSensor = 2; //define digital outputs to which we have connecte our relays (water and light) and LED (temperature) int waterPump = 7; int lightSwitch = 8; int tempLed = 2; //define variables to store moisture, light, and temperature values int moisture_val; int light_val; int temp_val; //decide how many hours of light your plants should get daily float hours_light_daily_desired = 14; //calculate desired hours of light total and supplemental daily based on above values float proportion_to_light = hours_light_daily_desired / 24; float seconds_light = 0; float proportion_lit; //setup a variable to store seconds since arduino switched on float start_time; float seconds_elapsed; float seconds_elapsed_total; float seconds_for_this_cycle; void setup() { //open serial port Serial.begin(9600); //set the water, light, and temperature pins as outputs that are turned off pinMode (waterPump, OUTPUT); pinMode (lightSwitch, OUTPUT); pinMode (tempLed, OUTPUT); digitalWrite (waterPump, LOW); digitalWrite (lightSwitch, LOW); digitalWrite (tempLed, LOW); //establish start time start_time = DateTime.now(); seconds_elapsed_total = 0; } void loop() { // read the value from the moisture-sensing probes, print it to screen, and wait a second moisture_val = analogRead(moistureSensor); Serial.print("moisture sensor reads "); Serial.println( moisture_val ); delay(1000); // read the value from the photosensor, print it to screen, and wait a second light_val = analogRead(lightSensor); Serial.print("light sensor reads "); Serial.println( light_val ); delay(1000); // read the value from the temperature sensor, print it to screen, and wait a second temp_val = analogRead(tempSensor); Serial.print("temp sensor reads "); Serial.println( temp_val ); delay(1000); Serial.print("seconds total = "); Serial.println( seconds_elapsed_total ); delay(1000); Serial.print("seconds lit = "); Serial.println( seconds_light); delay(1000); Serial.print("proportion desired = "); Serial.println( proportion_to_light); delay(1000); Serial.print("proportion achieved = "); Serial.println( proportion_lit); delay(1000); //turn water on when soil is dry, and delay until soil is wet if (moisture_val < 850) { digitalWrite(waterPump, HIGH); } while (moisture_val < 850) { delay(10000); } digitalWrite(waterPump, LOW); //update time, and increment seconds_light if the lights are on seconds_for_this_cycle = DateTime.now() - seconds_elapsed_total; seconds_elapsed_total = DateTime.now() - start_time; if (light_val > 900) { seconds_light = seconds_light + seconds_for_this_cycle; } //cloudy days that get sunny again: turn lights back off if light_val exceeds 900. this works b/c the supplemental lights aren't as bright as the sun:) if (light_val > 900) { digitalWrite (lightSwitch, LOW); } //turn off lights if proportion_lit>proportion_to_light, and then wait 5 minutes if (proportion_lit > proportion_to_light) { digitalWrite (lightSwitch, LOW); delay (300000); } //figure out what proportion of time lights have been on proportion_lit = seconds_light/seconds_elapsed_total; //turn lights on if light_val is less than 900 and plants have light for less than desired proportion of time, then wait 10 seconds if (light_val < 900 and proportion_lit < proportion_to_light) { digitalWrite(lightSwitch, HIGH); delay(10000); } //turn on temp alarm light if temp_val is less than 850 (approximately 50 degrees Fahrenheit) if (temp_val < 850) { digitalWrite(tempLed, HIGH); } }
+ LINKS
Garduino Garden Controller on Make: Projects
Arduino Duemilanove
ProtoShield (Circuit Board for Arduino)
Omron Relays
1N4004 Diode
220 resistor (sold in bags of 100, or just buy a few at RadioShack)
LED (or try RadioShack)
Photocell
10k thermistor
22-gauge solid-core wire (100' roll, or buy assorted colors at RadioShack)
10k resistors (sold in bags of 100, or just buy a few at RadioShack)
Parts list
Mikey Sklars version of a grow light made from red and blue LEDs
Arduino development application
Arduino Tutorial
Harbor Freight
Jameco
Maker Shed
» MAKE: NOISE — Discuss this article
You must be logged in to post a talkback.[ Display full threads] [ Newest First]
Showing messages 1 through 13 of 13.
- relay pins
You must be logged in to reply.
page 99 the relay pins are mixed upPosted by xboogerx on May 26, 2009 at 19:00:51 Pacific Time
- DateTime Library
You must be logged in to reply.
You need to download the DateTime library and extract the contents of the zip file into the hardware\libraries folder, then use
#include <DateTime.h>Posted by mtnbiker on June 11, 2009 at 21:01:27 Pacific Time
- Light problem
You must be logged in to reply.
Any idea why my lights would turn on during a digitalwWrite(light, LOW);??And then turn off with a HIGH? I have changed the Relay pins, and not sure what is going on. Ideas? Thanks.Posted by mtnbiker on June 11, 2009 at 21:16:09 Pacific Time
- I think the wiring diagrams are wrong
You must be logged in to reply.
Step 3 (Page 95) has the two left-most columns on the breadboard connected to 5V and GND. Steps 5 and later have them connected to GND and VIN.
I haven't actually tried the circuit yet, but I the the setup in Step 3 is the correct one; looks like the later ones are an error, since they differ from Step 3 and also seem to differ from what the text is telling you to connect.Posted by morrildl on June 14, 2009 at 14:42:55 Pacific Time
- Nails
You must be logged in to reply.
how far apart are people putting their nails to get the correct resistance?Posted by esqueleto on June 20, 2009 at 11:37:10 Pacific Time
- Earthbox?
You must be logged in to reply.
Anyone tried this with an Earthbox? It seems like it might be just as easy to keep the Earthbox full, as the feeder bucket. And then you can make do with only the photodiode and grow-light relay...Posted by morrildl on June 29, 2009 at 21:44:09 Pacific Time
- "First green"!
You must be logged in to reply.
Here is a link to my "build diary" on YT:
http://www.youtube.com/watch?v=PjwHKSD9ww8
This is the more interesting second entry. I've got basil shoots!Posted by morrildl on July 30, 2009 at 20:15:10 Pacific Time
- Aquaponics
You must be logged in to reply.
Hi,
Anyone tried to use the garduino as part of a hydroponics system. I am contemplating doing this and would appreciate any advice.
ThanksPosted by RonanOD on October 24, 2009 at 16:25:40 Pacific Time
- my flourecent light won't turn on!!
You must be logged in to reply.
i am trying this system as a component for a science fair project (testing if a plant would grow better in a human controlled garden vs. an arduino powered one) I am using an array of springs as my circuit board, i wired every thing correctly, but when i test my control over my florescent light, it doesn't turn on! i need to start working soon and am running out of ideas.Posted by circuit dude on November 08, 2009 at 15:01:55 Pacific Time
- Watering code error
You must be logged in to reply.
During testing it was getting stuck in the watering "while" loop. It can't tell when the soil gets wet because the moisture_val is not being updated with-in the "while (moisture_val < 850)" loop. I just changed the if and while statements to contain "analogRead(moistureSensor)" instead of "moisture_val". Another option would be to put a "moisture_val = analogRead(moistureSensor);" statment inside the while loop. Please update the code.
This is the code I am referring to:
// read the value from the moisture-sensing probes, print it to screen, and wait a second
moisture_val = analogRead(moistureSensor);
//turn water on when soil is dry, and delay until soil is wet
if (moisture_val < 850)
{
digitalWrite(waterPump, HIGH);
}
while (moisture_val < 850)
{
delay(10000);
}
digitalWrite(waterPump, LOW);
Change the while loop to:
while (moisture_val < 850)
{
delay(10000);
moisture_val = analogRead(moistureSensor);
}
Posted by JoshTW on January 03, 2010 at 23:59:58 Pacific Time
- Moister value stops code
You must be logged in to reply.
I'm having the same problem as JoshTW (Posted by JoshTW on January 03, 2010 at 23:59:58 Pacific Time). If the moisture reading goes below the set value the code stops running. I tried the JoshTW's fix; but either I've applied it incorrectly, or it doesn't work. Can anyone help? Thanks in advance for helping a newbie--this is my first foray into programming & electronics.Posted by AwnMan on January 24, 2010 at 07:09:26 Pacific Time
- Relay trips GFCI
You must be logged in to reply.
Hi,
I set up the circuit as shown, and when my two nails are apart (below 850) the pump runs, then when I touch the nails together and the value goes above 850 the relay shuts the circuit off and the pump stops. However, when that happens the GFCI trips and when I pull nails apart the pump doesn't begin again.
Can anyone provide guidance as to why this might be happening.
Right now I'm running the setup dry, with no water to test (if this burns out my $10 pump, so be it, it can be replaced).
Any help appreciated, thanks.
-RPosted by Gorpomon on June 14, 2010 at 07:28:28 Pacific Time
- It Works!
You must be logged in to reply.
I have built this project for a science fair and it works great! Instead of using several extension cords I wired the buses of an extension cord to work the same way. It keeps it very neat and I also added an uninterrupted plug in the cord for the arduino so I don't have to use batteries or find another outlet. Thanks for the idea Luke! (I also added a heat lamp to maintain temperature.)
Thanks a ton,
Eric B.Posted by robot452 on January 28, 2011 at 19:18:39 Pacific Time
|
Showing messages 1 through 13 of 13. |
Join the conversation -- every MAKE article has an online page that includes a place for discussion. We've made these RSS and Atom feeds to help you watch the discussions: subscribe.










