Capacitive Soil Moisture Sensor Basics

by taste_the_code in Circuits > Arduino

8680 Views, 17 Favorites, 0 Comments

Capacitive Soil Moisture Sensor Basics

118 - Capacitive Moisture Soil Sensor.00_00_01_28.Still001.jpg
Working with a capacitive soil moisture sensor

Hi everyone, in this Instructable we will look at a capacitive soil moisture sensor, how it works, how to connect it, and how to read the values that it produces.

A capacitive soil moisture sensor is used in gardening where we want to monitor the moisture levels in the soil so we can control an automatic irrigation system with it or get alerted once we need to water our plants.

Supplies

Materials used in the project:

Alternative links on Banggood:

How It Works

118 - Capacitive Moisture Soil Sensor.00_01_32_11.Still003.jpg
118 - Capacitive Moisture Soil Sensor.00_01_58_17.Still004.jpg

The sensor electronics are built around a 555 timer IC.

The timer and the other supportive components form an oscillator that works on a set frequency. Since the measuring part of the sensor is made out of two PCB tracks on the board, they act as a capacitor that is connected to this oscillating circuit.

Once the sensor is placed in soil, the moisture in the soil changes the capacitance of this capacitor, and with that, the frequency of oscillation on the 555 timer is changed.

This change in frequency is then translated to an analog voltage from 1 to 3 volts and this can then be detected with an Arduino and translated into a percentage.

Depending on the precision of the electronics that form the oscillator, each sensor can have slight differences in the output so it is necessary that we test them and adjust the limits accordingly later on in the steps.

Connecting It to Arduino

118 - Capacitive Moisture Soil Sensor.00_03_33_18.Still005.jpg
118 - Capacitive Moisture Soil Sensor.00_03_59_08.Still006.jpg
118 - Capacitive Moisture Soil Sensor.00_05_49_15.Still007.jpg

The sensor has three connections, VCC, GND, and AOUT.

VCC can be connected to either 3.3V or to 5V, and in my case, I have it connected to 3.3.V. GND is connected to the GND on the Arduino and VOUT can be connected to any analog input. In my case I use A0.

To check out the output of the sensor, I've created a basic sketch where I read the analog input and directly print the value to the serial console.

This way, we can see what are the output values when the sensor is exposed to air where that corresponds to 0% moisture and submerged in water for 100% moisture.

We will use these limits in the next step where we will map these values to an actual percentage.

Analog Voltage to Moisture Percentage

118 - Capacitive Moisture Soil Sensor.00_07_43_09.Still008.jpg
118 - Capacitive Moisture Soil Sensor.00_09_12_21.Still009.jpg

Now that we have the reading from the sensor, we can use the Arduino map function to map this range from the sensor into a percentage value from 0 to 100.

After the value is mapped, I've updated the sketch to now print out both of the values, the raw output, and the mapped percentage.

If we now move the sensor in and out of the water, we can observe the change in percentage.

Next Steps

118 - Capacitive Moisture Soil Sensor.00_12_07_23.Still010.jpg

This Instructable covers the basics of reading a capacitive soil moisture sensor. This value can then be used to be displayed on a screen, send to a processing server, or even control a connected pump to automatically water the plants.

I plan to upgrade this sensor with a central sensors hub and use it with Home Automation so I can automate the watering of my garden.

If that sounds interesting to you, then be sure to subscribe to my YouTube channel and follow me here on Instructables.