Growduino smart garden

I've been toying with so many ideas of things to automate, but with the long days and an approaching 2-week trip and two young plants at home, I started working in earnest on a garden control project last night. "Growduino" seemed like the obvious name... ;D

This is the simplest possible version-- just an automated watering system, with the nutrient solution pumped up from a reservoir in the tub with a submersible pump.

Here's a shot on Flickr:

from the description:

The "growduino" smart garden project will, um, grow to include more sensors and controls, but watering on a schedule seems like a good starting point since I'll be leaving the rig alone for 17 days starting Friday.

The program's main parameters are pump period (time between pumps) and pump duration.

Still need to transplant the subjects (heirloom tomato and Artemisia pontica) and add medium, mount the pump, rewire the pump power with ground and a fuse (ahem), install drip lines, mount the electronic bits, and figure out nutriuent and timing parameters for tasty, healthy results.

Sensing plans: soil/medium moisture, interior and exterior temperature and humidity, nutrient level, nutrient pH, sunlight intensity, sunlight direction, solar panel output, battery charge, CO2 level, what else?

Control plans: shade raising & lowering, vent fan, camera, data logging to web site, battery charging, garden and/or reflector and/or solar panel aiming (sun-dependent), CO2 scrubbing (greenhouse gases for greenhouses!), what else?

Note: the "plans" are in (roughly) increasing level of complexity/desirability-- not sure about aiming or CO2 scrubbing (?!), but moisture, temperature, humidity, and light sensing are definites, as are controlling a vent and logging data to a web page.

I'm also working on a simple interval timer to control a sprinkler valve. It had not occurred to me that the same device could also turn on a small pump! We like to grow our own garden starts in the spring but end up killing half of them due to lack of watering! Can't wait to use this next spring.

I figured I had the code nailed down, but it randomly goes into a bad state where it is turning the valve on and off as rapidly as it can. This is not good! I have to get in there and find that bug!

I'm still deciding how to switch the 24V A/C on and off. It's only 24V and fairly low current so there are several options. Relay or triac. Have you decided how you are going to switch your pump on and off?

Yep, I used a relay and it's all set-- finished it last night (er, early this morning...:wink: and uploaded a few pics:

The circuit is pretty much what I found here, with obligatory blinkenlights:

Here's the code it's running-- I'll probably change the timing values before taking off tonight:


  • Trigger a relay

int gPin = 3; // green LED
int bPin = 4; // blue LED or red LED? red looks better
int pumpPin = 2; // relay

unsigned long time;
unsigned long lastPumpTime;

int pumpPeriodHours = 6; // hours between pumps
int pumpPeriodSec; // seconds between pumps

int pumpDurationSec = 10; // seconds the pump is running

int statusPeriod = 5000; // ms time between status blinks-- to let you know it's alive
int statusBlink = 200; // ms duration of status blink

void setup()
pinMode(pumpPin, OUTPUT);
digitalWrite(pumpPin, LOW);
pinMode(gPin, OUTPUT);
digitalWrite(gPin, LOW);
pinMode(bPin, OUTPUT);
digitalWrite(bPin, LOW);
pumpPeriodSec = pumpPeriodHours * 60 * 60; // seconds between pump starts
//pumpPeriodSec = 30; // for setting short periods when testing

