Soil Moisture sensor

Aditya Kekre
4 min readJun 5, 2020

Ever thought of a home automated watering system in your own garden? A garden that automatically gives the measurement of the moisture content of the soil, waters plants automatically, and gives you the readings of the wetness of the soil, then you will definitely need a Soil Moisture Sensor. With the help of Arduino and soil sensor, you can turn your ordinary garden into a smart which waters the plants automatically and keeps them and the soil in good condition.

Through this blog, we will look at how exactly Soil Moisture Sensor works and how to interface it with Arduino.

Working of Soil Moisture Sensor

The soil moisture sensor consists of two probes that measure the volume of water in the soil. The 2 probes allow the electric current to pass through the soil and, according to its resistance, measures the moisture level of the soil.

Most soil moisture sensors are designed to estimate soil volumetric water content based on the dielectric constant of the soil. The dielectric constant can be thought of as the soil’s ability to transmit electricity. The dielectric constant of soil increases as the water content of the soil increases. This response is due to the fact that the dielectric constant of water is much larger than the other soil components, including air. Thus, the measurement of the dielectric constant gives a predictable estimation of water content.

When there is more water, the soil conducts more electricity, which means that the resistance will be less. So the moisture level will be higher. Dry soil reduces conductivity. So, when there is less water, the soil conducts less electricity, which means it has more resistance. So the moisture level will be lower.

There are many different types of Soil Moisture Sensors but their working principle is the same. All of these sensors have at least three pins: VCC, GND, and AO. The AO pin changes according to the amount of moisture in the soil and increases as there is more water in the soil.

Connections

  1. Connect the two pins from the Sensor to the two pins on the Amplifier circuit via hook up wires.
  2. Connect the Vcc from the Amplifier to the 3.3V pin on the Arduino and the Gnd pin to the Gnd pin on the Arduino.
  3. Now connect the Analog Data Pin to the A0 pin on the Arduino.

Code

#define SensorPin A0

float sensorValue = 0;

void setup() {

Serial.begin(9600);

}

void loop() {

for (int i = 0; i <= 100; i++)

{

sensorValue = sensorValue + analogRead(SensorPin);

delay(1);

}

sensorValue = sensorValue/100.0;

Serial.println(sensorValue);

delay(30);

}

Write the above code on the Arduino software and verify/debug it. For each soil moisture measurement, we took an average of 100 sensor data to make the data more stable and accurate. You can modify the code as per your requirements. After verifying the code, upload it on the Arduino board.

You can check the working of the sensor when you dip the sensor leads in a water-filled soil and in a dry one. You can keep these values as a reference for future use. Also, please note that the sensor may get oxidized in the soil after 10–12 months and lose its accuracy. Thus, you will have to replace the sensor every year.

For better display, you can also connect an LCD Display for showing the results of the amount of moisture in the soil.

Thus using an Arduino and a Soil Moisture Sensor you can make your garden smart and a home automated watering system. You can try this experiment with different development boards like Raspberry Pi boards and many more. Get Additional Information on Soil Moisture Sensor along with some of its accessories. See more of such interesting sensors and try out their interesting projects.

The above image of working and connection of Soil Moisture Sensor with Arduino is taken from randomnerdtutorials and electronicwings respectively. The Content is referred from create.arduino.cc

--

--