Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino-Based Soil Moisture Monitoring System with Alert Indicators

View and Edit Project In Cirkit DesignerImage of Arduino-Based Soil Moisture Monitoring System with Alert Indicators

Circuit Documentation

Summary of the Circuit

This circuit is designed to monitor soil moisture levels using a SparkFun Soil Moisture Sensor and provide visual and auditory feedback based on the moisture level. An Arduino UNO serves as the central microcontroller unit to process the sensor data. If the soil moisture level is below a predefined threshold, the circuit activates a buzzer and lights up a red LED. Conversely, if the moisture level is above the threshold, a green LED is lit. The circuit includes resistors to limit current to the LEDs.

Component List

Arduino UNO

SparkFun Soil Moisture Sensor

Buzzer

LED: Two Pin (red)

LED: Two Pin (green)

Resistor (200 Ohms)

Wiring Details

Arduino UNO

SparkFun Soil Moisture Sensor

Buzzer

LED: Two Pin (red)

LED: Two Pin (green)

Resistor (200 Ohms)

Documented Code

/*
 * This Arduino Sketch reads the soil moisture level from a sensor connected to
 * A0. If the soil moisture level is below a certain threshold, it activates a
 * buzzer connected to D8 and lights up a red LED connected to D2. If the soil
 * moisture level is above the threshold, it lights up a green LED connected to
 * D3.
 */

const int soilMoisturePin = A0; // Soil moisture sensor signal pin
const int buzzerPin = 8;        // Buzzer pin
const int redLEDPin = 2;        // Red LED pin
const int greenLEDPin = 3;      // Green LED pin
const int threshold = 500;      // Threshold for soil moisture

void setup() {
  pinMode(buzzerPin, OUTPUT);   // Set buzzer pin as output
  pinMode(redLEDPin, OUTPUT);   // Set red LED pin as output
  pinMode(greenLEDPin, OUTPUT); // Set green LED pin as output
  Serial.begin(9600);           // Initialize serial communication
}

void loop() {
  int soilMoistureValue = analogRead(soilMoisturePin); // Read soil moisture
  Serial.print("Soil Moisture: ");
  Serial.println(soilMoistureValue); // Print soil moisture value

  if (soilMoistureValue < threshold) {
    digitalWrite(buzzerPin, HIGH);   // Activate buzzer
    digitalWrite(redLEDPin, HIGH);   // Turn on red LED
    digitalWrite(greenLEDPin, LOW);  // Turn off green LED
  } else {
    digitalWrite(buzzerPin, LOW);    // Deactivate buzzer
    digitalWrite(redLEDPin, LOW);    // Turn off red LED
    digitalWrite(greenLEDPin, HIGH); // Turn on green LED
  }
  delay(1000); // Wait for 1 second before next reading
}

This code is designed to be uploaded to the Arduino UNO microcontroller. It initializes the necessary pins as outputs and continuously reads the soil moisture level. Depending on the moisture level, it controls the state of the buzzer and LEDs accordingly.