Overview of Soil Moisture
Soil Moisture Sensor
Soil moisture refers to the amount of water present in the soil. It can be measured using a soil moisture sensor, which consists of two conducting probes. These probes act as electrodes, measuring the moisture content based on the resistance between them.
The resistance between the two plates decreases as the moisture level increases, meaning the resistance is inversely proportional to the soil’s moisture content.
For more details on the soil moisture sensor and its usage, refer to the Soil Moisture Sensor topic in the sensors and modules section.
Connection Diagram of Soil Moisture with Arduino
Interfacing Soil Moisture Sensor With Arduino UNO
Measure soil moisture using Arduino Uno
In this setup, the analog output of the soil moisture sensor is processed using the ADC. The moisture content, expressed as a percentage, is displayed on the serial monitor.
The output of the soil moisture sensor varies between ADC values of 0 and 1023.
This can be converted into a moisture percentage using the following formula.
Moisture in percentage = 100 – (Analog output * 100)
Soil Moisture Code for Arduino Uno
const int sensor_pin = A1; /* Soil moisture sensor O/P pin */
void setup() {
Serial.begin(9600); /* Define baud rate for serial communication */
}
void loop() {
float moisture_percentage;
int sensor_analog;
sensor_analog = analogRead(sensor_pin);
moisture_percentage = ( 100 - ( (sensor_analog/1023.00) * 100 ) );
Serial.print("Moisture Percentage = ");
Serial.print(moisture_percentage);
Serial.print("%\n\n");
delay(1000);
}