loading
Picture of Garduino-Automated Gardening System
This instructable is a guide for setting up an automated gardening system using an arduino and other cheap electronic parts.  It allows sustainable gardening by using sensors to determine soil moisture, as well as a webscraper to determine future weather.  It uses this information to save water by only using the requisite amount.   Requirements for this project include experience soldering, some basic programming experience, and much patience for debugging.

See video for example of why we need this.
 
 
Remove these adsRemove these ads by Signing Up

Step 1: Build-Moisture Sensors

Picture of Build-Moisture Sensors
The moisture sensors rely on the resistivity of water to determine the moisture level of the soil.  The sensors measure the resistance between two separate nails by sending a current through one of them and reading a corresponding voltage drop due to a known resistor value.  The more water the lower the resistance, and using this we can determine threshold values for moisture content.
We will use three such sensors and use a multiplexor to alternate reading between them without using more than one arduino analog port.
While we will include a circuit board diagram, we recommend building the circuits on a breadboard first which will allow for both understanding and debugging. 
Each sensor uses two nails, a 100 ohm resistor, and a 100 K-ohm resistor.  We built a casing for each sensor with acrylic tubes, however this is not necessary.

Step 2: Build-Moisture Sensor- 1

Picture of Build-Moisture Sensor- 1
The first step is to find two equal length nails of any type, although we found that longer and non-galvanized nails worked best (galvanized nails do not work at all).  Next, a wire needs to be soldered to each nail.  It is best to use weaved wire since it is  flexible and less likely to break during use.  The nails act as a heat sink, and to counteract this they must be heated before soldering.  A hotplate was used to get the nails very hot.
A word of caution, as the name implies the hot plate gets extremely hot, as will the nails, so please use pliers to remove the nails from the hotplate.
It is useful to shrink wrap the soldered parts of the nails, especially if you are not planning to make a probe structure.

Step 3: Build-Moisture Sensor-2

Picture of Build-Moisture Sensor-2
The next step is to wire the nails to the arduino.  Use the circuit diagram provided.  The sensor works by sending a fake AC current by alternating DC current between the two nails.  The analog voltage is then read and a moisture level can be inferred.  Our code for the whole project will be available.   A picture of the finished sensor with acrylic covering is on the next page.

We read an input voltage into a multiplexor from a voltage dividor created by the 100K resistor. The 100 Ohm resistor, attached to the other lead of the sensor, is used for current limiting. Current limiting imposes an upper limit on the current coming into the arduino, which protects it from short-circuiting.

Step 4: Build-Moisture Sensor-3 (optional)

Picture of Build-Moisture Sensor-3 (optional)
Take a hollow acrylic tube and attach it to a pointed front with two holes for nails. Seal the bottom from water with silicone glue. Make sure that the nails are not touching as this will short the circuit.  Use a rubber stopper to seal the top.  It is important that the nails be equal distances apart on each of the moisture sensors, as any variation could affect resistivity readings from one or more of the probes. 

Step 5: Build-Moisture Sensor-4

Picture of Build-Moisture Sensor-4
To improve performance we used three soil moisture sensors.  However, there may not be enough analog pins on the arduino to accommodate all of these depending on what other attachments you are using.  We solved this problem by using a multiplexer, which allowed us to switch between and read from each of the three pairs of sensors. The circuit diagram is given below.

Step 6: Build-Temperature Sensor -1

Picture of Build-Temperature Sensor -1
For the temperature sensor we used a TC-74 chip.  The wiring here is pretty simple and is shown below.  It is recommended that you use 1K resistors on the ports connecting to the arduino (SDA, SCLK).  The sensor works by exposure of the chip's metal tab. Attaching this metal tab to a piece of sheet metal will increase the sensor's sensitivity over a wider area and improve performance. 

Temperature readings are used to normalize soil moisture content readings, since higher temperatures will increase resistivity between the nails, potentially giving inaccurate readings. It is important to correct for temperature so the arduino will trigger watering at the appropriate time. 

Step 7: Build-Circuit Board

Picture of Build-Circuit Board
Make a circuit board.  The schematic is shown below and the board file is attached.  We used the program EAGLE to design the board, and the files are in that format.

Step 8: Build-Pump System-Relay

Picture of Build-Pump System-Relay
The pump system we created uses a small fountain pump attached to the arduino with a solid state relay, allowing the arduino to turn the pump on or off automatically.  Strip off a segment of the pump's insulating tubing, and cut only one of the inner wires in half.  Attach each end of the newly cut wire to the relay's two outputs.  Be careful to avoid touching any exposed metal on the relay, as it is at a high voltage. We recommend putting electrical tape over the exposed wires.  Finally, connect the relay's ground to the the arduino's ground and the relay's input to an arduino digital pin (in our case 5). 

Step 9: Build-Pump System-Reservoir

Picture of Build-Pump System-Reservoir
The submerged pump needs a constant amount water to function properly.  To automate this process we used a float valve that attaches to a hose and opens when water is needed and closes when the water level rises.  Make sure to drill the hole high enough to give the float valve room, and that the tank is wide enough to accommodate the float.

Step 10: Build-Pump System-Tubing

Picture of Build-Pump System-Tubing
Drill small holes through a length of plastic tubing that is the correct size for the pump.  Then cut pvc pipe into 5-8 inch segments, punch small holes through their centers, and thread the plastic tubing through the holes.  These will be staked in the earth and provide a stable base for the tubing.  One may want to put a point on the bottom of the small pvc pipes so they are easier to stake.  There are many other ways to build the sprinkler system, so check out your local hardware store for some inspiration.

