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

Arduino Nano and ESP32-Based Smart Irrigation System with Soil Moisture and DHT11 Sensors

View and Edit Project In Cirkit DesignerImage of Arduino Nano and ESP32-Based Smart Irrigation System with Soil Moisture and DHT11 Sensors

Circuit Documentation

Summary

This circuit is designed to monitor soil moisture levels and control a water pump to automatically water plants. It uses an Arduino Nano to read data from a soil moisture sensor and a DHT11 temperature and humidity sensor. Based on the soil moisture level, the Arduino controls a relay module to turn the water pump on or off. An ESP32 is also included for potential wireless communication or additional processing.

Component List

  1. Arduino Nano

    • Description: A small, complete, and breadboard-friendly board based on the ATmega328P.
    • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK
  2. Soil Moisture Sensor

    • Description: Measures the volumetric content of water in soil.
    • Pins: VCC, GND, SIG
  3. 1 Channel 5V Relay Module

    • Description: Allows the Arduino to control high voltage devices like a water pump.
    • Pins: VCC+, VCC- (GND), IN, N.O., COM, N.C.
  4. Water Pump

    • Description: A small pump used to water plants.
    • Pins: VCC, GND
  5. DHT11

    • Description: A sensor for measuring temperature and humidity.
    • Pins: DATA, GND, VCC
  6. 9V Battery

    • Description: Provides power to the water pump.
    • Pins: -, +
  7. ESP32 (30 pin)

    • Description: A low-cost, low-power system on a chip with Wi-Fi and Bluetooth capabilities.
    • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3

Wiring Details

Arduino Nano

Soil Moisture Sensor

1 Channel 5V Relay Module

Water Pump

DHT11

9V Battery

ESP32 (30 pin)

Code Documentation

#include <DHT.h>

#define DHTPIN 6           // DHT11 data pin connected to pin D6
#define DHTTYPE DHT11      // DHT11 sensor
#define RELAY_PIN 7        // Relay control pin
#define MOISTURE_SENSOR A0 // Soil moisture sensor analog pin

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(MOISTURE_SENSOR, INPUT);

  Serial.begin(9600);
  dht.begin();
}

void loop() {
  int moistureLevel = analogRead(MOISTURE_SENSOR);  // Read soil moisture level
  float humidity = dht.readHumidity();              // Read humidity
  float temperature = dht.readTemperature();        // Read temperature

  int threshold = 500;  // Moisture threshold

  // Print sensor data to Serial Monitor
  Serial.print("Soil Moisture Level: ");
  Serial.println(moistureLevel);
  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println("%");
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println("°C");

  // Check if soil is dry, activate water pump
  if (moistureLevel < threshold) {
    digitalWrite(RELAY_PIN, HIGH);  // Turn on water pump
    Serial.println("Watering the plants...");
  } else {
    digitalWrite(RELAY_PIN, LOW);   // Turn off water pump
    Serial.println("Soil moisture is sufficient.");
  }

  delay(2000);  // Wait before taking next reading
}

This code initializes the DHT11 sensor and sets up the pins for the relay and soil moisture sensor. In the loop, it reads the soil moisture level, humidity, and temperature, and prints these values to the Serial Monitor. If the soil moisture level is below a certain threshold, it activates the relay to turn on the water pump. Otherwise, it turns off the water pump. The loop repeats every 2 seconds.