

This circuit is designed to automate the watering of plants based on soil moisture levels. It uses an Arduino UNO to read the soil moisture sensor and control a water pump via a relay. Additionally, a UV-C tube is included, which can be controlled by the Arduino.
Arduino UNO
Water Pump
Soil Moisture Sensor
1-Channel Relay (5V 10A)
UV-C Tube
12v Battery
// Define pins
const int soilMoisturePin = A0;  // Analog pin for soil moisture sensor
const int ledPin = 13;            // Pin for LED
const int relayPin = 2;          // Pin for relay module
// Threshold for soil moisture (you may need to calibrate this)
int soilMoistureValue = 0;  // Variable to store the sensor reading
int threshold = 500;         // Change this value based on your soil's moisture level (adjust as needed)
void setup() {
  // Initialize the LED and relay pins
  pinMode(ledPin, OUTPUT);    
  pinMode(relayPin, OUTPUT);
  
  // Initialize Serial Monitor for debugging
  Serial.begin(9600);
}
void loop() {
  // Read the analog value from the soil moisture sensor
  soilMoistureValue = analogRead(soilMoisturePin);
  
  // Print the soil moisture value to the Serial Monitor (optional)
  Serial.print("Soil Moisture Value: ");
  Serial.println(soilMoistureValue);
  
  // If the soil is wet (moisture detected), turn on LED
  if (soilMoistureValue > threshold) {
    digitalWrite(ledPin, HIGH);   // Turn on the LED
    digitalWrite(relayPin, LOW);  // Turn off the water pump (relay OFF)
  }
  // If the soil is dry (moisture not detected), turn on water pump
  else {
    digitalWrite(ledPin, LOW);    // Turn off the LED
    digitalWrite(relayPin, HIGH); // Turn on the water pump (relay ON)
  }
  
  // Wait a moment before taking another reading
  delay(1000);  // 1 second delay (adjustable)
}
This code reads the soil moisture level and controls the water pump and UV-C tube based on the moisture level. The LED on pin 13 is used to indicate the status of the soil moisture. If the soil is dry, the water pump is turned on; otherwise, it is turned off.