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

Arduino-Based Smart Garden Monitoring System with LCD Display and Automated Water Pump

View and Edit Project In Cirkit DesignerImage of Arduino-Based Smart Garden Monitoring System with LCD Display and Automated Water Pump

Circuit Documentation

Summary

This circuit is designed to monitor environmental conditions such as light level, soil moisture, temperature, and pH level. It uses an Arduino UNO microcontroller to read data from various sensors and display the information on an LCD screen. Additionally, the circuit controls a water pump via a relay module to maintain soil moisture levels.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. Temperature Sensor (LM35)

    • Description: Analog temperature sensor.
    • Pins: +Vs, Vout, GND
  3. SparkFun Soil Moisture Sensor

    • Description: Sensor to measure soil moisture levels.
    • Pins: VCC, GND, SIG
  4. 5V Mini Water Pump

    • Description: Small water pump powered by 5V.
    • Pins: Positive pin, Negative pin
  5. Relay Module 5V-30V

    • Description: Relay module to control high voltage devices.
    • Pins: Common contact, Normally open, Normally closed, Trigger, V-, V+
  6. LCD Display (16 pin)

    • Description: 16x2 character LCD display.
    • Pins: VSS, VDD, VO, RS, R_W, E, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7, A, K
  7. Potentiometer

    • Description: Variable resistor for adjusting LCD contrast.
    • Pins: GND, Output, VCC
  8. Ambient Light Sensor

    • Description: Sensor to measure ambient light levels.
    • Pins: GND, VCC, DATA
  9. Resistor

    • Description: 10k Ohm resistor.
    • Pins: Pin1, Pin2
  10. PH Meter

    • Description: Sensor to measure pH levels.
    • Pins: Signal, VCC, GND

Wiring Details

Arduino UNO

Temperature Sensor (LM35)

SparkFun Soil Moisture Sensor

5V Mini Water Pump

Relay Module 5V-30V

LCD Display (16 pin)

Potentiometer

Ambient Light Sensor

Resistor

PH Meter

Code Documentation

#include <LiquidCrystal.h>
#include <DHT.h>

// Pin definitions
#define LDR_PIN A0                // LDR pin for light sensor
#define MOISTURE_PIN A1           // Soil Moisture Sensor
#define DHT_PIN 2                 // DHT11 sensor pin
#define RELAY_PIN 8               // Relay pin to control water pump
#define POT_PIN A2                // Potentiometer for LCD contrast
#define PH_PIN A3                 // pH sensor pin

// DHT sensor setup
#define DHT_TYPE DHT11            // Define the DHT sensor type (DHT11 or DHT22)
DHT dht(DHT_PIN, DHT_TYPE);

// LCD setup (16x2 LCD)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Pin mapping for 4-bit mode

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize the LCD
  lcd.begin(16, 2);
  lcd.setBacklight(1); // Turn on the backlight

  // Initialize DHT sensor
  dht.begin();

  // Set the relay pin as output
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW); // Ensure pump is off at start
}

void loop() {
  // Read sensor values
  int lightLevel = analogRead(LDR_PIN);        // Read light level
  int moistureLevel = analogRead(MOISTURE_PIN);  // Read soil moisture level
  float temperature = dht.readTemperature();  // Read temperature
  int phLevel = analogRead(PH_PIN);           // Read pH level from sensor

  // Check if DHT sensor failed to read
  if (isnan(temperature)) {
    Serial.println("Failed to read temperature!");
    temperature = 0.0;  // Set to 0 in case of failure
  }

  // Read potentiometer value to adjust LCD contrast
  int contrast = analogRead(POT_PIN) / 4;  // Scale potentiometer value (0-1023 -> 0-255)

  // Adjust the LCD contrast (not all LCD models support this method, it's for some specific types)
  analogWrite(6, contrast);  // Pin 6 for contrast adjustment (if applicable, for some LCD models)

  // Print the values to the Serial Monitor for debugging
  Serial.print("Light Level: ");
  Serial.print(lightLevel);
  Serial.print(" Moisture Level: ");
  Serial.print(moistureLevel);
  Serial.print(" Temp: ");
  Serial.print(temperature);
  Serial.print(" pH: ");
  Serial.println(phLevel);

  // Display values on the LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print