Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Based Soil Moisture Monitoring System

Image of Arduino UNO Based Soil Moisture Monitoring System

Soil Moisture Monitoring System Documentation

Summary

The Soil Moisture Monitoring System is designed to measure the moisture level of the soil using a DFRobot Capacitive Soil Moisture Sensor and an Arduino UNO microcontroller. The system reads the analog value from the moisture sensor and outputs a qualitative status of the soil's moisture level to the serial monitor. The status can be "too wet," "perfect," or "too dry," depending on the sensor's reading compared to predefined threshold values.

Component List

DFRobot Capacitive Soil Moisture Sensor (V1.0)

  • Description: A sensor that measures the moisture level in the soil using capacitive sensing rather than resistive sensing.
  • Pins:
    • A: Analog output pin
    • VCC: Power supply pin
    • GND: Ground pin

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P, widely used for prototyping and educational purposes.
  • Pins:
    • IOREF, Reset, 3.3V, 5V, GND, Vin: Power supply and reset pins
    • A0 - A5: Analog input pins
    • SCL, SDA: I2C communication pins
    • AREF: Analog reference pin
    • D0 - D13: Digital I/O pins

Wiring Details

DFRobot Capacitive Soil Moisture Sensor (V1.0)

  • A (Analog output) connected to Arduino UNO A0 (Analog input)
  • VCC (Power supply) connected to Arduino UNO 5V
  • GND (Ground) connected to Arduino UNO GND

Arduino UNO

  • A0 (Analog input) connected to DFRobot Capacitive Soil Moisture Sensor A (Analog output)
  • 5V connected to DFRobot Capacitive Soil Moisture Sensor VCC (Power supply)
  • GND connected to DFRobot Capacitive Soil Moisture Sensor GND (Ground)

Documented Code

/* Soil Moisture Monitoring System
 * This code is designed to work with an Arduino UNO and a DFRobot Capacitive Soil Moisture Sensor.
 * It reads the moisture level from the sensor and prints out the status of the soil moisture.
 * The status can be "too wet", "perfect", or "too dry" based on predefined threshold values.
 */

// Threshold values for soil moisture levels
#define wetSoil 277   // Define max value we consider soil 'wet'
#define drySoil 380   // Define min value we consider soil 'dry'

// Define analog input pin connected to the soil moisture sensor
#define sensorPin A0

void setup() {  
  // Initialize serial communication at 9600 bits per second
  Serial.begin(9600);
}

void loop() {
  // Read the value from the soil moisture sensor
  int moisture = analogRead(sensorPin);
  Serial.print("Analog output: ");
  Serial.println(moisture);
  
  // Determine the status of the soil based on the moisture level
  if (moisture < wetSoil) {
    Serial.println("Status: Soil is too wet");
  } else if (moisture >= wetSoil && moisture < drySoil) {
    Serial.println("Status: Soil moisture is perfect");
  } else {
    Serial.println("Status: Soil is too dry - time to water!");
  }
  Serial.println();
  
  // Wait for 1 second before taking the next reading
  delay(1000);
}

This code is saved as sketch.ino and is intended to be uploaded to the Arduino UNO microcontroller. It includes a setup routine that initializes serial communication and a loop that continuously reads the moisture level, evaluates it against the threshold values, and prints the status to the serial monitor. The system pauses for one second between readings to allow for a stable measurement.