void loop(){

lastPumpTime = millis();

// Activate the pump and status LED
digitalWrite(pumpPin, HIGH);
digitalWrite(bPin, HIGH);
digitalWrite(pumpPin, LOW);
digitalWrite(bPin, LOW);

// Wait for the delay period, blinking periodically
time = millis();
while ( ((time-lastPumpTime)/1000) < pumpPeriodSec ) {
digitalWrite(gPin, HIGH);
digitalWrite(gPin, LOW);
time = millis();

Thanks for sharing the details. Your code is much simpler than mine. I'm a programmer by trade and obviously I've over complicated my version (ha ha). I tried to do it without any delay() calls so I could add other things for it to do later without messing up the timing of the water. I'll post my code once I get it behaving.

So it looks like you are driving a 5V DC relay switching 110V AC? Is that a transistor I see on the breadboard or are you driving the relay directly from an output?

I liked your solution of a drip loop around the plants instead of directing the entire flow of the pump into the plants. I guess it would have been fine either way, since overflow from the plants will return to the reservoir anyway.

Yes, that's a 2N2222 (overkill)-- I just followed the schematic in that link-- works great.

Forgot to post that I added an LCD before taking off 10 days ago-- here counting down the initial delay:

I inadvertently made a "step switch" by mounting it in two plastic shoebox lids (held together with gaffer's tape, of course...:).

Also discovered that twist ties can make nice jumper wires...:o

Step switch, LOL! FYI, have you factored in the 9 hour millis rollover?

If you are getting a new lastPumpTime @ 6 hours, you should never get a time = 12 hours;


Thanks for pointing that out!, did you notice I'm a newbie?!

At least I won't come crying to the forum when I get home next Monday and find the plants dead!

have you considered using a web front end so it can be controlled remotely?

this guy has done some of the proof of concept work for web->arduino connection.

I'd be interested in helping out with that. I currently have a commercial timer for my sprinkler system but i'd like something with more robust scheduling and more importantly i'd like to be able to control it remotely. I recently went on a vacation and while i was gone for 2 weeks the weather shifted from 60deg cloudy/rainy days to 75 and sunny. I had the waterign schedule set for the former and nearly every seedling i planted was cooked.

Hey there, I am also starting a very similar project, only got my arduino =) It includes automatic watering, growlights, temperature and humidity regulation. I was wondering, do you know of a way how to measure the ph of the soil?

Plus please keep us updated with ur project, Im so glad If i dont have to write it all by myself =)


Part of your timing problems could be caused by the millis rollover at 9 hrs 32 min? After this time, the internal timer goes back to zero. Consider possibly two sensor inputs, temp via a thermistor and humidity via a humidity sensor. Construct a grid with various humidity and temperature combinations and watering durations. You will have to run some experiments with a scale/balance and estimate how much water the pots lose at certain temp/humidity combinations. The Arduino consults this grid and then chooses the correct interval of time to run the pump. Another option is to measure soil moisture. This would make your life easier

Well, first off, the pontica died when I was away since the rig didn't water itself, but it's watering on a four hour interval now-- the original tomato plant and its new sibling are doing fine (spotty leaves aside...:).

Moisture sensing is a red herring, I think, because I'm growing in hydroponic medium. pH is much more interesting-- still trying to figure out the best sensor, but it seems like it should be straightforward.

Priorities now are aerating and agitating the nutrient reservoir to get the food distributed before the pump goes into action.

This is such a great project... I found it as I was gathering info on who i would go for a project like this. The only difference being that it would be grown in dirt as opposed of being hydro, and that -if it happens to be possible- the pump would pull water/nutriments from my balcony to the roof of the building (a few meters up) for rooftop gardening...

Also, in my case, moisture measuring would be good (

What kind of submersible pump are you using? I'm thinking of using something like the WT660 on this page : Fountain Pro Submersible Fountain and Pond Pumps

Cheers. Keep up the excellent work! I can't to see how you'll handle the different sensors !

i'm thinking about the same project. but i plan to use a light sensor to do the timing.
i think that is the easiest way to go. you can have two watering intervals (or just one or more) when a light intensity rate gets crossed.
i think the sunlight is still reliable. even when the sun does not shine you get high enough light intensities to start watering.
so just use the sun as your external timer :slight_smile:

Very cool! I'm working on a growduino layout right now in EAGLE...:slight_smile: Details to come...

here is a nice offer:

i wrote something about solenoids in this thread as wel:

Great deal for those valves!

I'm planning on using a 12V system (solar ftw!) and cheap (possibly windshield wiper washer) pumps. I won't have any water source access on a balcony, instead having a reservoir under the plants for water and nutrient-- should be fine to drain into itself (details complicated, more later).

These valves would be useful with a raised reservoir, if the runoff isn't being reused, esp. with a rainwater catchment system.

SO HAPPY to see many people working on different concepts of a "smart garden"!

I too am an avid gardener, who also happen to be an Electronic Technologist who likes to automate and control.

You may wish to consider using my recently introduced MRMP using either Controller or Bridge shell.

Using MRMP you can easily add your code, debug and even network them over the serial port or simple Wire network.

As an example I have a Bridge and three Controllers... House Alarm, Garage Alarm and Koi Pond feed and monitor. All are accessible from anywhere in the World. The MRMP Controller code is rock solid, runing for six months without any intervention.

Hope MRMP helps.

Whats the progress of this project?

I plan to invest my entire winter working on a hydroponic version, It will control PH/TDS/nutrent levels, water temps, monitor humidity in the green house, have web monitoring and a software GUI to control and set the many parameters of hydroponic gardening.

Id like to get this get this going with as many of you as possible!

if your interested in participating, shoot me a PM, Ill donate enough $ to each member of the team that provides code for the project to buy a new arduino :slight_smile:

Nice to see that I'm not the only lazy creature on this planet. I have made a thing like that about 6 months ago and have been testing it for all summer, the plants were satisfied, tomatos were delicious :slight_smile: I didn't include an actual arduino board as I made my own to reduce the size of the black box.

What it does:

  • temperature measurement: if it's too hot, it opens the window to let fresh air in. (can be set to auto/manual, if I want to let it closed/opened no matter what)
  • watering: two modes, auto-timer ->twice a day (as we don't water during the day, right) for a set period of time) and auto-humidity (the value shown on lcd) -> measures humidity and if the soil is too dry, triggers the valve (also only twice a day), this is, as on a cold day you don't need so much wattering.

I guess that's all you need :slight_smile: