How to use a Soil Moisture Sensor with Arduino

Posted on by
 Soil Moisture Sensor for Arduino

Soil Moisture Sensor for Arduino

If you are building a system to irrigate your plants automatically monitoring the soil moisture is more reliable than set watering cycles, so that only watering when your plants need, avoiding problems by overwatering. Here we will explain how to use one of these soil moisture sensors to Arduino.


This sensor consists of two parts, the fork-shaped probe that has to be nailed to the ground, and an electronic module that will be used to connect the probe with Arduino. It operates with a 3.3V or 5V supply to be administered by the VCC and GND pins. The red LED will light when we are feeding.

Has both digital and analog functionality, the pin AO will give us an analog signal between the supply value to 0V (For Arduino UNO 5v to 0V) to higher humidity value will be higher, this is due to the operation of the probe because the higher the humidity is greater conductivity of the soil and therefore increase the value that we measure.

The DO pin will give us a digital signal is “1” when the humidity value is lower than manually establish on the potentiometer and ‘0’ when it is larger. The potentiometer is connected to a comparator LM393 as the probe signal. To use it correctly we must calibrate with different soil samples with different humidities. The green LED will help us in this task because when we have a 1 in DO will turn on.

Power supply 3.3V ~ 5V
LED Red: Power
Green: Digital output
VCC: 3.3V-5V
DO: Digital output
AO: Analog output


int DOpin = 2;

void setup() {
 pinMode(DOpin, INPUT);

void loop() {
 int DO = digitalRead(DOpin);
 int sensorValue = analogRead(A0);
 int hum = (sensorValue * 100)/1024;

 Serial.print("Digital value: ");
 Serial.print("Analog value: ");
 Serial.print("Humidity: ");

Comments are disabled