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

Arduino-Controlled Automated Irrigation System with Soil Moisture Monitoring

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled Automated Irrigation System with Soil Moisture Monitoring

Soil Moisture Monitoring and Solenoid Valve Control Circuit Documentation

Summary

This circuit is designed to monitor the moisture level of soil using four soil moisture sensors and control a solenoid valve through a relay. The Arduino Nano microcontroller reads the analog values from the soil moisture sensors, calculates the average moisture level, and activates the solenoid valve if the average moisture level falls below a predefined threshold. The solenoid valve is controlled via a 12V single-channel relay, which is in turn powered by a DC power source. The relay ensures safe and effective switching of the high-power solenoid valve by the low-power microcontroller signal.

Component List

Arduino Nano

Soil Moisture Module (x4)

12V Single Channel Relay

12v Pneumatic Solenoid Valve

DC Power Source

Wiring Details

Arduino Nano

Soil Moisture Module

12V Single Channel Relay

12v Pneumatic Solenoid Valve

DC Power Source

Documented Code

/*
 * This Arduino Sketch reads data from four soil moisture sensors and controls
 * a solenoid valve via a relay based on the average soil moisture level.
 */

// Pin definitions
const int soilMoisturePins[] = {A0, A1, A2, A3};
const int relayPin = 2;

// Variables to store sensor readings
int soilMoistureValues[4];

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  
  // Initialize soil moisture sensor pins
  for (int i = 0; i < 4; i++) {
    pinMode(soilMoisturePins[i], INPUT);
  }
  
  // Initialize relay pin
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW); // Ensure relay is off initially
}

void loop() {
  // Read soil moisture sensor values
  int totalMoisture = 0;
  for (int i = 0; i < 4; i++) {
    soilMoistureValues[i] = analogRead(soilMoisturePins[i]);
    totalMoisture += soilMoistureValues[i];
  }
  
  // Calculate average soil moisture level
  int avgMoisture = totalMoisture / 4;
  
  // Print sensor values to serial monitor
  Serial.print("Soil Moisture Values: ");
  for (int i = 0; i < 4; i++) {
    Serial.print(soilMoistureValues[i]);
    Serial.print(" ");
  }
  Serial.print("| Avg: ");
  Serial.println(avgMoisture);
  
  // Control relay based on average soil moisture level
  if (avgMoisture < 500) { // Threshold value for soil moisture
    // Turn on relay to activate solenoid valve
    digitalWrite(relayPin, HIGH);
  } else {
    // Turn off relay to deactivate solenoid valve
    digitalWrite(relayPin, LOW);
  }
  
  // Wait for a second before next reading
  delay(1000);
}

This code is designed to be uploaded to the Arduino Nano microcontroller. It initializes the input pins connected to the soil moisture sensors and the output pin connected to the relay. The loop function reads the moisture levels, calculates the average, and controls the relay accordingly. The serial output can be used for debugging and monitoring the sensor values.