Out Of Stock
Description
This sensor measures the volumetric content of water inside the soil and gives us the moisture level as output. The sensor is equipped with both analog and digital output, so it can be used in both analog and digital mode. In this article, we are going to interface the sensor in both modes.
The specifications of the soil moisture sensor FC-28 are as follows
- Operating voltage: 3.3V~5V.
- Adjustable sensitivity (shown in blue digital potentiometer adjustment)
- Dual output mode, analog output more accurate.
- A fixed bolt hole for easy installation.
- With power indicator (red) and digital switching output indicator (green).
- Having LM393 comparator chip, stable.
- Panel PCB Dimension: 3cm x 1.5cm.
- Soil Probe Dimension: 6cm x 2cm.
- Cable Length: 21cm.
we will look at how to use the soil moisture sensor with the Arduino:
Using the soil moisture sensor with an Arduino can't be easier. Adding a Nokia 5110 LCD display makes things more professional since we can visually check the moisture levels of the soil.
oil moisture sensor is a sensor used to measure the amount of water in the soil at any particular point in time. Instead of the old gravimetric method of measuring soil water content, the soil moisture sensor measures the volumetric water content indirectly by using other properties associated with the soil, like its electrical resistance to measure the soil humidity.
Soil moisture Sensor Probe
The probe of the sensor which is shown in the image below has two large exposed pads.
The more water in the soil the better the electrical conductivity between the pads as a result of lower resistance. when the soil is dry, the resistance in the soil becomes higher and conductivity between this pads reduces. This helps the sensor determine the water level in the soil.
To make the reading of the soil humidity easy, we will be using the Nokia 5110 LCD display alongside with the Arduino.
At the end of this tutorial, we would have learned how to use the soil humidity sensor to read the soil humidity and display the humidity on an LCD. This project is a good building block for the development of an automatic irrigation system.
Schematics
The schematic for this project is a fairly easy to replicate one. we have covered connecting the Nokia 5110 LCD to the Arduino in previous tutorials, one of which can be found via this link(). The soil sensor has just three pins which are VCC, GND, and SIG(signal) pin and they are connected to the Arduino as shown in the schematics below.

Schematics
The connections are further highlighted below.
Soil moisture Sensor – Arduino
VCC – 5V
GND – GND
SIG – A0
With everything connected, we can now move to the code for the project.
Code:
Two Arduino code sketches are available for this tutorial. The first one is for those who do not have the Nokia 5110 LCD display while the second one is for those who have the LCD. The first sketch which does not incoporate the display uses the serial monitor as a means of displaying the data to make the changes in the sensor readings visible to the user.
Since the code sketches are similar and we have covered the how to use the Nokia 5110 LCD in more than 10 tutorials on this website, I will use the first code without the display as a reference point. I will advise that beginners go through the several Nokia 5110 LCD tutorials as they may learn one or two new tricks on using the display.
The concept behind the code is simple, we know the range of the arduino ADC is between 0 and 1023 so we read the analog value provided by the soil moisture sensor then using the range of the ADC, we convert the value to a percentage so it is easier for the user to understand and we display that percentage on the serial monitor (or on the Nokia 5110 LCD).
To explain the code briefly, the first thing we do is specify the analog pin of the Arduino to which the sensor is connected after which we create certain variables which will be used later on.
////////////////////////////////////////////// // ARDUINO SOIL MOISTURE DEMO // // // // http://www.educ8s.tv // ///////////////////////////////////////////// int sensorPin = A0; int sensorValue = 0; int percent = 0;
With that done, we move to the void setup function where we initialize serial communication so our data can be displayed on the serial monitor later.
void setup() { Serial.begin(9600); }
Next, is the void loop function where all the major action takes place. The first line of code under the function reads the analog value from the soil moisture sensor after which we call the convert to percent function which returns the percentage of water left in the soil as mentioned earlier. The percentage value is then displayed on the serial monitor using the printValueToSerial() function. The program is paused for 1000 ms and restarted again from the top.
void loop() { sensorValue = analogRead(sensorPin); percent = convertToPercent(sensorValue); printValuesToSerial(); delay(1000); }
The complete version of both the sketch with no provision for the LCD and the one with provision for the LCD can be downloaded via the link below.
To test the project, upload the code to your Arduino board and set up the system, inserting the sensor into a dry soil as shown in the image below.
When the Arduino is powered, the since the soil is dry and the sensor does not detect any moisture, as seen in the image above, the percentage value will reduce to as low as 1%. If we decide to add a little amount of water to the soil so it becomes moist, as shown in the image below, the percentage soil humidity increases.