Arduino Magazine
Arduino Magazine
Arduino Magazine
makezine.com/18/garduino
90
Make: Volume 18
GEEKED-OUT GARDENING
I wanted to start gardening, but I knew I wouldnt keep up the regular schedule of watering the plants and making sure they got enough light. So I recruited a microprocessor and a suite of sensors to help with these tasks.
My Garduino garden controller uses an Arduino microcontroller to run my indoor garden, watering the plants only when theyre thirsty, turning on supplemental lights based on how much natural sunlight is received, and alerting me if the temperature drops below a plant-healthy level. For sensors, the Garduino uses an inexpensive photocell (light), thermistor (temperature), and a pair of galvanized nails (moisture). You can use a Garduino to experiment and learn what works best in your garden.
Luke Iseman builds open source hardware, including pedicabs, pallet furniture, and chicken tractors, in Austin, Texas. His projects are available at dirtnail.com.
Make:
91
PROJECTS: garduino
Microcontroller-assisted gardening
How the arduino attends to your plants every need.
4 6 5
7 3 11
11
7 2 10 1
indoor garden
1 Relays let you control AC power (lights and pumps) with the Arduino. 4 Thermistor: resistance changes with temperature. 5 These wires lead to nails stuck in the soil: our moisture sensor. Resistance between the nails, through the soil, changes with soil moisture. 7 Garduino circuit board (Arduino + sensors). 8 The Garduino turns on the fluorescent light to make sure the plants receive the right amount of light (16 hours daily). The photocell plus Arduino measure how much natural sunlight is received and turn on the supplemental lights to make up any difference. 9 The black irrigation tubing has tiny holes that allow water to reach the plants when the pump is turned on. 10 The pump is submerged in a bucket of water. 11 Ordinary galvanized nails are used to sense soil moisture.
Here were controlling power to the pump with a relay wired to the Arduino.
2 3 The relays connect to our Arduino with diodes to prevent it from frying.
92
Make: Volume 18
SET UP.
M
C D
K J E F G H I
WARNING: This project involves using electricity near water. We recommend connecting to a GFCI outlet.
MATERIALS
All electronics can be purchased at the Maker Shed (makershed.com) and Jameco (jameco.com), and everything else can be found at your local hardware store. See makezine. com/18/garduino for direct links to purchase the parts online. Total cost, including the Arduino, was about $150. [A] Arduino microcontroller I used an Arduino Duemilanove, but any should work. [B] Circuit board You can pack everything onto a ProtoShield (shown on previous page and available at the Maker Shed) but the following pages show a solderless breadboard for clarity.
[C] Omron G5LE-1 relays (2) [D] 1N4004 diodes (2) [E] 220 resistor for the LED [F] Standard LED Any youd use with an Arduino will do. [G] Photocell [H] 10k thermistor [I] 22-gauge wire, solid core and stranded, several feet [J] 10k resistors (3) [K] Galvanized nails, 1"4" long (2) [L] USB cable [M] AC extension cords (2)
[NOT SHOWN] Plastic milk jugs for planting in. Use as many as youd like. I used about 30. Clear plastic storage containers, 28gal Youll need 1 for every 6 milk jugs. Bricks or other spacers to raise the milk jugs at least 1" off the bottom of the bin. Youll need about 5 for each storage container. Seeds preferably for things youd like to eat. Swiss chard is an easy starter plant. 48" fluorescent light fixture 48" fluorescent tube grow light I used the OttLite, but any tube marketed for plant growth should be fine.
Soil mixture I used Mels Mix, as recommended in Mel Bartholomews Square Foot Gardening. It consists of 1/3 peat moss, 1/3 coarse vermiculite, and 1/3 mixed compost, with the mixed compost coming from at least 6 different sources. You can use whatever works for your plants. Clean-water pump A small, cheap one is fine; I used a mini submersible pump from Harbor Freight (item #45303, available online at www.harborfreight.com). Micro soaker hose kit also from Harbor Freight (item #65015). Or you can use bike inner tubes and poke holes. 5gal bucket Funnel I used a cut milk jug
Photograph by Ed Troxell
Make:
93
PROJECTS: GARDUINO
makezine.com/18/garduino
MAKE IT.
>>
This project is ambitious for a first Arduino undertaking. I recommend completing at least the first few lessons of an Arduino tutorial before attempting this. Theres a great one at ladyada.net/learn/arduino.
3c. Connect one of the moisture sensors to +5V on the breadboard. 3d. Connect the other moisture sensor to a new row on the breadboard. 3e. Connect a 10k resistor to the same row as the moisture sensor and also to a new row. 3f. Connect a wire from analog input 0 on your Arduino to the same row as the resistor and moisture sensor. 3g. Connect the other end of the resistor (in the new row) to ground.
MICROCONTROLLER INPUTS AND OUTPUTS Heres how the Arduinos I/O pins connect to the Garduinos sensors, relays, and LED. SOIL PROBE PHOTOCELL
+5V DC +5V DC
RELAYS
DIGITAL I/O 7, 8 120V PLUG
ANALOG 0
ANALOG 1
R2
R1
R1
THERMISTOR
+5V DC Illustrations by Gerry Arrington R3
LED
ANALOG 2
DIGITAL I/O 2
R4
R1
Make:
95
PROJECTS: GARDUINO
makezine.com/18/garduino
CODE: int moistureSensor = 0; int lightSensor = 1; int tempSensor = 2; int moisture_val; int light_val; int temp_val; void setup() { Serial.begin(9600); //open serial port } void loop() { moisture_val = analogRead(moistureSensor); // read the value from the moisture-sensing probes Serial.print("moisture sensor reads "); Serial.println( moisture_val ); delay(500); light_val = analogRead(lightSensor); // read the value from the photosensor Serial.print("light sensor reads "); Serial.println( light_val ); delay(500); temp_val = analogRead(tempSensor); // read the value from the thermistor Serial.print("temp sensor reads "); Serial.println( temp_val ); delay(1000); }
96
Make: Volume 18
97
PROJECTS: GARDUINO
makezine.com/18/garduino
7c. Solder a 22-gauge wire to each side of the split cord wire. 7d. Solder the 22-gauge wire that runs to the extension cords receptacle to the lower right lead of the relay (it should be labeled 4 on the bottom of the relay). 7e. Solder the 22-gauge wire that runs to the extension cords plug to the middle left lead of the relay (labeled 1). 7f. Connect a 22-gauge wire to each of the 2 other leads on the left side of the relay (labeled 2 and 5). Optionally, you can cover the relays bottom side with hot glue to strengthen all 4 connections.
Photography by Ed Troxell; bottom photograph by Luke Iseman
7g. Wrap both connections to the extension cord in electrical tape or heat-shrink tubing. Congratulations, youve completed your relay-cord setup. 7h. Repeat Steps 7a7g with another relay and extension cord to create the second relay-cord setup.
98
Make: Volume 18
Relay 1
2 4
An easy step here: after checking that your light fixture is working, plug it into the relay cord that will control it. I simply rested the fixture on top of the outer plastic bins, but feel free to get fancy. Optimum distance from these fluorescents for the light intensity you want is just a few inches, so make sure you get them up close, personal, and adjustable as the plants grow.
Make:
99
PROJECTS: GARDUINO
makezine.com/18/garduino
Lastly, you need to program your Garduino to run the garden. Because temperature and soil moisture are dealt with as constants (i.e., always turn on the LED if temperature is below a certain value, always turn on the water if moisture is below a certain value) theyre simple to deal with. Light is more complicated: you want to keep track of how much light your plants are getting, so that natural light plus supplemental light always equals optimum light time (in my case, I chose 14 hours daily). To do this, I used the DateTime Arduino library.
FINISH X
NOW GO USE IT
100
Make: Volume 18
USE IT.
IMPROVE AWAY!
I dont expect this beta Garduino to get everyone gardening and save the world; thats an exercise for readers to solve with their improvements. But here are some initial ideas: Use pulsing red and blue LEDs for an ultraefficient lighting system (see screwdecaf.cx/sept. html for Mikey Sklars version). Figure out what times of night your utility charges lower rates for electricity, and turn the lights on during those times only. Build a pH probe and fine-tune your soil acidity for different plants. Add a relay-controlled heater to keep a greenhouse version above a minimum desired temperature. Add a battery and solar panel to take the whole system off-grid. Use an irrigation valve instead of a pump to water your larger, outdoor garden, and add some modified solar garden lights for additional lighting. If many people start recording the efficiency and convenience of this automated approach to gardening, then maybe we can even grow more food of better quality with less energy. Happy Garduino-ing!
You can find the complete code at makezine/18/ garduino. Ill add links to better versions as readers create them.
Make:
101