Você está na página 1de 12

90 Make: Volume 18

PROJECTS: GARDUINO makezine.com/18/garduino


THE GARDUINO
GARDEN
CONTROLLER
By Luke Iseman
P
h
o
t
o
g
r
a
p
h

b
y

M
i
c
h
a
e
l

T
.

C
a
r
t
e
r
M_090-101_Garduino_F1.indd 90 4/14/09 11:48:43 AM
=ifdD8B<dX^Xq`e\#Mfcld\(/%=fidfi\#m`j`kdXb\q`e\%Zfd
91 Make:
Luke Iseman builds open source hardware, including pedicabs, pallet lurniture, and chicken tractors,
in Austin, Texas. His pro|ects are available at dirtnail.con.
Set up: p.93 Make it: p.94 Use it: p.101
GEEKED-OUT
GARDENING
wanted to start arden|n, but |new
wou|dnt |ee u the reu|ar schedu|e
o water|n the |ants and na||n sure
they ot enouh ||ht. co recru|ted a
n|crorocessor and a su|te o sensors
to he| w|th these tas|s.
My Oarduino garden controller uses an Arduino nicro
controller to run ny indoor garden, watering the plants only
when they're thirsty, turning on supplenental lights based on
how nuch natural sunlight is received, and alerting ne il the
tenperature drops below a planthealthy level.
For sensors, the Oarduino uses an inexpensive photocell
(light), thernistor (tenperature), and a pair ol galvanized
nails (noisture).
You can use a Oarduino to experinent and learn what works
best in your garden.
M_090-101_Garduino_F1.indd 91 4/14/09 11:49:05 AM
=ifdD8B<dX^Xq`e\#Mfcld\(/%=fidfi\#m`j`kdXb\q`e\%Zfd
*
.
+
-
,
/
0
(
)
('
((
.
0) DXb\1Mfcld\(/
GIFA<:KJ1>8I;L@EF
@
c
c
l
j
k
i
X
k
`
f
e

Y
p

K
`
d
d
p

B
l
Z
p
e
[
X
D@:IF:FEKIFCC<I$8JJ@JK<;>8I;<E@E>
?fnk_\8i[l`efXkk\e[jkfpfligcXekj\m\ipe\\[%
(
I\cXpjc\kpflZfekifc
8:gfn\ic`^_kjXe[
gldgjn`k_k_\8i[l`ef%
)
?\i\n\i\Zfekifcc`e^
gfn\ikfk_\gldgn`k_X
i\cXpn`i\[kfk_\8i[l`ef%
*
K_\i\cXpjZfee\Zkkf
fli8i[l`efn`k_[`f[\jkf
gi\m\ek`k]ifd]ip`e^%
+
K_\id`jkfi1i\j`jkXeZ\
Z_Xe^\jn`k_k\dg\iXkli\%
,
K_\j\n`i\jc\X[kf
eX`cjjklZb`ek_\jf`c1fli
df`jkli\j\ejfi%I\j`jkXeZ\
Y\kn\\ek_\eX`cj#k_ifl^_
k_\jf`c#Z_Xe^\jn`k_jf`c
df`jkli\%
-
G_fkfZ\cc1i\j`jkXeZ\
Z_Xe^\jn`k_c`^_k`ek\ej`kp%
.
>Xi[l`efZ`iZl`kYfXi[
8i[l`ef"j\ejfij%
/
K_\>Xi[l`efkliejfe
k_\lfi\jZ\ekc`^_kkf
dXb\jli\k_\gcXekji\Z\`m\
k_\i`^_kXdflekf]c`^_k
(-_flij[X`cp%K_\g_fkf$
Z\ccgclj8i[l`efd\Xjli\
_fndlZ_eXkliXcjlec`^_k
`ji\Z\`m\[Xe[kliefek_\
jlggc\d\ekXcc`^_kjkfdXb\
lgXep[`]]\i\eZ\%
0
K_\YcXZb`ii`^Xk`fe
klY`e^_Xjk`ep_fc\jk_Xk
XccfnnXk\ikfi\XZ_k_\
gcXekjn_\ek_\gldg`j
klie\[fe%
('
K_\gldg`jjlYd\i^\[
`eXYlZb\kf]nXk\i%
((
Fi[`eXip^XcmXe`q\[
eX`cjXi\lj\[kfj\ej\
jf`cdf`jkli\%
@E;FFI>8I;<E
((
=ifdD8B<dX^Xq`e\#Mfcld\(/%=fidfi\#m`j`kdXb\q`e\%Zfd
93 Make:
F
h
o
t
o
g
r
a
p
h

b
y

E
d

T
r
o
x
e
l
l
SET UP.
A
E
F
H
l
D
J
B
C
K
G
L
M
MATERlALS
AII eIectronics can be
purchased at the Maker
Shed {makershed.com)
and Jameco {jameco.com),
and everything eIse can be
found at your IocaI hard
ware store. See makezine.
comZISZgarduino for
direct Iinks to purchase
the parts onIine. TotaI cost,
incIuding the Arduino, was
about SI50.
[A] Arduino microcon
troIIer used an Arduino
Duenilanove, but any should
work.
[B] Circuit board You
can pack everything onto a
Froto8hield (shown on previ
ous page and available at the
Maker 8hed) but the lollowing
pages show a solderless
breadboard lor clarity.
[C] Omron G5LEI reIays {Z)
[D] IN4004 diodes {Z)
[E] ZZ0 resistor lor the LED
[F] Standard LED Any you'd
use with an Arduino will do.
[G] PhotoceII
[H] I0k thermistor
[l] ZZgauge wire, soIid
core and stranded,
severaI feet
[J] I0k resistors {3)
[K] GaIvanized naiIs,
I"-4" Iong {Z)
[L] USB cabIe
[M] AC extension cords {Z)
[NOT SHOWN]
PIastic miIk jugs lor plant
ing in. Use as nany as you'd
like. used about 30.
CIear pIastic storage
containers, ZSgaI You'll
need l lor every 6 nilk |ugs.
Bricks or other spacers to
raise the nilk |ugs at least
l" oll the botton ol the bin.
You'll need about 5 lor each
storage container.
Seeds prelerably lor things
you'd like to eat. 8wiss chard
is an easy starter plant.
4S" fIuorescent Iight
fixture
4S" fIuorescent tube "grow
Iight" used the OttLite, but
any tube narketed lor plant
growth should be line.
SoiI mixture used Mel's
Mix, as reconnended in Mel
Bartholonew's Square Foot
Gardening. t consists ol
1
/3
peat noss,
1
/3 coarse vernicu
lite, and
1
/3 nixed conpost,
with the nixed conpost con
ing lron at least 6 dillerent
sources. You can use whatever
works lor your plants.
CIeanwater pump A snall,
cheap one is line, used
a nini subnersible punp
lron Harbor Freight (iten
#45303, available online at
www.harborlreight.con).
Micro soaker hose kit also
lron Harbor Freight (iten
#650l5). Or you can use bike
inner tubes and poke holes.
5gaI bucket
FunneI used a cut nilk |ug
WARNlNG: This project invoIves using eIectricity near water. We recommend connecting to a GFCl outIet.
l
M_090-101_Garduino_F1.indd 93 4/14/09 11:51:02 AM
=ifdD8B<dX^Xq`e\#Mfcld\(/%=fidfi\#m`j`kdXb\q`e\%Zfd
94 Make: Volune l8
PROJECTS: GARDUINO makezine.com/18/garduino
HOOK UP YOUR
MICROCONTROLLER
GARDEN
START
>>
MAKE IT.
Time: A Weekend Complexity: Moderate
This pro|ect is anbitious lor a lirst Arduino undertaking. reconnend conpleting at least the lirst lew
lessons ol an Arduino tutorial belore attenpting this. There's a great one at ladyada.net/learn/arduino.
1. PLANT YOUR GARDEN
8prout your seeds belore planting then, or buy started plants. planted a variety ol vegetables in nilk
|ugs with the tops cut oll, with holes in the botton to allow drainage, and a surrounding plastic storage
container to catch water as it drained out.
2. MAKE MOISTURE SENSORS
2a. Cut ? pieces ol wire, each ?' long, and strip " oll the ends.
2b. Wrap l end ol each wire around the head ol each nail.
2c. Cover the wirenail connection with a generous anount
ol solder.
3.
CONNECT MOISTURE SENSORS
TO THE ARDUINO
You can tell when your soil needs water by neasuring the resistance between the ? nails stuck in the dirt.
The nore water in the soil, the nore conductive it is.
3a. Connect a wire between ground on your Arduino and the ground (-) colunn on your breadboard.
You'll use this colunn on the breadboard as ground lor the rest ol the circuit.
3b. Connect a wire between +5V on your Arduino and the positive (+) colunn on your breadboard. You'll
use this colunn as the positive voltage connection lor the rest ol the circuit. F
h
o
t
o
g
r
a
p
h

b
y

L
u
k
e

s
e
n
a
n
M_090-101_Garduino_F1.indd 94 4/14/09 11:51:52 AM
=ifdD8B<dX^Xq`e\#Mfcld\(/%=fidfi\#m`j`kdXb\q`e\%Zfd
95 Make:
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.
MlCROCONTROLLER lNPUTS AND OUTPUTS
Here's how the Arduino's lZO pins connect
to the Garduino's sensors, reIays, and LED.
SOlL PROBE PHOTOCELL
THERMlSTOR
LED
I
l
l
u
s
t
r
a
t
i
o
n
s

b
y

G
e
r
r
y

A
r
r
i
n
g
t
o
n
KEY
RI 10k
RZ Photocell
R3 Thermistor
R4 220
DI 1N4004
DlGlTAL lZO Z
DlGlTAL lZO 7, S
DI
+5V DC
ANALOG 0
RI
RZ
R4
RI
R3
+5V DC
ANALOG I
RI
+5V DC
ANALOG Z
RELAYS
EXTENSlON
CORD
IZ0V
PLUG
RELAY
4 5
I
Z
M_090-101_Garduino_F1.indd 95 4/14/09 11:56:15 AM
=ifdD8B<dX^Xq`e\#Mfcld\(/%=fidfi\#m`j`kdXb\q`e\%Zfd
96 Make: Volune l8
PROJECTS: GARDUlNO makezine.com/18/garduino
4. LOAD THE SENSOR TEST CODE
Make sure that the noisture sensor works by connecting your Arduino to a conputer and entering the
sensor test code below (also at nakezine.con/l8/garduino). When you touch the nails together, the
noisture value should read 985, when they're not touching, the noisture value should be 0.
NOTE: lf you haven't used your Arduino before, you need to connect it via its USB cabIe to your computer, then
Iaunch the Arduino deveIopment appIication {free downIoad at arduino.cc), enter the code, and then upIoad it to
the board. SeIect the seriaI monitor to see the output.
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);

}
M_090-101_Garduino_F1.indd 96 4/14/09 11:56:29 AM
=ifdD8B<dX^Xq`e\#Mfcld\(/%=fidfi\#m`j`kdXb\q`e\%Zfd
97 Make:
5. ADD THE LIGHT SENSOR
5a. First, connect the photocell to ? new rows on the breadboard.
5b. Connect a wire between one row that the photocell touches
and the positive colunn.
5c. Connect a l0k resistor to the other row that the photocell
touches and to a new row.
5d. Connect a wire between the photocellresistor row and
analog input l on your Arduino.
5e. Connect the other end ol the resistor to ground.
5f. Test your light sensor by connecting your Arduino to your
conputer and nonitoring the serial output. neasured the
lollowing values:
ndirect sun: 949
Anbient indoor light at night: 658
Anbient indoor light at night, with a
hand casting shadow over the sensor: 343
6. CONNECT THE TEMPERATURE SENSOR
6a. Connect the thernistor to ? new rows on the breadboard.
6b. Connect a wire between one row that the thernistor touches
and to the positive colunn.
6c. Connect the last ol the l0k resistors to the other row the
thernistor touches and to a new row.
6d. Connect a wire between the thernistorresistor row and
analog input ? on your Arduino.
6e. Connect the other end ol the resistor to ground.
6f. Test your tenperature sensor by connecting your Arduino to
your conputer and nonitoring the serial output. neasured the
lollowing values:
6lF = 90l
90F = 949
5lF = 8//
3?F = /96
M_090-101_Garduino_F1.indd 97 4/14/09 11:56:43 AM
=ifdD8B<dX^Xq`e\#Mfcld\(/%=fidfi\#m`j`kdXb\q`e\%Zfd
9S Make: Volune l8
PROJECTS: GARDUlNO makezine.com/18/garduino
7. SPLlCE RELAYS lNTO THE LlGHTZPUMP POWER CORDS
Now we work with the heavy lilters: our relay setups. These will turn the lights and punps on and oll,
in response to hours ol sunlight received and soil noisture.
7a. Cut lour l0" lengths ol ??gauge wire and strip " oll each
end.
7b. Look at your extension cord's plug: one prong is larger than
the other. 8plit the ? wires ol the cord apart, then cut the wire
that runs to the snaller prong, and strip l" oll each side.
TlP: The correct wire is the one without ridges running aIong its
Iength. Don't worry if you cut both wires; you can just spIice the
other wire back together.
7c. 8older a ??gauge wire to each side ol the split cord wire.
7d. 8older the ??gauge wire that runs to the extension cord's
receptacle to the lower right lead ol the relay (it should be
labeled 4 on the botton ol the relay).
7e. 8older the ??gauge wire that runs to the extension cord's
plug to the niddle lelt lead ol the relay (labeled l).
7f. Connect a ??gauge wire to each ol the ? other leads on the
lelt side ol the relay (labeled ? and 5). Optionally, you can
cover the relay's botton side with hot glue to strengthen all
4 connections.
7g. Wrap both connections to the extension cord in electrical
tape or heatshrink tubing. Congratulations, you've conpleted
your relaycord setup.
7h. Repeat 8teps /a-/g with another relay and extension cord
to create the second relaycord setup.
F
h
o
t
o
g
r
a
p
h
y

b
y

E
d

T
r
o
x
e
l
l
,

b
o
t
t
o
n

p
h
o
t
o
g
r
a
p
h

b
y

L
u
k
e

s
e
n
a
n
M_090-101_Garduino_F1.indd 98 4/14/09 11:56:56 AM
=ifdD8B<dX^Xq`e\#Mfcld\(/%=fidfi\#m`j`kdXb\q`e\%Zfd
99 Make:
8. CONNECT RELAYS AND AN LED TO THE ARDUINO
8a. Connect one ol your diodes to ? unused rows on the
breadboard.
8b. Connect the botton lelt lead (pin ?) ol your relay (looking at
it lron the top, with the leads down) to the positive lead ol your
diode - the end that does not have a band on it.
8c. Connect the upper lelt lead (pin 5) ol your relay to the nega
tive lead ol the diode - the end narked with a band.
8d. Connect a wire between ground on your Arduino and the
ground colunn on your breadboard (il you're using the sane
breadboard lor relays and sensors, |ust use the ground colunn
you've already created).
8e. Connect the row containing the negative lead ol your diode
(the end with the band) and the upper lelt lead ol your relay to
digital input/output / on your Arduino.
8f. Connect the positive lead ol the diode to your ground colunn.
That's it lor connecting the lirst relay.
8g. Now choose ? new unused rows and repeat 8teps 8a-8l to
connect the second diode and relay as you did the lirst, except
this one goes to digital input/output 8 on your Arduino.
8h. Connect the ??0 resistor to ? unused rows. Connect the
LED's long leg (+) to either end ol the resistor, and its short leg
(-) to ground. Connect the other end ol the resistor to digital
input/output ? on your Arduino.
9. SET UP THE LIGHTING SYSTEM
An easy step here: alter checking that your light lixture is work
ing, plug it into the relay cord that will control it. sinply rested
the lixture on top ol the outer plastic bins, but leel lree to get
lancy. Optinun distance lron these lluorescents lor the light
intensity you want is |ust a lew inches, so nake sure you get
then up close, personal, and ad|ustable as the plants grow.
Relay 1
to extension cord
F
h
o
t
o
g
r
a
p
h

b
y

M
i
c
h
a
e
l

T
.

C
a
r
t
e
r
1
2
5
4
M_090-101_Garduino_F1.indd 99 4/14/09 11:57:12 AM
=ifdD8B<dX^Xq`e\#Mfcld\(/%=fidfi\#m`j`kdXb\q`e\%Zfd
I00 Make: Volune l8
PROJECTS: GARDUlNO makezine.com/18/garduino
I0. SET UP THE WATERlNG SYSTEM
You've got a wide variety ol options here. Here's how nine works:
A snall punp is subnerged in a 5gal bucket water source. x
A relay controlled by noisture sensors activates the punp to x
nove water lron the bucket to a nilk|ug lunnel.
Oravity noves water lron the lunnel down to the soaker x
hoses, which drip into the plants.
used a nini soaker hose kit lron Harbor Freight Tools to
assenble rings that drip into all the plant containers. l you
nake a setup like this, be sure to elevate the bucket on a crate
or sonething else, noving water inches instead ol leet vertically
will greatly reduce the strain on your punp.
initially tried using |ust a sprinkler valve nounted to the botton
ol a bucket, without the punp. But gravity provided only enough
pressure lor the slightest trickle. thought about connecting
the sprinkler valve right into ny plunbing, but worried that the
chlorine content ol water straight lron the laucet would be bad
lor ny plants (chlorine evaporates lron water within sonething
like ?4 hours).
A better version ol this would be to use ? buckets, with water
coning lron a sprinkler valve connected to house plunbing
going into one bucket, being held there ?4plus hours, and then
noving into the second, plantleeding bucket.
II. PROGRAM YOUR GARDUlNO
Lastly, you need to progran your Oarduino to run the garden.
Because tenperature and soil noisture are dealt with as
constants (i.e., always turn on the LED il tenperature is below
a certain value, always turn on the water il noisture is below
a certain value) they're sinple to deal with.
Light is nore conplicated: you want to keep track ol how
nuch light your plants are getting, so that natural light plus
supplenental light always equals optinun light tine (in ny
case, chose l4 hours daily). To do this, used the DateTime
Arduino library.
FlNlSH X
NOW GO USE lT x
F
h
o
t
o
g
r
a
p
h
y

b
y

M
i
c
h
a
e
l

T
.

C
a
r
t
e
r
M_090-101_Garduino_F1.indd 100 4/14/09 11:57:25 AM
=ifdD8B<dX^Xq`e\#Mfcld\(/%=fidfi\#m`j`kdXb\q`e\%Zfd
I0I Make:
SWlTCHlNG TO ...
GARDENlNG COMPUTER
USE IT.
REAP YOUR HARVEST
Check your seed packets (you saved then, right?)
to see how nany weeks until your plants should be
ready lor harvest. But don't be surprised il they're
ready sooner than thatl l they seen to be grow
ing too slowly, check your watering and lighting
routines.
EVALUATE YOUR DATA
As currently inplenented, Oarduino needs to be
hooked up to a conputer that's nonitoring serial
output to obtain nore neaninglul data to share.
With additional work, it's possible to store data on
a U8B drive. But lor now, nonitor the serial out
put in the Arduino environnent to evaluate your
Oarduino's perlornance.
lMPROVE AWAYl
don't expect this beta Oarduino to get everyone
gardening and save the world, that's an exercise lor
readers to solve with their inprovenents. But here
are sone initial ideas:
x Use pulsing red and blue LEDs lor an ultra
ellicient lighting systen (see screwdecal.cx/sept.
htnl lor Mikey 8klar's version).
x Figure out what tines ol night your utility charges
lower rates lor electricity, and turn the lights on
during those tines only.
x Build a pH probe and linetune your soil acidity
lor dillerent plants.
x Add a relaycontrolled heater to keep a
greenhouse version above a nininun
desired tenperature.
x Add a battery and solar panel to take the whole
systen ollgrid.
x Use an irrigation valve instead ol a punp to water
your larger, outdoor garden, and add sone nodi
lied solar garden lights lor additional lighting.
l nany people start recording the elliciency and
convenience ol this autonated approach to garden
ing, then naybe we can even grow nore lood ol
better quality with less energy. Happy Oarduinoingl
You can lind the conplete code at nakezine/l8/
garduino. 'll add links to better versions as readers
create then.
F
h
o
t
o
g
r
a
p
h

b
y

M
i
c
h
a
e
l

T
.

C
a
r
t
e
r
M_090-101_Garduino_F1.indd 101 4/14/09 11:57:41 AM
=ifdD8B<dX^Xq`e\#Mfcld\(/%=fidfi\#m`j`kdXb\q`e\%Zfd

Você também pode gostar