Toggle Nav

Interfacing Soil Moisture Sensor with Arduino

Table of Contents

Soil Moisture Sensor Features

Soil moisture sensors are designed in the form of two-pronged forks to easily sink into the soil. The function of this module is simple. When the sensor is placed in a conductive material (eg wet soil), the two sensor pads are connected to each other. The more water that is in the soil means the better the conductivity between the pads will be, resulting in a lower resistance and more current passing through the circuit. With this method, the sensor can measure the amount of humidity.

The output of this sensor is analog voltage. The higher the humidity, the higher the output voltage.

You can adjust the sensitivity of the digital output using the potentiometer on the board.

Soil Moisture Sensor Pinout

This module has 4 pins:

  •  VCC: Module power supply – 2-5 V
  •  GND: Ground
  •  DO: Digital voltage output
  •  AO: Analog voltage output

The following circuit shows how you should connect Arduino to soil moisture sensor. Connect wires accordingly.

Required Materials

Hardware Components

Arduino UNO R3 × 1
YL-69 Soil Moisture Detection Sensor Module × 1
Male to Female Jumper wire × 1

Software Apps

Arduino IDE

Interfacing Soil Moisture Sensor with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to Soil Moisture Sensor. Connect wires accordingly.

Step 2: Code

Upload the following code to your Arduino. This code converts the sensor output voltage to digital using ADC and displays the result in the serial monitor.
  Soil Moisture Sensor
  modified on 27 Sep 2020
  by Mohammad Reza Akbari @ Electropeak

// for Arduino uncomment this
//int Sensor = A0;

// for STM32 uncomment this
int Sensor = PA0;

int ad_value;

void setup()
  pinMode(Sensor, INPUT);
void loop()
  ad_value = analogRead(Sensor);
  Serial.print("Output: ");

Liked What you see?

Get updates and learn from the best

More To Explore

Leave a Reply

Your email address will not be published. Required fields are marked *