Garduino Upgrade, Now With More Twitter!

118K43622

Intro: Garduino Upgrade, Now With More Twitter!

A couple months ago I came across two great instructables.  The first was the Garduino, an arduino controlled garden to help you grow plants at home.  The second was the Tweet-a-Watt, a project that teaches you how to monitor your home power usage using Xbees and Twitter.  I read about both these projects here at Instructables and in Make Magazine, Vol 18

I thought it would be great to combine both these projects and build myself an indoor garden that I could monitor from work via Twitter.  Thus began an adventure in gardening and electronics that taught me a lot and took me much longer than perhaps it should have.  Fortunately for you I'm going to write down all the steps so you can get started right away.  Maybe you'll follow up with this project and upgrade your garden or use this as a guide to start on a similar project.  Either way, I hope you'll let me know what you get up to.

If you're ready then head to the next step and begin the process!

Edit: Please see the code now posted on GitHub - https://github.com/chrisgilmerproj/garduino-upgrade

STEP 1: Gather Your Materials

This project is really two projects in one. It is both a gardening project and a wireless project. But, as is true with any project, getting your materials will probably be the hardest part. This is because building can move along pretty fast once you have everything, but it's finding out you're missing the one crucial piece that always holds things up. Below is a list of web pages from my wiki with a list of all the parts you'll need. Go ahead and take a look, I've listed them with as much detail as I could and if I've left something out just let me know so I can add it to the list.

Various Parts Lists:

I highly recommend you buy a couple extra parts here and there. You'll find, as I did, that they come in handy when you make a mistake. For the majority of the parts nothing is particularly expensive so buying a few extra things won't hurt.

STEP 2: Build Your Garduino

The Garduino Instructable is probably your best resource for starting this project.  It has tons of great insights that will help you get started with your own arduino controlled garden.  He has also put together a website with more pictures and a kit that you can get, but I chose to build this project with my own parts.

When you get started you'll want to get some plants and a place to plant them.  I recommend a local gardening store where possible.  You'll pick up some healthy plants there and probably a few good tips on how to care for them.  I picked up basil and mint, a couple plants I'd find useful to have for cooking.  I also got an 8" x 18" planter with a matching dish to catch water.  You can certainly go out and use tubs or custom pots, just choose what's right for you and your plants.  Also, pick something that will look nice around your house if that's important to you.

The first thing that is different about my project is that I was building an indoor garden.  My apartment doesn't have a lot of light from any of the windows, nor does any good light fall on the patio.  This changed a lot of the parameters for my garden.  For one, I didn't need a light or temperature sensor, something I discovered after the fact, as my light will be constant from the fluorescent bulb and my temperature inside the apartment is pretty stable. 

I also learned that whether you choose to keep your plants inside or outside you should be aware of bugs.  My first plants died because of spider mites, something I hadn't even thought of when starting this project.  I found the solution was actually pretty easy, involving a spray bottle, a tiny bit of soap and water.  It's a much cleaner solution, especially if you plan to eat your plants, and doesn't hurt the environment either.

STEP 3: Upgrade #1: Remote Sensors

One of my early upgrades to this project was to take the sensors off the arduino and put them closer to the plants.  I wanted to do this primarily to keep the arduino as far away from the water and water pump as possible.  The nice thing about this is that you can put your arduino somewhere accessible and safe and keep the sensors you want closer to the plants, where they are needed.  Is this a good idea?  Maybe, but I was happy to do it.

My sensor was designed to have the temperature, light and moisture sensors onboard.  Also, I included 2 red LEDs so that I could indicate if the plants were being watered or if the temperature went out of an acceptable range.  Of course this was before I had decided to keep the plants indoors, so in retrospect I'd probably ditch the temp and light sensor and leave the LED on the arduino.  Better yet I could have just used the onboard LED connected to pin 13 on the arduino.  Then all I'd have is two wires leaving the arduino to act as the moisture sensor for the plant.  Regardless, this was a fun part of the project and I learned a lot.

