Garduino-Automated Gardening System

271K47218

Intro: 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.

STEP 1: 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

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

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)

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

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

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

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

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

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

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

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)

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

15 Comments

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

I know this is an old thread, but the water tank would make it east to add fertilizer to the irrigation system. Connecting directly to the water line would make this harder.

in order to purchase this online what do we call this circuit board??

hi guys....

i need some help.. will b glad if sum1 helps me out...

ya actually i must let u know dat im in d 9th grade... n im working on a project based on arduino but im facing sum problms with my code....

my project is about the automatic irrigation system... one who is dealing wid arduino may find this out veryyy familiar but im trying to do sum thing different with it...

d basic thing is dat the moisture sensor checks the moisture level of the soil and if it finds it low than the required level... the submersible pump pumps d water and irrigates the plant

.... but wht im doing different is dat..... im going to connect an HC-05 module (bluetooth) and i want that my IRRIGATION SYSTEM AUTHENTICATES ONLY WHEN AN ANDROID DEVICE GETS CONNECTED TO IT....

and i want this output through an app called bluetooth terminal of an android device..

Automatic irrigation system..

Farm no.1

(having 24 plants)

System initialising....

Calculating soil moisture...

soil moisture=xyz

Alert!! Soil moisture is low.. // ( if or else needed )

Calculating temperature...

temperature=xyz

temperature favourable for irrigation.... // ( no need of using "if" or "else"... idea is to show the temperature.. thats all... )

Soil moisure is low.. plants need to be irrigated...

Irrigation system initialising..

watering...

..

.

irrigation done!!!!

NEW soil moisture=xyz

NEW temperature=xyz

// and after this a delay of 5 sec.. and the system starts again..

Automatic irrigation system..

Farm no.1

(having 24 plants)

System initialising....

Calculating soil moisture...

soil moisture=xyz

YUP!! the moisture level is good.. no need of watering...

Calculating temperature...

temperature=xyz

temperature favourable for irrigation....

but the moisture level is well off... no need of irrigation..

NEW soil moisture=xyz

NEW temperature=xyz

PLS someone help me out for code... i know that the superiors will no more than half an hr.. for it.....

pls send me the code on my email.. omkarj1422001@gmail.com

i hope that sum people wud even hv liked this idea... SO plssssss help me people..

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

Big THX 4 sharing.

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

beautiful and relax with eyes .

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: https://www.instructables.com/id/Watering-Garden-with-GARD-A-WATER-Arduino-Project/

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

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

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
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
Truly remarkable!
thank you for posting! i will try something similar this summer
This is awesome! I actually had a project in one of my engineering classes that asked for something just like this. Good job!