<wbr id="glvtv"></wbr>

    <form id="glvtv"></form>

        A cheap soil moisture sensor - GardenBot
        The Soil Moisture Sensor

        You are building a cheap soil moisture sensor so the brain can read the amount of moisture in the soil. The version we are building is very low tech, but it is also very cheap and easy to build. It consists of a block of packing foam with a couple of wires shoved into it. And the great thing is that it's possible to use reclaimed materials in much of it's construction.

         If you cruise around the web, you will find many other types of soil moisture sensor -- some home-made, some commercial. If you want to read a breakdown of what's available and how things work, read the note on different types of soil moisture sensors below.

        * Check it out!
        The new, new soil moisture sensor circuit is here! *

        (see the parts page)
        • galvanized steel wire -- 12 gage or equivalent 
        • packing foam block (e.g. inside a product box for home electronics) -- the slightly flexible kind is better (less brittle than styrofoam)
        • soldering iron and solder
        • lead wires

        The general idea is that we want two probes -- metal rods, kept about equal distance apart, that we can bury in the soil. We will need an electrically non-conductive material to help keep the rods in their fixed position. And we will also want the probes to be insulated everywhere except where we want to take a reading.

        • When you bury the moisture sensor, you may want to bury a soil temperature sensor also as the reading from this sensor is affected by temperature (see below).
        • Remember that you can adjust this sensor by changing the resistor that makes up the other part of the voltage divider (see the local circuit below).

        Here is a diagram for constructing the actual probe.

        This basic cheap soil moisture sensor consists of two probes (the metal rods) held apart at a fixed distance by some insulating material.

        The other factor is that part of the probe is insulated so that you can control at what depth you would like to take the reading.

        So, our sensor starts with a 50mm thick (tall) insulating block. This does keep the rods apart, and is also just a booster -- it's a big, foam block sitting on the soil so you don't accidentally dig up your sensor.

        Next down is the insulated section of the probe (also 50mm). From here down, the probe will be under the soil. If you want to change the depth of the reading, you can just change the length of this insulated section. You will not have to make changes to the local circuit.

        Finally we have the exposed part of the probe (again 50mm). This is the part of the probe that actually takes the reading. You could experiment with different lengths here, but you will have to make changes to the local circuit (to adjust the voltage divider).


        To make the probes, cut two pieces of galvanized wire -- each 200mm (20cm) long. Of course if you have cut this wire from a roll, you will need to straighten it.

        Next, you will need to solder a lead wire to one end of each probe wire -- this will be the top end. Make sure to give yourself enough wire to work with when you bury the sensor outside (maybe 75 to 100cm, around one yard).
        We want each probe to be insulated for most of its length -- notice in the diagram above that only the last 50mm of the probe is exposed metal.
        Now that you have the probe with the lead wire attached, you can insulate the thing by using heat-shrink tubing (see heat-shrink).
        Cut a block of the packing foam to make the top of the sensor. When selecting a foam, look for one that is pliable enough to accept the sensors being jammed through it (sometimes styrofoam is a problem).

        In this photo the block is 70mm wide, 50mm high, and as thick as the sheet I cut it from.

        Mark on the block, on both top and bottom, where you will stab the sensors through. Use the awl (etc.) to make two holes that are parallel -- you may want to stab through from each side.

        And here is the sensor once it is buried in the soil. Note the wires for the soil temperature sensor to the left of the foam block.
        This is the sensor after perhaps one month of use. Notice that the leads have begun to corrode somewhat. But the readings are still very accurate.

        Different types of soil moisture sensors

        There are several different types of soil moisture sensor out there. The Wikipedia article on soil moisture sensors explains some of the different types.

        You might also want to check out the sensor from Vegetronix  (VG400). I will report more -- I am in the process of testing one myself. Though initial tests indicate that our basic cheap sensor has nearly as much accuracy and somewhat better dynamic range.

        Resistance as soil moisture

        The type of sensor we are building in this module is a resistive sensor. The resistive type of moisture sensor is the most crude. It uses the two probes to pass current through the soil, and then we read that resistance to get the moisture level. More water makes the soil conduct electricity more easily (less resistance), while dry soil conducts electricity more poorly (more resistance).

        One problem with resistive sensors is that the resistance of a material changes with temperature. So when the sun beats on the soil and the soil warms up, the resistance changes. This will produce a false "dry" read. For this reason, we employ the soil temperature sensor so GardenBot can use that data to warp the soil moisture to remove the false reading -- i.e. on the chart, the line looks straight.

        One other problem we encounter is due to our use of Direct Current. The problem is that if you have DC current (constantly flowing electricity in one direction) going between two pieces of metal (like the exposed probe tips) then etching will take place. This process is called electrolysis, and it is bad for the probes -- it means that they will be eaten away slowly by the action of the electricity. We solve this by only turning the current on when we want to take a reading. Look at staged processing on the brain module page.

        By the way, electro-etching can be a very cool effect, if you need it. It can be used to do metal etching for a variety of purposes (artistic or otherwise).

        Special note on plaster sensors

        You may have seen sensors out there made of plaster (gypsum). The techniques vary, but generally the sensor consists of two wires or nails which are then sealed within a plug (often a cylinder) made of plaster. The concept is cool, but the problem is that plaster has a behavior that makes it a very poor choice for reading soil moisture.

        Initially when the plaster is dry, it has very high resistance (as you would expect). The problem is that plaster has an affinity for moisture, so as soon as the plaster comes in contact with any moisture at all, the sensor reading will drop to a very low resistance. And even if you completely saturate the sensor, you will not get the resistance to drop much lower than that.

        The plaster based sensor might work as an ambient humidity sensor (yet to test that one).

        The local circuit - simple, voltage flipping style sensor

        This is the new-new moisture sensor -- use this instead of the basic version below.
        The main improvement to the sensor is that we need to run the current both forward and reverse. This allows us to use our cheap two-probe soil moisture sensor without electrolysis ... more or less

        Note: I am looking for feedback on this new design. Please contact me if you have info from your own tests.

        There is still a single sensor read wire (Arduino analog in), and the resistor is still part of a voltage divider with the soil between the probe wires. You will need to try different values for the 57-100K resistor -- this depends on your sensor and soil and you may fall out of this range. The 100 ohm resistor is just for currently limiting if the soil moisture sensor becomes shorted out (like sticking it in water).

        The biggest difference is that you will need two logic pins to control the sensor (Arduino digital out). This circuit is set up so that the two digital pins from Aruduino are used to flip-flop the voltage (running the current forward, then reverse). This back and forth current helps to cancel out electrolysis. That is not to say that electrolysis is not taking place. It is simply that the crust that is created by electrolysis is broken up when the current reverses. So the soil moisture sensor will operate effectively for a longer period of time.

        The sensor reading is a bit different in this new setup. Since the soil moisture sensor is essentially a voltage divider, when we reverse the current, we also swap the relative voltages. This means the the sensor now gives two different readings depending on the direction of the sensor.

        In the software, we need to do a couple of things to use this new setup. We will need to flip-flop two different inputs to make the current go back and forth. And we must keep the readings separate and use a bit of smoothing when combining them. This minor inconvenience is worth the extra life you gain by using this setup.

        If you like, you can download this simple Arduino sketch that flip-flops the voltage between two pins to test your sensor (it's what I use for testing).

        Note: the current GardenBot software package does not support this new voltage-flipping setup.

        And here is what the wiring might look like on your local circuit breadboard.

        The local circuit - H-bridge, voltage flipping style sensor

        This is the same voltage-flipping circuit as above. But this version uses an H-bridge which allows us to control a larger voltage/current. If you find the digital output from the Arduino isn't enough to power your moisture sensor, you can use this circuit.

        And here is what the wiring might look like on your local circuit breadboard.

        The local circuit - basic sensor (prone to electrolysis)

        Here's the diagram for the local circuit portion of this module. You should use the newer voltage-flipping version above.

        The circuit is mainly a voltage divider - the soil moisture sensor is one half and the 57K resistor is the other half.

        There is also a noise filter - the 47uF capacitor going to ground. And of course, an output so the Arduino can take a sensor reading.

        Note: If your sensor does not give you usable readings even after it has been buried for a week or so, you may need to adjust it. To adjust this sensor, you can change the value of the resistor. When you have some chart data so you can see the behavior of the sensor, you will be able to see if it is drifting nicely in the middle somewhere, or if it is peaking out (hitting the top or bottom of the graph - which means you are loosing data). By changing the value of the resistor, you can adjust the operating range for this sensor so that all your data shows up in the middle of the graph somewhere.

        And here is what the wiring might look like on your local circuit breadboard.

        about how-to parts contact GardenBot home forum