Learn how to measure soil moisture using a capacitive hygrometer with Arduino.
A capacitive hygrometer measures soil moisture using variations in capacitance. Unlike resistive sensors, it is more accurate and avoids issues with electrode oxidation. These sensors are ideal for automatic irrigation systems.
The sensor uses a 555 timer to generate a square wave. The capacitance of the soil affects the signal, resulting in a voltage difference. Higher soil moisture increases the capacitance, lowering the output voltage.
Typical voltage ranges:
Connect the sensor as follows:
const int sensorPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int humedad = analogRead(sensorPin);
Serial.print("Raw Moisture Value: ");
Serial.println(humedad);
delay(1000);
}
Convert the sensor's raw readings into a percentage:
const int sensorPin = A0;
const int humedadAire = 550; // Dry air reading
const int humedadAgua = 250; // Water reading
void setup() {
Serial.begin(9600);
}
void loop() {
int humedad = analogRead(sensorPin);
int porcentajeHumedad = map(humedad, humedadAire, humedadAgua, 0, 100);
porcentajeHumedad = constrain(porcentajeHumedad, 0, 100);
Serial.print("Moisture: ");
Serial.print(porcentajeHumedad);
Serial.println("%");
delay(1000);
}