Complete Guide to Use Soil Moisture Sensor W/ Practical Example

by Electropeak in Circuits > Arduino

1145 Views, 4 Favorites, 0 Comments

Complete Guide to Use Soil Moisture Sensor W/ Practical Example

soil-moisture-tutorial-teaser.jpg

You can read this and other amazing tutorials on ElectroPeak's official website

Overview

In this tutorial, you will learn how to use a soil moisture sensor. Practical examples are also provided to help you master the code.

What You Will Learn:

  • How soil moisture sensors work
  • How to use soil moisture sensor with Arduino

How Does It Work?

soil-moisture-tutorial-2.jpg

The soil moisture sensor consists of two probes that measure the volume of water in the soil. The two probes allow the electric current to pass through the soil and, according to its resistance, measures the moisture level of the soil.

When there is more water, the soil conducts more electricity, which means that the resistance will be less. So the moisture level will be higher. Dry soil reduces conductivity. So, when there is less water, the soil conducts less electricity, which means it has more resistance. So the moisture level will be lower.

Soil Moisture Sensor – Pin Out

There are different types of soil moisture sensor on the market, but their working principal are all similar; so if your sensor is different from the one you see in this tutorial, don’t worry! All of these sensors have at least three pins: VCC, GND, and AO. The AO pin changes according to the amount of moisture in the soil and increases as there is more water in the soil. Some models have an additional base called DO. If the moisture amount is less than the permissible amount (which can be changed by the potentiometer on the sensor) the DO pin will be “1”, otherwise will remain”0″.

Interfacing Soil Moisture Sensor and Arduino

In this tutorial, we have used the Waveshare Soil Moisture Sensor. It has a detection length of 38mm and a working voltage of 2V-5V. It has a Fork-like design, which makes it easy to insert into the soil. The analog output voltage boosts along with the soil moisture level increases.

Circuit

soil-moisture-tutorial-fritzing.jpg

Using this sensor is quite easy. You connect the AO pin to any analog pin. If your sensor has a DO pin, you can connect it to any digital pin.

Code

soil-moisture-tutorial-results.jpg

For each soil moisture measurement, we took an average of 100 sensor data to make the data more stable and accurate.

Please note that after 10-20 months, the sensor may get oxidized in the soil and lose its accuracy. Therefore you should replace it every year. Since it has a low price and easy setup, it worths the annual replacement.

Downloads

Related Projects

Buy a Soil Moisture Sensor

Buy Waveshare Moisture Sensor from ElectroPeak

Buy YwRobot Soil Moisture Sensor Module from ElectroPeak