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

Arduino UNO WiFi Smart Irrigation System with Soil Moisture Sensing and Temperature Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO WiFi Smart Irrigation System with Soil Moisture Sensing and Temperature Control

Smart Irrigation System Circuit Documentation

Summary

The Smart Irrigation System is designed to automate the watering process of a plant based on soil moisture and temperature readings. The system utilizes an Arduino UNO R4 WiFi as the main controller, interfaced with a DHT22 sensor for humidity and temperature measurements, and a YL-83 Module LM393 for soil moisture detection. A 5V relay is used to control a 5V mini water pump, which is powered by a 3xAAA Battery Pack. The system activates the water pump when the soil moisture is below a certain threshold and the temperature is within a specified range.

Component List

DHT22 (Wokwi Compatible)

3xAAA Battery Pack with Switch and JST

5v Mini Water Pump

Arduino UNO R4 WiFi

YL-69 Sonda

YL-83 Module LM393

5v Relay

Wiring Details

DHT22 (Wokwi Compatible)

3xAAA Battery Pack with Switch and JST

5v Mini Water Pump

Arduino UNO R4 WiFi

YL-69 Sonda

YL-83 Module LM393

5v Relay

Documented Code

/*
 * Smart Irrigation System
 * This Arduino sketch reads data from a DHT22 sensor (humidity and temperature)
 * and a soil moisture sensor. If the soil moisture is below a certain threshold
 * and the temperature is within an ideal range, it activates a relay to water
 * the plant by turning on a water pump.
 */

#include <DHT.h>

#define DHTPIN 2     // Pin connected to DHT22 data pin
#define DHTTYPE DHT22   // DHT 22 (AM2302)
#define RELAY_PIN 3  // Pin connected to Relay trigger
#define SOIL_PIN A1  // Pin connected to Soil Moisture Sensor

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  dht.begin();
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW); // Ensure relay is off initially
}

void loop() {
  delay(2000);  // Wait a few seconds between measurements

  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();
  int soilMoisture = analogRead(SOIL_PIN);

  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" *C");

  Serial.print("Soil Moisture: ");
  Serial.println(soilMoisture);

  // Control relay based on soil moisture and temperature
  if (soilMoisture < 300 && temperature > 15 && temperature < 35) {
    digitalWrite(RELAY_PIN, HIGH); // Turn on relay
  } else {
    digitalWrite(RELAY_PIN, LOW); // Turn off relay
  }
}

This code is designed to be uploaded to the Arduino UNO R4 WiFi microcontroller. It initializes the DHT22 sensor and the relay pin, reads the sensor data, and controls the relay based on the soil moisture and temperature readings.