Introduction: An Arduino, Hydroponics, and You: a Solar Powered Microcontroller Garden

After buying an Arduino and learning how to use it, I immediately started wondering, "What can I build with this thing that I can call my own?" So I started listing the things that I like: Solar panels, living "off the grid", self sustaining systems, becoming a more knowledgeable and independent person, etc. and naturally I came to the obvious conclusion that I should build a nuclear fusion chamber. Within 10 seconds I realized that would be kind of hard, so I moved on to the next idea: An Arduino powered garden.

Step 1: Basic Theory

The basic idea was simple enough. Build a garden that will water itself and turn on grow lights when it isn't getting enough sunlight. I wanted to keep it indoors, so I decided to build it in an old fish tank. I needed to grow something that could grow in small areas and under many conditions, so I chose a spice (cilantro) and lettuce. I also wanted it to be compact so it doesn't take up too much space, so I kept that in mind while building everything.

To power the Arduino without a USB, I plugged the 12V directly into the Vin pin on the Arduino, while making sure the 12V power supply, a battery in this case, and the Arduino share a common ground. This is important! The Arduino has a built in voltage regulator so anything between 6-20V will power the Arduino.

Step 2: Materials

The materials came from a variety of sources. For anyone with the intent to build their own garden, use whatever resources you have available! I used what I had lying around to save a significant amount of money. Many of the electronic parts I used came from the Arduino Starter Kit, which cost $100, but was extremely worth it in that it taught me the basics of using an Arduino and electronics. Many of the ideas in this project were pulled from the beginner projects in the Starter Kit book.

Link to starter kit:

https://www.arduino.cc/en/Main/ArduinoStarterKit

Arduino Starter Kit - $100

1/4" Vinyl Tubing - $5

1/8" Vinyl Tubing - $5

Fish Tank - $25 off Craigslist

NTE2395 MOSFET N-Channel Transistors - $10 for two

Potting Soil - $15

360 Degree Spray Nozzles - $5 for a pack of six

Seeds - $5

10W LED Grow Lights - $30 for five strips

http://www.amazon.com/Hydroponic-Flowers-Vegatable...

Added up I spent about $100 on parts (not including the Arduino Starter Kit). I had a battery lying around, but if you have to buy a battery, expect to spend around $50 - $60 for an appropriate one.

Step 3: Sealing the Tank

The tank I found was pretty old and needed to be resealed, so I placed some silicone sealant along all the edges to make sure the tank was water proof. Pretty simple.

Step 4: Watering System

We had a water reservoir and attached motor lying around that was from a car's windshield sprayers. These are perfect for a project like that since they run on 12V DC and the pumps are more than powerful enough for this application. If you need one of these, simply go to a junkyard and grab one. I wouldn't expect it to cost any more than $10 for everything.

To start out I placed my tank on an old table that we had lying around the house. Conveniently this table was on wheels which was an added benefit. I mounted the reservoir + motor onto the side of the table using screws and an L-bracket.

