Soil Moisture Measurement With Arduino

About: I am someone who takes work ethics very seriously. I am honest in my position. Always try to make my world peace and beautiful.

The Soil Moisture Sensor is used to measure the amount of water inside the soil and provide the moisture level or the level of dryness or dampness of the soil. The output of this sensor helps to judge if there needs water or not in the soil. The sensor is mostly used in the garden or cultivation land to reduce human involvement.

Step 1: Working of Soil Moisture Sensor

A moisture sensor has two long probes which are pushed in the soil to measure the amount of water in the soil. These two flow the current to the soil and identify the resistance of the soil and convert the value to the moisture value.

In here, where there is more water, soil conducts more current, so the resistance will be lower and moisture level will be higher. On the other hand, dry soul conducts very less amount of electricity because of very low amount of water, so the resistance is higher and moisture will be lower.

There is a mapping for the level of moisture. Sensors are mainly mapped within 0 to 1023 values. So for different level of moisture, the mapping of the moisture sensor is given below-

  • If the sensor value is 1000 or more than that then the sensor is not in the soil or sensor is disconnected.
  • If the sensor value is more than 600 but less than 1000 then the soil is dry.
  • If the sensor value is 370 to 600 then the soil is humid.
  • If the sensor value is less than 370 then the sensor in the water.

Step 2: Hardware Specification

Soil moisture sensor have two parts. One is the sensing part with probes and other one is data processing MH Sensor Series part.

i. Sensing Part

ii. MH Sensor Series

In the probes part, there are two pins in the sensor which are like positive and negative point of a source voltage. These two points connected to the MH sensor and it processes the data to values and sends to the microcontroller. Microcontroller processes those data to human readable value.

MH Sensor Series works like an analog to digital converter (ADC) of sensor value. There is an adjustable variable resistor in it which helps to fix the reference point of sensors. It also helps to get lower voltage output values or higher voltage output value from the sensors. The MH sensor also have a potentiometer to set the threshold value to compare with a comparator.

The MH sensor have four pins which are connected to the microcontroller.

A0: Analog output

D0: Digital output

GND: Ground

VCC: Power Source


Soil moisture sensor's output can be used both as analog and digital output.

Step 3: Analog Mode

In analog interfacing mode, the sensor will give the percentage value of the moisture. The sensor gives value from 0 to 1023 and microcontroller will map the value to the percentage from 0 to 100.

The range can be changed depending on the climate of that place. Developer can change the range on the code and takes action for the changing value.

Code:

void setup()

{

Serial.begin(9600);

pinMode(A0, INPUT);

}

void loop()

{

int mois = analogRead(A0);

Serial.print(mois);

Serial.print(" - ");

if(mois >= 1000) {

Serial.println("Sensor is not in the Soil or DISCONNECTED");

}

if(mois < 1000 && mois >= 600) {

Serial.println("Soil is DRY");

}

if(mois < 600 && mois >= 370) {

Serial.println("Soil is HUMID");

}

if(mois < 370) {

Serial.println("Sensor in WATER");

}

delay(2000);

}

Step 4: Digital Mode

To connect the soil moisture sensor FC-28 in the digital mode, we will connect the digital output of the sensor to the digital pin of the Arduino. The Sensor module contains a potentiometer with it, which is used to set the threshold value. This threshold value is then compared with the sensor output value using the LM393 comparator which is placed on the sensor module.

The LM393 comparator will compare the sensor output value and the threshold value and then gives us the output through the digital pin. When the sensor value will be greater than the threshold value, then the digital pin will give us 5V and the LED on the sensor will light up and when the sensor value will be less than this threshold value, then the digital pin will give us 0V and the light will go down.

Code

int led_pin =13;

int sensor_pin =8;

void setup() {

pinMode(led_pin, OUTPUT);

pinMode(sensor_pin, INPUT);

}

void loop() {

if(digitalRead(sensor_pin) == HIGH){

digitalWrite(led_pin, HIGH);

}

else {

digitalWrite(led_pin, LOW);

delay(1000);

}

}

Share

    Recommendations

    • Optics Contest

      Optics Contest
    • Plastics Contest

      Plastics Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018

    Discussions