Soil moisture sensor Interface with arduino uno


Water is needed for the fundamental growth of plants. When sufficient amount of water is not present at the time of plant needs, then eventually the plant can prompt lessened quality or demise. Since it is very hectic for human to look after plants all the time, engineers designed soil moisture sensors to lessen the burden. Now using the sensor system designer can build any types of system that can look after the water needs of plant.

Sensor description:

This DFRobot soil moisture sensor has two probes through which current passes in soil, then read the resistance of soil for reading moisture level. We know that water make the soil more prone to electric conductivity resulting less resistance in soil where on the other hand dry soil has poor electrical conductivity thus more resistance in soil. Using these properties of electricity the sensor is designed. Inside the sensor there are circuitry for measuring the resistance and converting it into voltage as output.


  1. Supply voltage: 3.3v – 5v
  2. Output voltage: 0- 4.2 v
  3. Current: 35mA
  4. Low power consumption


  1. Irrigation controller
  2. Gardening
  3. Water sensor


  1. Arduino uno (1pc)
  2. Soil moisture sensor (DFRobot)
  3. Analog sensor cable (3 pin)

Pin configuration:


Figure 1: Pin configuration of DFRobot soil moisture sensor



Figure 2: soil moisture sensor interfacing with Arduino Uno


Soil Moisture sensor


S (pin 3)


VCC (pin 1)


GND (pin 2)

For this sensor no extra circuit is not required to construct so the data pin of soil moisture sensor which is pin 3 is directly connected with arduino uno’s analog I/O pin. In this project this pin is connected with arduino uno’s analog pin A0. However the question arises as to why analog pin? The reason behind using analog I/O pin is because the sensor provides analog voltage as output. Since arduino uno has analog-to-digital converter (ADC), it saves the hobbyist from hassles. Arduino uno do all the task using analogRead() function and show analog value.


/* # the sensor value description

# 0  ~300     dry soil

# 300~700     humid soil

# 700~950     in water*/

void setup(){



void loop(){

int soil_moisture=analogRead(A0);  // read from analog pin A3

Serial.print(“analog value: “);

if(soil_moisture<30) {

Serial.println(“Dry soil”);


if((soil_moisture>300)&&(soil_moisture<700)) {

Serial.println(“Humid soil”);







According to the code sensor data is received by A3 pin of arduino uno. However any analog I/O pin can do the task. Also any arduino model will work for this code. The sensor manual luckily gave the conditions for identifying three types of soils: dry, humid, watery. However, if any user need more specific dissection then thy can experiment with the sensor by reading only analog value and tabulate them. After taking certain sample they can finally come to a conclusion.



Leave a Reply