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.
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 electronics will be damaged by the rain, dew or hose water.

A relay can be used to periodically reverse the connection to the probe spikes. This may reduce the damage as the etching of, and deposition to, the polarity of 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 better to consider a capacitive probe as it is insulated from the soil.
An issue with these sensors is that they 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 will result in one of the probes being eaten away and deposits forming on the other. One cheap unit only lasted a few days in my garden before the tracks were corroded and partially eaten away.
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.
NOT RECOMMENDED