I then attached a tube from the motor (I believe the motor used a 3/8" tube), and using a couple tube adapters we had lying around, hooked up my tubes after cutting them to the right lengths. I found that Command Strip wire holders were perfect for holding the tubes down to the tank. Find all these parts these at any hardware store, ideally Lowe's or Home Depot.

I ran the tube from the motor to a tube splitter adaptor under the soil, then each to the 360 degree sprayer. To hold the sprayers up I just used a zip tie and secured to the tube + sprayer to chopsticks sticking out of the dirt.

One wire from the motor is then connected to the "drain" on the NTE2395 transistor. I chose this transistor because of its capability to handle high current across the drain and source, and its capability of dispersing heat. I burned a couple of different transistors before learning this. The other wire from the motor is connected directly to 12V on the breadboard. The "source" on the NTE2395 is connected to ground, and the "gate" is connected to the Arduino's digital pin through a 10M resistor. When the Arduino turns on 5V across the gate, it closes the drain and source, allowing current to flow from the 12V battery and through the pump.

I attached an IN4007 diode (it's cheap), in parallel with the motor to take care of the surge from turning the motor off. The motor is an inductor after all, so a change in voltage will mean the motor wants to resist that change by creating a sharp voltage in the opposite direction which is why the diode seems to be placed backwards in the circuit at first. Don't forget this or you could damage your Arduino!

Lastly I added a button in so I can water the plants whenever I want. Just plug it into a digital pin on the Arduino with a 10K resistor.

Step 5: Moisture Sensors

I kept things simple here. I soldered wire directly to two galvanized nails and stuck them in opposite ends of the tank. Use plenty of solder here to make sure you get a good and strong connection. The Arduino then reads the resistance between the two nails, and thus the resistance of the soil, to determine how much moisture is in the soil. It will then decide if it needs to turn on the watering pump based on these moisture readings.

One nail is attached directly to the Arduino's 5V power supply, and the other is connected to ground through a 10K resistor so not too much current flows to the Arduino. The blue wire in the picture goes to an Analog In pin that reads the resistance between the two pins.

Step 6: Temperature Sensor, Light Sensor, and the LCD Display.

I decided to mount these three things on a separate circuit board outside the tank to avoid any chance of water getting on them. I then hung it outside the tank in a visible place so I could read off the LCD display. All three of these things and the wires and parts on this circuit came from the Arduino Starter Kit.

To connect this circuit board to the breadboard and Arduino, I used and old computer monitor cable. Again, just use what you have lying around! You'd be surprised at how you can reuse "junk". I cut the end of the cable off to expose the wires, then soldered the wires to my circuit board (the LCD uses quite a few wires!). I pretty much followed the circuit diagram from the starter kit book to wire up the LCD display.

The temperature sensor was just a standard TMP36, which changes resistance based on the temperature. We then read the voltage across the TMP36 using an Analog In pin and convert this to a temperature. The photoresistor works in just about the same way, except with light. I hooked a 10K resistor up in series with the photoresistor and another Analog In pin again to make sure we limit the current through the Arduino's pins.

Solder Male Arduino Connector Pins to each wire on the other end of the cable so we can plug into the Arduino. Wrap it up in electrical tape so nothing touches anything it shouldn't. Safety first!

The positive voltage for everything in this step is the ARDUINO 5V, NOT 12V. Things will probably blow up if you used 12V.

In the picture, W is "Water", L is "Light" and T is "Temperature (in C)".

Step 7: Grow Lights

Grow lights are the most power intensive part of the project, so it was important to use as little energy as possible, so naturally try and use higher power LEDs. I found strips of 12V LEDs (each strip 10W) on Amazon. I decided to only use two strips as a balance between power consumption and making sure my plants get enough light.

Generally speaking, plants optimum wavelength for growth is around 660nm (red light) and 440nm (blue light), so these LEDs are only either red or blue. This is why plants are green; we see the green light because plants don't use it for photosynthesis as much.

Using some scrap metal lying around, I created a simple support for the lights to hang from. I used zip ties to secure the lights to the metal bars.

The wiring is essentially the same as hooking up the motor, minus the diode (LEDs do not act as inductors). I used the same kind of transistor, an NTE2395, and hooked to Arduino up to the gate with a 10M resistor. Note the positive sides of the lights is hooked directly to 12V and the other is hooked to the drain on the transistor.

Step 8: Solar Panel

I'm using an old 12V battery charging solar panel from a car. It surprisingly puts out about 20V when in direct sunlight! Bu the current isn't too much so this is fine for charging the 12V deep cycle battery we had lying around. I don't know what the capacity on this battery is. All I know is it is huge because it came from a camper. Just hook the solar panel up in parallel across the 12V battery and it will charge it while it runs.

Alternatively if this solar panel proves to not be enough, I will hook up my 45W solar panels which are significantly bigger and will definitely provide enough to charge the battery.

Step 9: Plants

I used lettuce and cilantro, as these grow fine with each other. Any spice (oregano, rosemary, mint, etc.) would be fine too as they are small and don't grow too tall. I pour a small amount of liquid plant food into the water reservoir when I fill it up to make sure my plants are nice and healthy. An alternative to store bought plant food would be leftover water from boiling vegetables or something along those lines.

Step 10: Power Considerations

The power draw of this system breaks down as follows. All these are rough estimates:

Arduino - 50 mA

Grow lights - 1 A, for a max of 12 hours a day (like on a rainy day).

Water pump - 1.5 A, but only for 10 second watering cycles once or twice a day.

LCD - 40 mA

When we calculate this power consumption in a day we get:

(0.05 A * 24 hr) + (1 A * 12 hr) + (1.5 A * 0.005hr) + (0.04A * 24 hr) = 14.17 Ah.

So we need a battery that can supply about 15 Ah a day, and once we consider that batteries fall below 12V before they use up all this energy, I'd say a 12V battery with 20+ Ah would be sufficient for powering this project. Again, the one I'm using used to power a camper so it obviously way more than this. A battery this size is around $40, but to err on the safe side I would go for anything above 25 Ah if possible.

Step 11: The Code

I thought it'd be easier and more organized to upload the code in a Google doc:

https://docs.google.com/document/d/1NLgMJqJjs_tmA_...

Essentially I broke the code into separate little tasks.

1. First check the button

2. Check the moisture level

3. Turn on the motor if there isn't enough moisture in the soil

4. Check temperature

5. Check light

6. Turn on grow lights if there isn't enough light

The RunningAverage library can be downloaded here:

http://playground.arduino.cc/Main/RunningAverage

It allows me to have smooth values and makes the system as a whole much less volatile.

Step 12: Conclusion

The garden seems to work very well. All that remains is to see if the plants are receiving enough water and light. This is just a matter of tweaking two number in the code and some long term testing. I will update this Instructable with pictures and comments when my plants begin to grow! I am very happy with the results so far though. This is just my version of it using what I had lying around, so don't be afraid to take my ideas and run with them if you have something that works better for you!

Comment below with any questions, comments or concerns and let me know what you think! This project was a blast to work on and I highly recommend it to anyone interested in growing their own plants.

Thanks for reading!

Email: shawnzamperini@gmail.com

UPDATE (9/10/15): After building the project I moved it to my apartment, which is on the 9th floor. Unfortunately, the windows have a special UV (or some sort of wavelength) tint which cuts my solar panel power rate down by a factor of 10. In other words, the panel is useless with these windows. I am explicitly not allowed to hang anything, like the solar panel, outside my window by agreement with my lease, so as of now the project is on hold until I can move it somewhere else. But the lettuce is growing very well as I've been watering it on my own since the battery has died. So the tank works fine!

Comments

author
fishticker made it!(author)2016-01-03

Hi! First, congratulation for your project, it's really cool.
I would like to make something like this in a few weeks.
But I have a question. You didn't mention the fact where the battery was full. How do you stop its charge ? Because, if you just put your solar panel in parallel with it, There is a risk of explosion, right ?

author
mtbjakeh made it!(author)2015-09-20

My video is a little boring, but it walks through the functions pretty well. I like the solar panel idea, might have to add one to mine.

https://www.youtube.com/watch?v=Jjz1lLVRoQ0&feature=youtu.be

APWS.JPG
author
16mlucas made it!(author)2015-08-31

Hi,

first, this tutorial is very well made and easy to understand.

Then a small advice, the led doesn't give a lot of heat, such as HPS lamps(other growing lamps) So your led strips can be much closer to the plants, around 15 centimeter.

author
Zamperweenie made it!(author)2015-08-31

I'm sure they could except that the support for lower lights would've been much more difficult and if they were that low it would increase the risk of getting wet (yay explosions).

author
DallasB3 made it!(author)2015-08-31

I know what you grow mate.... knowldeg of lighting distance is not general knowlwdge......

author

Nice post! How you control LED light spectrum for
plants?

author
DallasB3 made it!(author)2015-08-31

you dont you buy them in that spectrum, and flowers use more than one blue and one red spectrum

author
Zamperweenie made it!(author)2015-08-21

They're just red and blue LEDs. Each strip provides 10W. I'm not controlling the spectrum or anything. Does that answer your question?

author

Thank for you ansver, but i meant a special spectrum for plants/ Like Fluora fluorescent, and his LED analogue.

author
Kinnishian made it!(author)2015-08-24

I think they are commercially purchased for this purpose, Zamperweenie didn't "control" the spectrum of the LED, they were made like that for this purpose.

author
Zamperweenie made it!(author)2015-08-21

I'm not sure I follow your questiom 100%, but if you're asking why red and blue LEDs, all I did was Google what light plants like the most and the general consensus is around 440 nm (blue) amd 660 nm (red). So, naturally, that's what color the LEDs are.

Does that help you out at all?

author
ppetrov7 made it!(author)2015-08-18

If you dont want to get your nails corroded, you can use the aternating current method but takes 2 digital pins instead of 1

author
Zamperweenie made it!(author)2015-08-18

I've heard about doing this, but I don't really have much room left for another digital pin. The capacitance of the wires was starting to become a factor and messing me up also.

author
Kinnishian made it!(author)2015-08-24

I'm a little unclear on having the 5V constantly running through the two pins- I almost feel as if you could benefit from using a digital pin to supply the <<20mA current so you can turn it on and off. No need to worry about AC for galvanic corrosion resistance if your testing duty cycle is 0.001% of the time that you actually need to poll the resistance of the soil.

Also if you want to avoid using an analog pin you can use an RC-charging system where you have a small cap on a digital pin and see how long it takes to go from 0V to 'high' which is usually a pretty consistent trigger point.

Just random added cents

author
Sanados made it!(author)2015-08-23

nice information!

To still only use one pin I would run that output through a commutator and the output to an OPV. Then you can even use IO and do not need an analog one.
The adjustment of the humidity could than be made over a variable resistor so that you do not need to change the code on updating. (Useful when plant kinds change often)

author
LegendofPedro made it!(author)2015-08-23

I think the DAC and ADC would be more appropriate.

author
tisaconundrum made it!(author)2015-08-18

How does that work?

author
LegendofPedro made it!(author)2015-08-23

This isn't hydroponics; you're growing in soil.

"Grow lights are the most power intensive part of the project, so it was important to use as little energy as possible, so naturally try and use higher power LEDs.

You haver this backwards; energy is the time integral of power so for lower energy use, use lower power LEDs.

"An alternative to store bought plant food would be leftover water from boiling vegetables or something along those lines."

Avoid this if you boil in salt-water. NaCl buildup will kill your plants.

"When we calculate this power consumption in a day we get:

(0.05 A * 24 hr) + (1 A * 12 hr) + (1.5 A * 0.005hr) + (0.04A * 24 hr) = 14.17 Ah."

Except you have two LED strips, so 14.17+12=26.17 Ah, right?

"//wire inductance from motor current messes up LCD, so restart it
delay(3000);
lcdPrep();"

Run that by me again... You're using a DC motor so there shouldn't be any induced current when dV/dt=dB/dt=0. Where is your transient snubbing diode located?

You might want to increase the current to the FETs' gates; overcome the gate capacitance and push the channel into saturation faster. 50uA seems pretty low to me.

Algae will grow inside clear tubing (step 4), black tubing will prevent this.

author
Kinnishian made it!(author)2015-08-24

Confusion about the LED power comes from the fact the OP's statement <<better to use high power LEDs to save energy" is meant with the implicit alternative <<better to use high power LEDs rather than energy-expensive incandescent or flourescents.>>

Perhaps the original statement could be clarified, if you want to nitpick (i did understand what was meant, but I also have grown with indoor lights before and it is more obvious if you have.)

author
Zamperweenie made it!(author)2015-08-23

Lower wattage LEDs won't give the plants enough energy. That's the purpose of grow lights. If they were lower wattage they'd just be normal LEDs which don't do much for plants.

Each strip draws 0.5A, so two strips draw 1.0A.

The data communication between the LCD and the Arduimo are changes in voltage across the wires, so there is some sort of interference, though I don't know how much. Regardless this tiny addition to the code fixed whatever issues I was having.

Algae in the tubes really won't harm anything.

Thanks for the feedback though!

author
Sanados made it!(author)2015-08-23

I noticed that as well.
Those led strips may even be to little. (They will suffice at least for winter)

What LegendofPedro mentioned about algue, you really want to change those to black ones and prevent any sun in the water parts.
Speaking about long time, those little things will clog up your system.

author
Zamperweenie made it!(author)2015-08-23

Yeah the strips aren't as powerful as a normal incandescent grow light, but they're certainly better than normal LEDs (or nothing!).

And I suppose you guys have a point with the algae. When and if it becomes an issue I'll just switch it with black tubing then.

author
MikeS73 made it!(author)2015-08-23

you might have an issue with fungus growing in a tank like that . Salt build up with no drainage .

author
Zamperweenie made it!(author)2015-08-23

Yeah I was thinking this. I was gonna see what happens first because drilling through the glass to make a draining system may be a task. But it's certainly something to keep in mind!

author
vann_solo made it!(author)2015-08-23

please display a wiring diagram to show how all of this is connected?

author
Zamperweenie made it!(author)2015-08-23

I don't have any sort of "official" wiring diagram, but nothing is too complex in this. The LCD is hooked up according to the diagram in there and everything else is pretty basic. I hope that helps!

author
Sanados made it!(author)2015-08-23

You may want to add a ventilator (like an old pc vent).
Plants need some "wind" to grow strong. Also fresh air keeps the mold down.

author
smandal13 made it!(author)2015-08-20

great job

author
gada888 made it!(author)2015-08-17

Nice sharing,please provide the link of the LED strip?

author
Zamperweenie made it!(author)2015-08-18

I went ahead and added the link under Step 2: Materials.

author
gada888 made it!(author)2015-08-19

Thanks for your great writeup and effort.

author
tisaconundrum made it!(author)2015-08-18

Just look up led strip on amazon.

About This Instructable

41,788views

477favorites

License:

More by Zamperweenie:GrOwn - A Solar Powered Arduino GardenAn Arduino, Hydroponics, and You: A Solar Powered Microcontroller Garden
Add instructable to: