Brigadoon - An Occasional Corner on the Internet
Soil Moisture Sensor
Designed by Mark Little
The soil moisture sensor is essentially two spike probes pushed into the soil and the resistance between the two probes. As the soil becomes more moist, the soil conductivity rises and the resistance decreases.

Unfortunately, the resistance between the two probes also depends on the intrinsic conductivity of the soil and the soil temperature. As a result, it is difficult to calibrate the soil moisture sensor to make a direct reading of soil moisture.
Not only is soil conductivity affected by the chemical composition of the soil, it is also influenced by how tightly packed the soil is around the sensor probes. A longer term issue is that these sensors normally have a D.C, potential across the probes to take the measurements and this makes the probes subject to electrolysis in some soil types. This can result in one probes being eaten away and deposits forming on the other.

If electrolysis turns out to be a problem, a relay can be used to periodically reverse the connection to the probe spikes. This will reduce the damage as etching of, and deposition to, the spikes will be periodically reversed. It should be noted that this will delay the eating away of the probes, but not prevent all damage. Given the low price of the sensors, it is probably easier to replace the spikes when necessary, rather than spending the effort to protect the probe.

Even with all of these limitations, the two probe sensor is a cheap and convenient way of measuring the relative amount of moisture in the soil. The soil moisture probe electronics modules, as shown by the example above, normally have one connector with two (2) pins to allow the probes to be connected (the polarity of the connection between the soil probe and the circuit board is not important. There is also a four (4) pin connector which normally has the following connections.
Pin Function
VCC Supply Voltage to the Senor. Typically +5V, but check the datasheet
GND Ground or Earth connection for the supply voltage and the sensor output
AOUT Analogue Output - Voltage proportional to the measured soil moisture. Note; depending on the sensor, the voltage may  be inversely proportional to the soil moisture. Check with the sensor documentation,
DOUT Digital Output - Digital output that goes high when the sensor reading exceeds a value determined by the setting of the potentiometer on the circuit board.
Mounting the Sensor

While the circuit board used to create the probe spikes needs to be pushed into the moist dirt, the same does not go for the connector on the top. The electronics board, the probe connector, and the connecting wires that are normally provided, are not designed to be out in the weather or the UV radiation from the sun. Iti s recommended that, at the very least, some form of weather protection is provided, otherwise the system will have a very short life span.