Arduino Projects

Arduino Soil Moisture Sensor Getting Started Tutorial

Soil Moisture Sensor With Arduino Description:

 

In this tutorial, you will learn how to use a soil moisture sensor with Arduino. A soil moisture sensor has many applications, especially in agriculture. Before I use this sensor in some intermediate and advanced level projects, first I decided to make a very basic getting started tutorial to explain the basic connections and programming. This tutorial covers

  1. Basic introduction
  2. Interfacing the soil moisture sensor with Arduino
  3. Soil Moisture Sensor Arduino Programming and finally
  4. Testing

Recently, I added an advanced level project based on Irrigation. In this project I used the Capacitive Soil moisture with the Nodemcu ESP8266 along with the Lora Transceiver modules by the Reyax technologies. This is really an amazing project, which I designed for one of my customers.

Let’s get started….


Amazon Links:

Arduino Nano USB-C Type (Recommended)

12v Adaptor:

Soil Moisture Sensor Arduino:

Other Tools and Components:

ESP32 WiFi + Bluetooth Module (Recommended)

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

FC-28 Soil Moisture sensor:

soil moisture sensor

A soil moisture sensor actually consists of two components, the board and the part having these legs.

This is component number1 provided with 2 male headers, with the help of these two male headers it can be interfaced with the blue board using the Female to Female type jumper wires, or if you want solid connections, you can solder these pins.

soil moisture sensor

And this is component number 2.

soil moisture sensor

Component number 1 is basically a two-legged lead, that goes into the soil, as you can see this component has two male headers which connect to the component number 2 which is an amplifier/ Analog to digital converter circuit.

soil moisture sensor

This circuit is connected with the Arduino using these 4 male headers. These 4 male headers are labeled with Vcc. Ground….D0 and A0. D is for the digital while A is for the analog. So it means we can get values in both Digital and Analog. The digital output is in the form of 0 or 1which can be controlled using this potentiometer.

This module has also two led’s, one led is the power ON led, while the other led works with the digital output pin. When the moisture is below a certain value which is set using the potentiometer then led remains off. When there is moisture, this led turns ON.  While the analog output can be any number between 0 and 1024. This value will entirely depend on the water content present in the soil. So now we can say that the soil moisture sensor has two modes

  1. Analog Mode and
  2. Digital Mode.


First of all, let’s cover the analog Mode.

soil moisture sensor

The component 1 which is a two-legged lead is connected with component 2 using two jumper wires, it doesn’t matter which pin you connect with which one, as it has no polarity. The VCC pin is connected with 5volts, The ground wire which is the blue wire is connected with the Arduino’s ground, while the analog output pin is connected with pin A1 of the Arduino.

Soil Moisture Sensor Analog Mode Programming:

As you know my friends every Arduino and the mega program has at least two functions, which are the void setup and void loop function. void means that this function is not returning any value, while the empty parenthesis means that this function is not taking any arguments as the input.


reads the moisture sensor and store the value in msvalue variable. And then using the serial.println function, we send the value to the serial monitor, where we can check the value of the moisture sensor.

Then using two if the conditions we can turn on and turn off the led. When the sensor value is greater than 500 and the flag is false then turn on the led, which means that it needs water. And then change the flag status to true and use a delay of 1 second as 1000 milliseconds are equal to 1 second.

If the value is less then 300 then simply turn off the led. And change the flag status back to false.

I have already uploaded this program let’s watch this in action…

soil moisture sensor

Soil Moisture Sensor Digital Mode:

soil moisture sensor

Now simply remove the yellow wire and connect it with the digital output pin and connect the other end with digital pin 4 of the Arduino.

Soil Moisture Sensor Digital Mode Programming:

Watch Video Tutorial:

Other Related Video

 

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

One Comment

Leave a Reply

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

Back to top button