You can download the schematic and board layout files I created.  I decided to build the board by hand instead of having it manufactured for me primarily due to cost.

STEP 4: Update #2: Relay Boxes

The most important upgrade I think I made was to build real relay boxes to control my power to the light and the water pump.  With water so close to the electricity I figured a safer approach was needed than the one used in the original Garduino instructable.  Fortunately the author pointed out a great resource at SparkFun that I used to do the project. 

Finding the whole thing incredibly useful I wrote up another instructable on how I built my relay boxes and made it more generic for other projects where you might want an arduino to control power.  Check out the Arduino Controlled Relay Box Instructable when you get a chance.

At this point I decided to add on an arduino protoboard to my project so that I could have access to more power lines without having to solder together a new breadboard.  You may choose to do something different, but this made things significantly easier, especially if I decide to do more modification later.

If you don't do anything else with your Garduino definitely do this upgrade.  It's definitely the most important.

STEP 5: Upgrade #3: New Software

Now it's time for the software upgrade.  With an indoor garden I no longer had the need to have the entire project be automated within the arduino.  The original arduino kept an internal clock and counted the amount of daylight from the light sensor against the number of seconds in the day.  I found this to be more frustrating than it was worth once I moved inside and stopped using the light sensor.  This was primarily because I found that the light cycle revolved around when I power cycled the arduino, having no way to set the internal clock myself.

In fact I thought I could do a better job regulating the time from my laptop.  Not only would the light only be on at night and in the morning when I wouldn't care, but I could reset the arduino power at any time and it wouldn't change this schedule.  The added advantage to this method would be that I'd also be able to record the sensor readings from the garden to look at them later. 

To get started you have to know that the arduino can talk over a serial connection to your laptop.  You probably already knew this, but what you may not know is that you can use the Python programming language to read and talk to the arduino.  This is great because it opens up all sorts of tools for you to use when interacting with your arduino.

For this you'll need to download and install the following:At this point I also want to direct you to the Arduino Controlled Servo Robot project by Oomlout.  My methods roughly follow what I learned there.  The basic premise is that you'll be sending a command from the laptop to the arduino every 15 seconds.  The arduino will decode this message, check that it is a correct message, and then the arduino will use the commands to manage the garden.  If no message is received then no new actions will be applied to the garden. 

I choose to send a command that looks like this: "+++lw".  The arduino can tell if the message is correct by reading that I have included the "+++".  Then I pass the letters 'l' and 'w'.  If the 'l' is lower case then it tells the arduino to turn off the light.  If the 'l' is an uppercase 'L' then the light will come on.  Easy, right?  

The 'w' is trickier.  I have included some safety protocols in my software.  The arduino will only turn on the pump for a maximum of 5 times for 5 seconds each time.  You may wonder how a plant will live on only 25 seconds of watering.  Well I reset the counter every 4 hours.  This way the plant will continue to get water and my kitchen will not continue to get flooded.  The 'w' as a lower case tells the arduino nothing useful, but if I change the 'w' to an uppercase 'W' then the pump counter will reset to zero and the arduino can again water my plant if it's necessary.  Make sense?  You may want to something slightly different, but this worked for me.

Instead of including the code in the text here I've decided to include files.  You should be able to open these with your Arduino IDE for the arduino code and with IDLE or a text editor for the Python code.

STEP 6: Upgrade #4: Wireless Control

Now comes the exciting part!  It's probably not likely that you can leave your computer connected via USB to your arduino all day long in your kitchen.  If you can that's great, but I need my laptop in my office where I find it useful.  This is where my experience with the Tweet-a-Watt came in handy.

Early on I decided to use Xbee wireless devices to talk between my computer and the computer.  Now I apparently did things the hard way because I thought you'd need to send the data through the Xbee controller from the arduino and then decode it on the other end with the Xbee Python library.  This turns out to be completely untrue.  You certainly can do it this way, but it's way harder than simply using the Xbee modules as a direct serial link to your computer.

