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

Arduino-Controlled Soil Moisture Sensing with Automated Watering System

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

Circuit Documentation

Summary

This circuit is designed to monitor soil moisture levels and control a solenoid valve based on the moisture content. The system uses an Arduino UNO as the central processing unit, interfaced with a SparkFun Soil Moisture Sensor to measure the moisture level. A 1 Channel 5V Relay Module is used to control the solenoid valve, which is powered by a 12V battery through a 7805 voltage regulator. The PowerBoost 1000 Basic Terminal USB provides a stable 5V supply to the Arduino and other 5V components. A diode is used in conjunction with the solenoid to prevent back EMF from damaging the circuit.

Component List

Wiring Details

Arduino UNO

SparkFun Soil Moisture Sensor

1 Channel 5V Relay Module

PowerBoost 1000 Basic Terminal USB

Solenoid

Diode

12V Battery (mini)

7805

Documented Code

// sketch.ino
const int MOISTURE_SENSOR_PIN = 2; // Assuming the sensor SIG pin is connected to D2
const int RELAY_PIN = 3;            // Relay module is controlled by pin D3
const int MOISTURE_THRESHOLD = 40;  // Set the moisture threshold to 40%

void setup() {
  pinMode(MOISTURE_SENSOR_PIN, INPUT);
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW); // Initialize the relay to be off
}

void loop() {
  int sensorValue = analogRead(MOISTURE_SENSOR_PIN); // Read the moisture sensor value
  int moisturePercentage = map(sensorValue, 0, 1023, 100, 0); // Map the value to a percentage (assuming 0 is wet and 1023 is dry)

  // Check if the moisture level is below the threshold
  if (moisturePercentage < MOISTURE_THRESHOLD) {
    // Soil is too dry, open the solenoid (activate the relay)
    digitalWrite(RELAY_PIN, HIGH);
  } else {
    // Soil is moist enough, close the solenoid (deactivate the relay)
    digitalWrite(RELAY_PIN, LOW);
  }

  // Wait for a bit before reading again
  delay(1000); // Delay in milliseconds (1 second)
}

This code is designed to read the moisture level from the soil moisture sensor and control the solenoid valve through the relay. If the soil moisture falls below the set threshold, the solenoid valve is opened to allow watering.