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

Arduino-Controlled Soil Moisture Sensing with Automatic Watering System

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled Soil Moisture Sensing with Automatic 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 detect 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 parallel with the solenoid to protect the circuit from voltage spikes (flyback diode).

Component List

Wiring Details

Arduino UNO

SparkFun Soil Moisture Sensor

1 Channel 5V Relay Module

PowerBoost 1000 Basic Terminal USB

Solenoid Valve

Diode

12V Battery (mini)

7805 Voltage Regulator

Documented Code

// sketch.ino
const int MOISTURE_SENSOR_PIN = A0; // Assuming the sensor SIG pin is connected to A0
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 run on the Arduino UNO. It reads the moisture level from the soil moisture sensor and activates a relay to control a solenoid valve based on the moisture content. If the soil is too dry (below the threshold), the solenoid valve is opened to allow watering.