Everything about Soil moisture sensor, working, and Arduino interface

Soil moisture sensor measures the volumetric content of water in the soil. This sensor is widely used in smart irrigation and smart gardens. In this article, we will learn how soil moisture sensors work and how we can interface it to Arduino.

Working of soil moisture sensor

Soil moisture sensors have two probs which inserted into the soil. The sensor is basically a variable resistance. Conductivity between probs depends on water present in the soil. A low level of water means low conductivity and more resistance similarly, more water more conductivity less resistance.

Soil moisture sensor overview

The sensor consists of two components probe and a module.

The probe has exposed conductors which go directly into the soil. If you look closer the conductor has a 2cm zone of shining metal with respect to the flat surface of the sensor this area is responsible for conductance. The sensor average the water content over the entire length of the sensor.

The Module connects the probe to the Arduino. This module has a built-in potentiometer to adjust the sensitivity. The module also has an LM393 comparator.

apart from that module also has power and status LED.

Soil moisture sensor pinout

The soil moisture sensor module has a total of 6 pins. Two pins are to connect the probe and the rest four pins are:-

  • A0 (Analog output) provides an analog signal
  • D0 (Digital Output) Provide digital signals
  • Vcc 3.3v-5v
  • GND Ground

Soil moisture sensor features

  • Sensor Operating voltage 3.3v to 5v.
  • Dual output mode digital and analog.
  • Panel PCB Dimension: 3cm x 1.5cm.
  • Soil Probe Dimension: 6cm x 3cm.
  • Cable Length: 21cm.
  • Power (Red LED) and output(Green LED) indicator.

Soil moisture sensor Connection with Arduino

The connection of soil moisture is very simple.

  • Connect module A0 to Arduino A0,
  • Vcc of the module to Arduino 5v
  • GND of the module to Arduino GND

Code

The following code will give you row data. Calibrate your sensor, insert the probe into dry soil and note down the value.

#define AOUT_PIN A0 // Arduino pin that connects to AOUT pin of moisture sensor

void setup() {
  Serial.begin(9600);
}

void loop() {
  int value = analogRead(AOUT_PIN); // read the analog value from sensor

  Serial.print("Moisture: ");
  Serial.println(value);

  delay(500);
}

Replace the limit with your dry soil value.

int sensorPin = A0; 
int sensorValue;  
int limit = 400; 

void setup() {
 Serial.begin(9600);
 pinMode(13, OUTPUT);
}

void loop() {

 sensorValue = analogRead(sensorPin); 
 Serial.println("Analog Value : ");
 Serial.println(sensorValue);
 
 if (sensorValue<limit) {
 digitalWrite(13, HIGH); 
 }
 else {
 digitalWrite(13, LOW); 
 }
 
 delay(1000); 
}

So basically, it measures the moisture level in dry soil and if moisture goes down the threshold the Arduino turn on the warning LED attached to pin number 13. you can replace this LED with Relay and make a self-irrigation system.

If you are planning to make a smart Greenhouse read ower article on the DHT11 temperature and humidity sensor.

Leave a Comment