Step 11: Connect

Picture of Connect
photo3.JPG
When connected, the circuit should look like this.  Note: this picture includes a wifly shield that will hopefully be implemented in the future.  Notice that we connected the relay to the wifly shield.  It would be better to put this on the board, however, this was an oversight on our part. 

Step 12: Build-Plastic Enclosure (optional)

Picture of Build-Plastic Enclosure (optional)
We then used a regular plastic box 15x10x6 cm to enclose the circuit board and a separate box to enclose the relay.  The arduino and relay need to be protected from the elements if they are to be placed outside in a garden. This separation allows the relay to get very hot but not damage the circuit board, however, it should not get very hot if using the code provided at the end.

Step 13: Code

The garduino uses arduino and python programs that interact with one another through the library pySerial. The arduino checks the soil moisture content and if low, triggers the python web scraper and find tomorrow's weather forecast.  If the forecast includes rain, python tells the arduino to delay checking soil moisture content for the next 24 hours.  If the forcast is dry then the arduino will be triggered to water.  After this, the system will recheck soil moisture content every twenty minutes to see if more water is needed.  if water is not needed at the initial watering check, or after a recheck, the system waits for 24 hours and the process is repeated.

For the scraper to work, you need to download and install:
- BeautifulSoup
- urllib2
- pySerial

I would recommended creating a github account (https://github.com/) and pulling everything from github. 

We used yahoo's weather api to find tomorrow's forecast: http://developer.yahoo.com/weather/

Look here for some good documentation:
- http://www.crummy.com/software/BeautifulSoup/ (Beautiful Soup documentation)
- http://www.regular-expressions.info/ (Regular Expressions, useful for parsing html)
- http://www.linuxforu.com/2012/03/building-image-processing-embedded-systems-using-python-part-3/ (best example of pySerial I found...much better than pySerial's documentation) 
- http://www.akeric.com/blog/?p=1140 (another good example of pySerial) 

Thanks to Joseph Long for help with the code.

Step 14: Garduino in Action


Step 15: Further Improvements

Further improvements include implementing the wifly shield as well as doing a better calibration of the moisture sensors.  The value that we have for the necessary moisture content to water is estimated and a more careful analysis would help conserve even more water. We would also like to plot real-time data from our garduino using matplotlib and ipython. 

We would like to thank,

Dwight Whitaker
David Haley
Glen Flohr
Tony Brigsby
JamesB45 months ago

Great read!! there are other ways that this can be accomplished also.. FYI the device that is being created is similar to an RTD.. one thing that should probably be touched down on... is if you are running your wires any distance, in order to get correct signal response, be sure to shield your wires and run them in pairs AND ground at one and only one place. Noise can develop from many different devices that you have in your home, this would cause in accurate readings. If making the circuit from scratch.. use a wheatstone bridge that has your variable resistor as your moisture sensor and an op-amp for signal conditioning. All you have do to is step your op amp gain in one direction or the other. I recommend 1-5 volts = 0-100% resistance change. Now that you have a upper and lower range signals.. you can now program your arduino to respond to the serial data input by using C programming

blauerhund7 months ago

Big THX 4 sharing.

Is the Nail really necessary? Why can't the copper cord just be used as the sensor.

indiaritu10 months ago

beautiful and relax with eyes .

crackopl1 year ago

looks nice - needs some improvements like one mentioned by diy_bloke (pump running dry + delay 24hrs). overall - well done :)

see my version for big garden: http://www.instructables.com/id/Watering-Garden-with-GARD-A-WATER-Arduino-Project/

aj339601 year ago

Your project is really cool. What versions of python, serial, beautifulsoup and urllib2 did you use.

aj339601 year ago

Your project is really cool. What versions of python, serial, beautifulsoup and urllib2 did you use.

shemul30912 years ago
waw! so cool ! :D
diy_bloke3 years ago
Upon rereading my earlier comments, I realized that maybe my tone as a far as one can detect one in writing, maybe came across with a harshness that I did not intend at all.

I am not critical of yr project, not at all, I think it is great, but I just had a couple of questions that hopefully cld help me understand and or learn from
diy_bloke3 years ago
Why would you want the delay of 24 hours? In the video you say it is because it has been watered already so it does not need watering for another day. But then what is the sense of the probes??

If yr probes would indicate that the soil is dry after half a day, yr system just ignores that (as I understand) wouldn't it be easier then to just open yr tap once a day and say 'done' and use the arduino for something completely different?

Wouldn't it be more logical to let yr program always react to the readings of the probes.
1 if dry give water, if dry within 24 hrs again, water again
diy_bloke3 years ago
just a question. It is indeed smart not to leave yr pump run dry, but if you have a continous waterflow to the tank, then why use a pum at all. Wouldn't it be simpler then to just use an electric valve to open and close the mains water supply?

Also, I use galvanized material for my spikes and that works great.

Your sensors look fantastic, but it seems a bit overkill to use length of acrylic tube, just to attach 2 nails to. Might as well just put them on the bottom of a bamboo stick with tie wrap, or am i missing a point here? Is there any added value in using the acrylic tubes
Truly remarkable!
thank you for posting! i will try something similar this summer
JSWheeler3 years ago
This is awesome! I actually had a project in one of my engineering classes that asked for something just like this. Good job!