The moisture sensors rely on the resistivity of water to determine the moisture level of the soil. The sensors measure theresistance between two separate nails by sending a current through one of them and reading a corresponding voltage dropdue to a known resistor value. The more water the lower the resistance, and using this we can determine threshold valuesfor moisture content.We will use three such sensors and use a multiplexor to alternate reading between them without using more than onearduino analog port.While we will include a circuit board diagram, we recommend building the circuits on a breadboard firstwhich will allow for both understanding and debugging. Each sensor uses two nails, a 100 ohm resistor, and a 100 K-ohmresistor. 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 workedbest (galvanized nails do not work at all). Next, a wire needs to be soldered to each nail. It is best to use weaved wire sinceit 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 thenails 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-2The next step is to wire the nails to the arduino. Use the circuit diagram provided. The sensor works by sending a fake ACcurrent by alternating DC current between the two nails. The analog voltage is then read and a moisture level can beinferred. Our code for the whole project will be available. A picture of the finished sensor with acrylic covering is on thenext 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 currentcoming 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 siliconeglue. 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 resistivityreadings from one or more of the probes.Step 5: Build-Moisture Sensor-4To improve performance we used three soil moisture sensors. However, there may not be enough analog pins onthe arduino to accommodate all of these depending on what other attachments you are using. We solved this problem byusing a multiplexer, which allowed us to switch between and read from each of the three pairs of sensors. The circuitdiagram 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 recommendedthat you use 1K resistors on the ports connecting to the arduino (SDA, SCLK). The sensor works by exposure of the chipsmetal tab. Attaching this metal tab to a piece of sheet metal will increase the sensors sensitivity over a wider area andimprove performance.Temperature readings are used to normalize soil moisture content readings, since higher temperatures will increaseresistivity between the nails, potentially giving inaccurate readings. It is important to correct for temperature so the arduinowill 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 thearduino to turn the pump on or off automatically. Strip off a segment of the pumps insulating tubing, and cut only one of theinner wires in half. Attach each end of the newly cut wire to the relays 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 relays ground to the the arduinos ground and the relays 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 valvethat attaches to a hose and opens when water is needed and closes when the water level rises. Make sure to drill the holehigh enough to give the float valve room, and that the tank is wide enough to accommodate the float.
Drill small holes through a length of plastic tubing that is the correct size for the pump. Then cut pvc pipe into 5-8 inchsegments, punch small holes through their centers, and thread the plastic tubing through the holes. These will be staked inthe 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 theyare easier to stake. There are many other ways to build the sprinkler system, so check out your local hardware store forsome inspiration.Step 11: Connect
When connected, the circuit should look like this. Note: this picture includes a wifly shield that will hopefully be implementedin the future. Notice that we connected the relay to the wifly shield. It would be better to put this on the board, however, thiswas an oversight on our part.
We then used a regular plastic box 15x10x6 cm to enclose the circuit board and a separate box to enclose the relay. Thearduino and relay need to be protected from the elements if they are to be placed outside in a garden. This separationallows the relay to get very hot but not damage the circuit board, however, it should not get very hot if using the codeprovided at the end.Step 13: CodeThe garduino uses arduino and python programs that interact with one another through the library pySerial. The arduinochecks the soil moisture content and if low, triggers the python web scraper and find tomorrows weather forecast. If theforecast includes rain, python tells the arduino to delay checking soil moisture content for the next 24 hours. If the forcast isdry then the arduino will be triggered to water. After this, the system will recheck soil moisture content every twenty minutesto see if more water is needed. if water is not needed at the initial watering check, or after a recheck, the system waits for24 hours and the process is repeated.For the scraper to work, you need to download and install:- BeautifulSoup- urllib2- pySerialI would recommended creating a github account (https://github.com/) and pulling everything from github.We used yahoos weather api to find tomorrows 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 ofpySerial I found...much better than pySerials documentation)- http://www.akeric.com/blog/?p=1140 (another good example of pySerial)Thanks to Joseph Long for help with the code.Step 15: Further ImprovementsFurther 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 helpconserve even more water. We would also like to plot real-time data from our garduino using matplotlib and ipython.