It may have taken me hours, but this step shouldn't take you very long once you've set up your Xbees.  Essentially you remove the USB cable between your computer and the arduino, hook up your Xbee modules (one to the computer via an FTDI cable and one to the arduino via tx/rx lines), and then continue as though you were still using the USB cable.  Don't believe me? Try it.  Maybe this was obvious to other people but it was pretty exciting when I figured it out.

Now I should tell you there are several steps to doing this whole wireless step.  You need to first purchase and assemble the Xbee modules.  Then you'll want to program each of the Xbee chips and finally connect them up.  The best resource I found for setting up my modules was actually a tutorial about Wirelessly Programming your Arduino.

I decided to set up my arduino to be wirelessly programmed so that I could easily update the code from my laptop when I needed to upgrade my arduino.  This was an added bonus to being able to wirelessly talk to my arduino via serial and it just seemed to sweeten the whole project.  I also found this made some of the debugging easier since I needed to do a lot of writing and rewriting to the arduino.

STEP 7: Update #5: Twitter Your Garden

Now you've got your garden all hooked up to your computer and talking wirelessly to the computer.  You may even be recording your data to a file to look at it later.  What you may not be able to do yet is monitor your plants while you're at work.  To do this I employed Twitter, much like the Tweet-a-Watt did.  I signed up for an account that I could use for testing, @chrisgilmertest.  Then I hooked my code into the Python Twitter API, entered my user name and password, and voila!  I was done.

I set up my twitter to send back the readings for the different sensors and the current time.  I know you can track the time you posted, but I wanted the time from my computer.  I also decided to have it tweet every half hour.  When I originally was programming this I had it tweet every 5 minutes, which was good when I wanted to ensure it was actually working, but got annoying to follow pretty quick.  I may actually have it tweet every hour or couple hours in the future.  You get to decide what you want for yourself and go from there.

I have asked friends to help me come up with some silly messages for my garden to tweet, based on the sensor readings, so maybe I'll get some snarky comments up there soon.

You may have noticed that this code was already provided to you earlier in this Instructable.  My hope was that you got excited and already started to play with it.  If not, what are you waiting for?

STEP 8: Useful Project Notes

I learned a bunch of useful things while doing this project and I wanted to make sure I captured them here for you.  Hopefully I've written them all down because they are mighty handy:

Plants:
When it comes to plants remember that they are indeed alive.  They are also tasty, not just to you but often to other things as well.  My first plants were eaten by cats and then destroyed by spider mites.  I never would have thought about this during the planning stage of the project and it definitely cost me a few extra bucks to replace them.  

Lighting:
Plants need light and it can be tough finding the right set of lights.  There is plenty of information out there about lights for growing plants but it turns out to be incredibly difficult to find these lights at a local hardware store.  It took me a while but after asking around I was directed to a Hydroponics Store.  You know the kind (wink, wink), and they hooked me up in no time at all.  Pun partially intended.  The people were great at the store and definitely reminded me of why I like to buy local when possible.

Water:
You've got to be really careful when you get started with automatically watering your plants.  The soil resistivity will change dramatically as you first start to water it, meaning your calibration of the sensors will be difficult.  I found this out the hard way when my pump decided to water not only my plant but my entire kitchen.  It's better to program in some safety catches in the software to prevent this.  My plants will only water for up to 30 seconds at four different times in the day and no more.  It may be different for you, but be warned.

Wireless Programming:
You may have set up your arduino to be wirelessly programmed.  I did and I found the only annoying thing is that I'd reset my arduino when I reset my computer.  Turns out I was flipping the reset line on the arduino via the Xbee.  The easiest solution to fix this was to disconnect the reset line whenever I didn't want to reprogram.  I could still leave the other electronics in place, but removing the reset line fixed the problem without having to disassemble anything else.

Final Comments:
I had a lot of fun building this project.  I learned a lot along the way and I hope to have some delicious plants for eating after all this work.  I hope you found this project interesting and useful for upgrading your own Garduino.  If you do follow any of the upgrades in this project let me know and tell me how they worked out for you.

