Soil Moisture Sensor

Soil Moisture Sensor Experiment

Introduction

In this experiment, we will learn how to measure soil moisture using an Arduino and a soil moisture sensor. This sensor will help us monitor soil hydration levels, which is ideal for automated watering systems in gardens or farms.

Soil Moisture Sensor

Components Needed

Circuit Setup

  1. Connect the VCC pin of the soil moisture sensor to the 5V pin on the Arduino.
  2. Connect the GND pin of the soil moisture sensor to the GND pin on the Arduino.
  3. Connect the analog output pin of the sensor to an analog input pin on the Arduino (e.g., A0).

Ensure that the soil moisture sensor is properly inserted into the soil before testing.

Soil Moisture Sensor Circuit Setup

Code for Soil Moisture Sensor

Upload the following code to your Arduino to read soil moisture levels:


// Define the analog input pin for the sensor
int sensorPin = A0;  
int sensorValue = 0; 

void setup() {
  Serial.begin(9600);  // Initialize serial communication
}

void loop() {
  sensorValue = analogRead(sensorPin);  // Read the value from the sensor
  Serial.println(sensorValue);  // Print the value to the serial monitor
  delay(1000);  // Wait for a second
}
            

Explanation

The soil moisture sensor measures the electrical resistance between two probes. The Arduino reads this resistance as an analog value, which indicates the moisture level in the soil:

Troubleshooting