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

Arduino UNO Based Automated Soil Moisture Monitoring and Water Pump Control System

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Automated Soil Moisture Monitoring and Water Pump Control System

Automated Irrigation System Documentation

Summary

This document describes an automated irrigation system designed to monitor soil moisture levels and automatically water plants when the soil moisture falls below a predefined threshold. The system uses an Arduino UNO as the central processing unit, a soil moisture sensor to measure the moisture level, a 2-channel relay to control the water pump, and an LCD I2C display to provide a user interface. The system is powered by a 9V battery and controls the water pump based on the moisture readings.

Component List

Arduino UNO

MKE-S13 Soil Moisture Sensor

2-Channel Relay

Water Pump

9V Battery

LCD I2C Display

Wiring Details

Arduino UNO

MKE-S13 Soil Moisture Sensor

2-Channel Relay

Water Pump

9V Battery

LCD I2C Display

Documented Code

Arduino UNO Code

const int sensorPin = A0; // Pin sensor kelembapan tanah
const int relayPin = 7;   // Pin kontrol relay
const int threshold = 500; // Ambang batas kelembapan tanah

void setup() {
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW); // Pastikan pompa mati saat startup
  Serial.begin(9600); // Untuk debugging
}

void loop() {
  int sensorValue = analogRead(sensorPin); // Baca nilai dari sensor kelembapan tanah
  
  Serial.print("Kelembapan Tanah: ");
  Serial.println(sensorValue); // Tampilkan nilai sensor ke serial monitor

  if (sensorValue < threshold) {
    digitalWrite(relayPin, HIGH); // Hidupkan pompa
    Serial.println("Pompa ON");
  } else {
    digitalWrite(relayPin, LOW); // Matikan pompa
    Serial.println("Pompa OFF");
  }
  
  delay(2000); // Tunggu 2 detik sebelum pembacaan berikutnya
}

This code is responsible for reading the soil moisture sensor data, comparing it to a predefined threshold, and controlling the relay to turn the water pump on or off accordingly. It also sends the soil moisture readings to the serial monitor for debugging purposes.

Relay Module Code

void setup() {
  // No setup code required for relay module
}

void loop() {
  // No loop code required for relay module
}

The relay module does not require any specific code as it is directly controlled by the Arduino UNO through one of its digital pins.

9V Battery Code

void setup() {
  // No setup code required for the battery
}

void loop() {
  // No loop code required for the battery
}

The 9V battery does not require any code as it is a power source.