Index
Introduction
A soil moisture sensor is an electronic device designed to measure the moisture content of soil. It is commonly used in agriculture, gardening, and environmental monitoring to determine when to water plants or to monitor soil conditions for various purposes. Here’s an introduction to soil moisture sensors:
Hardware Overview
- Comparator (e.g., LM393): Compares the input voltage from the probes with a reference voltage to determine the moisture level.
- Variable Resistor (Potentiometer): Allows calibration of the sensor by adjusting the reference voltage.
- Power Indicator LED: Indicates if the sensor is powered on.
- Digital Output LED: Indicates the status of the digital output (wet or dry).
Probes:
- Description: Metal probes that are inserted into the soil.
- Function: Measure the soil moisture by detecting the electrical resistance between them. The resistance changes with the amount of water present in the soil.
Working Principle
The soil moisture sensor operates in a straightforward manner.
The fork-shaped probe with two exposed conductors acts as a variable resistor (similar to a potentiometer) whose resistance varies with the soil’s moisture content.
This resistance varies inversely with soil moisture:
- The more water in the soil, the better the conductivity and the lower the resistance.
- The less water in the soil, the lower the conductivity and thus the higher the resistance.
The sensor produces an output voltage according to the resistance, which by measuring we can determine the soil moisture level.
Application
- Agriculture:
- Gardening:
- Environmental Monitoring:
- Automated Systems:
- Smart Irrigation Systems:
- Golf Course Maintenance:
- Landscaping:
Pinout
- VCC: Connect to 3.3V or 5V for power.
- GND: Connect to ground (0V).
- OUT: Analog or digital output for soil moisture level.
Circuit Description
Soil Sensor Pin | Arduino Pin |
VCC | 5 V |
GND | GND |
Analog | Analog A0 |
Circuit Diagram
Programming With Arduino
Step 1: Select the appropriate board and port
Go to Tools > Board and select your Arduino board (e.g., Arduino Uno).
Go to Tools > Port and select the port to which your Arduino is connected.
Step 2: Upload the Code
- Copy the provided code into your Arduino IDE.
#define MoisturePin A0
void setup() {
Serial.begin(9600);
}
void loop() {
// Read the analog value from the soil moisture sensor
int soilMoistureValue = analogRead(MoisturePin);
// Print the soil moisture value to the Serial Monitor
Serial.print("Soil Moisture Level: ");
Serial.print(soilMoistureValue);
Serial.print("%");
Serial.println();
delay(1000);
}
- Verify and upload the code to your Arduino board.
Step 3: Open the Serial Monitor
- Ensure the baud rate in the Serial Monitor matches the baud rate set in the code (
9600
).