You can always ask for more information or check out my website for more information.  I keep a blog, a project wiki, and an svn repository with the latest code.  I also have a set of photos you can look at.  Hopefully it's all up to date and full of resources to help you out.  Good luck with your project!

PS - If you like this project please vote for it in the "Arduino Contest" and help me win!

23 Comments

author's own site is currently broken, but you can get parts list etc. from the Internet Archive's 2013 copy ( https://web.archive.org/web/20130328204841/http://wiki.chrisgilmer.net/index.php?title=Garduino )

please give me the various parts list. i cannot acess it from the link provided..

https://web.archive.org/web/20130328204841/http://wiki.chrisgilmer.net/index.php?title=Garduino

Very cool stuff. A word to the wise though, while the foil is shiny, it is still silver in color, which is just a very light black. You'd be better off with an opaque white material. In my photography I fould that using ordinary foamcore board is an amazing reflector of light, and is more efficient at it than foil. Maybe this could work for your design.
Hey, I appreciate the comment on the foil.  I wouldn't have thought of that and now I may try to switch it out.  Foil just happened to be cheap and available in my kitchen, so I figured it would work here.  Thanks for the advice!
The mylar that was suggested earlier has really helped me with my projects. If i remember my numbers correctly it was almost 200 lumens more than when I wasn't using it. I just cut to size an old emergency blanket that came out of a first aid kit. It does reflect heat back as well which is helpful for growing in winter months.
What equipment did you use to measure the lumens in your grow setup?
I used a soil meter from the local home depot... something like http://www.amazon.com/Bond-9629-3-Way-Garden-Moisture/dp/B000UJTOEO/ref=sr_1_1?ie=UTF8&qid=1316452006&sr=8-1

i will grant that it probably isn't the most accurate thing in the whole world...

I will probably go to something like this mastech unit later. But I'm going to be out of the loop for about a year, so it will be some time before I can start playing around with stuff again :-(

http://www.amazon.com/Mastech-Digital-Illuminance-Light-LX1330B/dp/B000S19W3W/ref=sr_1_1?ie=UTF8&qid=1316452054&sr=8-1
mylar is ideal and white (2 ply greenhouse plastic is white on one side and black on the other) is next best, aluminum foil isn't "black" at all but it certainly makes consistently uneven lighting which is bad for plants.
I'm not sure if it's real mylar or not but a cheap way to get a super reflective material is to buy a few of those "space blankets" they sell in Army surplus stores, you can usually find them for around $5 (in the U.S. anyway).
You might want to check your cars first aid kit as they usually come one with one, just hope you don't need it =)
Most of this is beyond my ken and or cash reserves. I came upon this item searching for help with a way to utilize a remote announcer thing from Harbor freight tools that does real well (range over 200 feet) but not all I'd like. It flashes a light and makes a sound whenever anyone/thing passes by the remote unit.

I would like to figure out a way to take the output (light/sound) and wire in a relay to control say 120VAC to ring a louder bell or flash more lights or set off an X-10 code (their remote sensors don't work at the range the HFT unit does).

I belong to a Google Group on Woodworking that's pretty good but have not found a similar discussion group where one might post such queries and get something other than SPAM and offers of free sex.

If you can help . . .

Thanks
One direction to look into is wire in transistors to switch an AC relay. This is well documented, but I wouldn't advise any beginner to work with exposed AC. See next paragraph instead.

A much easier and potentially safer route is to wire an AC or X10 remote control or other remote control. There are a lot of tutorials for using a micro to control a remote control (the book Practical Arduino has one example, but search the web). Basically you would use a pin from the arduino to electrically simulate a button push (bridge the switch) on the remote. This is a very good beginner-intermediate project.
This is a very nice setup, and i really loved to read your instructable. I ordered myself a arduino uno, and i'll be building this one, with my own needs offcourse. If you want to keep plants indoor, i suggest making a growbox that's light proof and airproof. I would add ventilators and a temperature and moisture sensor to keep things under control. I would allso install the light sensor, just to see when the lamps are worn and give less light. In your growbox you play god so anything is possible. An fusebox in metal would house the electronics, safely away from water and inside an automated sprinkler from a fire extinguisher. With low currents this is not necessary, but in my case i'm controlling a 600 watts growlight. I would allso add more soil moisture setups which will control my pump and give water through spikes. Allso air circulation is a must have to avoid "dead" spots between the leave"s and stems. Another system i have is taking water from a rain collecting container of a 1000 liters wich feeds my "feeding" barrel. Rain water is still the best for growing plants. The possibilities are really endless, you could allso inject co2 so your plants grow faster...

Keep up the good work ;)
As a former hydro store employee, like to chime in with a few points - aluminum is very reflective but foil has a very uneven surface so the light scatters in more directions, lessening the intensity - that would be a better trait very near a light source (notice how they don't put mirrors (which are backed with vacuum evaporated aluminum usually) in the HID light reflectors, but instead rough or hammered metal surfaces to prevent hot spots from occurring). Mylar is more reflective than a bright white surface but we're only talking 10% more reflective than the black and white poly tarp someone mentioned above - nicknamed 'panda film.' The panda film is very good for covering large areas and usually sold off of rolls by the foot (it comes off ten foot wide, but it's folded on the rolls so only looks about three feet wide in the store), whereas for mylar you're usually stuck buying a whole roll (at least, hydro store wise). If you have a store like Tap Plastics nearby, you can buy mylar from them, usually by the yard.

If you're attempting to control atmospheric conditions such as humidity and temperature, getting foam-core insulation panels and taping some mylar/panda film to the inside and then making a box of them around your grow area is fairly effective, but a fan to vent excess humidity / temperature is a must in a mostly or fully enclosed area (unless you have other ways of controlling those) - keeping the water reservoir outside the grow chamber helps prevent excess humidity from building up.

A fan is good in any case because it will keep fresh gasses circulating amongst your leaves and even out humidity and such to prevent mold, as well as keeping your plant stems in motion and strengthening them. When my friend was experimenting building his own LED grow lights, we just used some computer fans since the power supply was compatible, they actually ended up helping to make up the difference between the power consumption of the LEDs and the power output of the supply (because all our electronics were hand tooled without any fancy microcontrollers like you kids have today).

This is an awesome project, and I'm totally bummed I can't afford to build something like this to take care of my bonsai - though I'd need soil moisture sensors and the ability to water on a per-plant basis ... or have to re-pot all of the little trees in such a way as they'd dry out at the same speed.
I am a little confused how did you hook up the tweet-a-watt with the graduino ??
well first i think i might  be a little confused what this project is .  i guess it's kinda cool  if you want to tinker around  but some light timers... any how
use Mylar its really reflective and you can  buy a forum of it at the 99 cent store
tho its extremely thin and  can be hard to work with if you get the  kind from the
hydro store it's like 25 bucks for 20 feet and alot thicker  but yeah i can see why  you used the foil and now  the lights..
lights,  the  cheapest !! lights  you can get  i recommend the  light fixture at wal mart for  like 12 bucks  t12 48in  bulbs  i would get  the  cool white  with the blue  labeling for the vegetative  growth  in a leafy green plant 6100k to 6500k
should  make your  herbs grow  nice if you have  t5 lights  those are  nice  but  more expensive  thay have them at homedepot for 35

 >>but some light timers...

but you could take it so much further and have automated controls from everything to light, heating, ventilation, watering. some stepper motors and your lights on a track and you could simulate the movement of the sun, aeration in hydro settups, why have your pumps going full blast when the lights are off?

i mean this just all off the cuff but the ideas are endless!
 Looking at the attached .pde file, I'm not seeing any programming to receive commands from the serial via python.

I'm new to Adruino and just wanted to understand.
Well, I knew I wasn't completely crazy.  There are two versions in my code repository and I grabbed the wrong one.  Try this link, it should have the code you need:

http://svn.chrisgilmer.net/viewvc.cgi/project/completed/garduino/arduino/garduino/garduino_pde/garduino_pde.pde?revision=22&view=markup
More Comments