top of page

Interfacing Soil/Moisture Sensor with Arduino

Updated: Apr 1

Soil Moisture Sensor
Soil Moisture Sensor

The quantity of water present in the soil is the #soil moisture. The moisture of the soil is measured to determine how fertile the land is to cultivate a particular crop on a large scale. Basically, #moisture in the soil is an indirect measure of properties such as its dielectric constant, interaction with neutrons, etc.

In this project, we are going to design a circuit using a Soil Moisture sensor to test the moisture quantity in Soil with different textures. This article gives the Hardware description and explains the circuit connection and the code required to interface with the IDE to get the output on the computer screen.

Hardware List

The circuit consists of the following components.

All the Components Required
All the Components Required
  1. Arduino

Arduino chip
Arduino UNO

Arduino board is a microcontroller that is used to accept inputs from sensors connected and provide an output action on the desired device connected to it. The sensor inputs can be that from light-detecting sensors, flame sensors, temperature sensors, etc. The output function done on the devices can be turning on an LED, the sound of a buzzer, or a Serial monitor display.

Buy Arduino from here.

2. Soil Moisture sensor

FC-28 Soil Moisture Sensor
FC-28 Soil Moisture Sensor

The sensor (also called a Hygrometer #sensor) is used to measure the volumetric quantity of water in the soil through the probes provided. The FC-28 sensor contains an IC on the board which is an LM323 comparator. The sensor also contains a #potentiometer embedded in it which will hold the threshold value of the moisture set by the user.

Sensor specifications.

  • Input voltage: 3.3V - 5V

  • Output voltage: 0V - 4.2V

  • Input current: 35 mAmps

  • Output: Analog or Digital (Analog Range 0 - 1023 and Digital outputs 0 or 1)

Buy Soil Sensor from here.

3. Jumper Wires

Jumper Wires
Jumper Wires

These are the main components that are used to establish the connections between different devices of the circuit.

Buy Jumper Wires from here.

Circuit Diagram

The circuit diagram below shows the necessary connections from the Arduino to the FC-28 Soil Moisture Sensor.

The Soil Moisture sensor is connected to the Arduino board with the help of Jumper wires. The sensor contains a set of pins on two sides. The set of pins on one side are Ground(Gnd), #Voltage input(Vcc), Digital output(D0), and Analog output(A0).

These pins are connected to the Arduino chip in the following manner. The Ground pin of the Sensor is connected to the Ground pin of the #Arduino chip. The Vcc pin on the sensor is connected to the 5V supply pin of the Arduino chip.

When there is a requirement for Analog output, the A0 pin of the sensor is connected to the A0 pin of the Arduino chip. The range of output values for Analog output is 0 - 1023. Else, when Digital output is required, the D0 pin of the sensor can be connected to any of the digital output pins of the Arduino chip. The digital outputs as we know will be either 0 or 1.

The second set of pins present on the other side of the sensor are connected to the probes that will be measuring the moisture of the soil when placed physically in it. The conducting probes are the basic sensor devices of this circuit.

As mentioned earlier, the sensor has a potentiometer and a #comparator embedded on it whose functions are to hold the threshold value and compare the input value from the sensor to the threshold value fixed by the user respectively. The detailed working will be discussed in the working of the circuit.


Note: Please change the file format to .ino(Arduino IDE) format before you upload the code to the Arduino board.


The circuit, when switched ON and OFF, is shown below.

Circuit switched OFF
Circuit switched OFF

When the connections are done, the conducting probes connected to the Soil moisture sensor must be inserted into the soil whose Moisture value is desired to be known. The circuit must simultaneously be interfaced with Arduino IDE.

Circuit switched ON
Circuit switched ON

When the circuit is switched ON, the sensor reads the values that the probes conduct. The potentiometer actually holds the threshold value fixed by the user. The LM323 comparator present on the sensor chip compares the threshold value to the sensor input value. The glowing of the LED in the sensor indicates the functioning of the sensor.

(In the code provided above, the threshold value is not given and hence no comparison happens as it is the function which we can code/design as per our requirement).

Finally, the output, that is the value of moisture content in the soil is displayed on the Serial Monitor of the Arduino IDE.

The video given below shows an explained version of the circuit building, working of the code, and display of output for better understanding.

Video By - Abhishek Goud

The article gives the idea for basic connections of the Soil Moisture Sensor to Arduino and how to read the values. This sensor and circuit can be used as Moisture measurement devices for gardens at home or for agricultural fields on developing the same on a larger scale.



623 views2 comments

Related Posts

See All


Anushka Gupta
Anushka Gupta
Jul 26, 2023

I've been searching for a comprehensive guide on soil/moisture sensor interfacing, and this blog exceeded my expectations. Well done, Learn Electronics India! Your dedication to educating others is commendable.


LearnElectronics India simplifies complex concepts beautifully. Thank you!

bottom of page