Create Makers

Capacitive Soil Moisture Sensor Arduino

Capacitive Soil Moisture Sensor

Disclosure: Some of the links below are affiliate links and we only earn a small commission if you purchase through our links at no additional cost to you. The earning mainly used for maintaining the website.

If you are still using the old-school sensors to read the soil moisture contents, then you might have to stay on this tutorial blog. The sensor mentioned is the resistive soil moisture sensor which its resistance changes inversely proportional to the moisture.

Nothing wrong with the sensor but the life span due to corrosion of the probe is a concern. And that is why a capacitive soil moisture sensor is a better option.

Starter Pack

  1. Arduino Board
  2. Capacitive Soil Moisture Sensor
  3. Jumper Wires
  4. Breadboard

Working Principle of Capacitive Soil Moisture Sensor

Just like a capacitor, the capacitive soil moisture sensor has two conductive plates separated by a distance (dielectric) capable of storing electrical energy in an electric field. Generally, the sensor measures the charge-storing capacity of the soil.

To avoid any confusion, we use the parallel plate capacitor formula. The probe’s conductive plate’s surface area and the distance between them are fixed. The only left out is the dielectric constant, Ꜫr.

Parallel Plate Capacitor Formula

All materials have the ability to store electrical charge which is referred to as dielectric constant. Air, soil, and fertilizer or minerals have relatively low dielectric constants. Water has a higher dielectric constant compared to other components in soil. Thus this changes the capacitance in the sensor which determines the moisture level.

On top of the module, there is a 555 Timer IC which outputs a square wave. With resistors, capacitors, and diodes the square wave is then converted to a triangle wave and then to an analog voltage to be read by the Arduino. Different moisture contents have different dielectric constants. This difference changes the capacitance of the sensor which outputs different analog voltage values.

Wiring and Coding the Sensor with Arduino

Interfacing the sensor is easy as there are only three wires.

Arduino

Capacitive Soil Moisture Sensor

GND

GND

VCC

VCC

A0

AOUT

const int soilAnalog = A0;
int soilVal;

void setup() {
 Serial.begin(9600);
 delay(100);
}


void loop() {
 soilVal = analogRead(soilAnalog);
 Serial.print("Analog Output: ");
 Serial.println(soilVal);
 delay(1500);
}

The codes are the same as the analog output resistive soil moisture sensor in the previous tutorial. You can go to the tutorial if you need explanation on the codes.

Of course, the values do not represent moisture content. With the values above, we can map them into percentage accordingly.

const int soilAnalog = A0;
int soilVal;
const int dry = 523;
const int wet = 200;
const int moistureLevel;

void setup() {
  Serial.begin(9600);
  delay(100);
}


void loop() {
  soilVal = analogRead(soilAnalog);
  moistureLevel = map(soilVal, wet, dry, 1000);
  Serial.print("Moisture Level: ");
  Serial.print(moistureLevel);
  Serial.println("%");
  delay(500);
}
map(value, FromA, FromB, toAtoB);

To convert values from one range another range.

fromA → toA

fromB → toB

Value

Values to be converted.

fromA and FromB

Range of value to be converted.

toA and toB

Target range of value.

Nay! We Love Videos

Bye Bye

If you find you are replacing resistive soil moisture sensors too often, then you should consider switching to a capacitive soil moisture sensor. In terms of life span, definitely, the capacitive soil moisture sensor can last longer. Besides being a little bit pricey compared to resistive types, they are worth the upgrade.
Hope you find this tutorial helpful in your projects. Subscribe to our newsletter for more tutorials.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments