Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Based Automated Plant Watering and Light Management System

Image of Arduino UNO Based Automated Plant Watering and Light Management System

Circuit Documentation

Summary

This circuit is designed to interface an Arduino UNO with various sensors and actuators for environmental monitoring and control. It includes an I2C LCD for display, a DHT11 sensor for temperature and humidity measurements, a soil moisture sensor, a photocell (LDR) with a resistor for light detection, a relay module to control a water pump and an LED bulb, and the water pump and LED bulb as the actuators.

Component List

Arduino UNO

  • Microcontroller board based on the ATmega328P
  • Provides digital and analog I/O pins
  • Powers the circuit and controls the sensors and actuators

I2C LCD 16x2 Screen

  • Alphanumeric liquid crystal display
  • Uses I2C communication protocol
  • Displays temperature, humidity, soil moisture, and light levels

KY-015 DHT11

  • Digital temperature and humidity sensor
  • Provides ambient temperature and humidity readings

Relay Module 2 Channel

  • Contains two independent relay switches
  • Controls high power devices like the water pump and LED bulb

Water Pump

  • Electric pump for water circulation
  • Controlled by one of the relays on the relay module

LED bulb AC / Bombillo AC

  • Light source for the environment
  • Controlled by the other relay on the relay module

SparkFun Soil Moisture Sensor

  • Measures the moisture level in the soil
  • Helps in determining when to activate the water pump

Photocell (LDR)

  • Light-dependent resistor
  • Measures the intensity of light in the environment

Resistor

  • Fixed resistor with a value of 200 Ohms
  • Forms a voltage divider with the photocell for light measurement

Wiring Details

Arduino UNO

  • 5V and GND pins provide power to the I2C LCD, Relay Module, Photocell, Soil Moisture Sensor, and DHT11 sensor.
  • A0 pin connected to the Photocell through a 200 Ohm resistor for light measurement.
  • A2 pin connected to the Soil Moisture Sensor for moisture level detection.
  • SCL and SDA pins connected to the I2C LCD for data display.
  • D10 pin controls the Relay Module's IN1, which in turn controls the Water Pump.
  • D8 pin controls the Relay Module's IN2, which in turn controls the LED bulb.
  • D4 pin connected to the DHT11 sensor for temperature and humidity readings.

I2C LCD 16x2 Screen

  • SCL and SDA pins connected to the corresponding pins on the Arduino UNO for I2C communication.
  • VCC (5V) and GND pins connected to the power supply lines.

KY-015 DHT11

  • S pin connected to D4 on the Arduino UNO for data signal.
  • 5V and GND pins connected to the power supply lines.

Relay Module 2 Channel

  • IN1 and IN2 pins connected to D10 and D8 on the Arduino UNO for control signals.
  • VCC connected to the 5V power supply line.
  • GND connected to the ground line.
  • NO1 connected to the Water Pump's VCC.
  • NO2 connected to the LED bulb's +.

Water Pump

  • VCC connected to NO1 on the Relay Module.
  • GND connected to the ground line.

LED bulb AC / Bombillo AC

  • + connected to NO2 on the Relay Module.
  • - connected to the ground line.

SparkFun Soil Moisture Sensor

  • SIG pin connected to A2 on the Arduino UNO for signal output.
  • VCC and GND pins connected to the power supply lines.

Photocell (LDR)

  • One pin connected to A0 on the Arduino UNO through a 200 Ohm resistor.
  • The other pin connected to the ground line.

Resistor

  • One pin connected to the ground line.
  • The other pin connected to the Photocell and A0 on the Arduino UNO.

Documented Code

#include <dht11.h>
#define DHT11PIN 4

// Including Libraries for I2C LCD
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

// Initialize the DHT sensor
dht11 DHT11;

// Initialize LCD
LiquidCrystal_I2C lcd(0x27, 20, 2); // Set the LCD address to 0x27 for a 20 chars and 4 line display

const int maxLDRValue = 1023;
const int maxSMSValue = 1023;

// Light duration variables
const unsigned long lightDurationThreshold = 50400000; // 14 hours in milliseconds
const unsigned long resetDuration = 86400000; // 24 hours in milliseconds
unsigned long lightDuration = 0;
unsigned long startTime = 0;
bool lightDetected = false;

void setup() 
{
  pinMode(A0, INPUT); // Photoresistor
  pinMode(A2, INPUT); // Soil Moisture
  pinMode(D10, OUTPUT); // Pump
  pinMode(D8, OUTPUT); // Lamp
  Serial.begin(9600); 
  lcd.begin();
  startTime = millis(); // Initialize start time
}

void loop() 
{
  delay(1000);
  int chk = DHT11.read(DHT11PIN);
  int photoresistorValue = analogRead(A0);
  int soilmoistureValue = analogRead(A2);
  float percentage = (float)photoresistorValue / maxLDRValue * 100;
  float percentageSMS = (float)soilmoistureValue / maxSMSValue * 100;
  
  // Soil moisture control
  if (percentageSMS < 40) {
    digitalWrite(D10, HIGH); // Turn on pump
  } else {
    digitalWrite(D10, LOW); // Turn off pump
  }

  // Light control
  if (percentage > 20) {
    lightDetected = true;
    lightDuration += millis() - startTime; // Accumulate time in light
  } else {
    lightDetected = false;
  }

  // Reset light duration after 24 hours
  if (millis() - startTime >= resetDuration) {
    lightDuration = 0; // Reset light duration
    startTime = millis(); // Reset start time
  }

  // Check light duration
  if (lightDuration >= lightDurationThreshold) {
    digitalWrite(D8, LOW); // Turn off lamp
  } else if (!lightDetected) {
    digitalWrite(D8, HIGH); // Turn on lamp if light duration not reached
  }

  // Display data on LCD
  lcd.setCursor(0, 0);
  lcd.print("Temperature,");
  lcd.setCursor(0, 1);
  lcd.print("Lumen & humidity");
  delay(1000);
  lcd.clear();
  
  lcd.print("Temp: ");
  lcd.print(DHT11.temperature);
  lcd.print((char)223);  
  lcd.print("C");
  
  lcd.setCursor(0, 1);
  lcd.print("Hum: ");
  lcd.print(DHT11.humidity);
  lcd.print("%  ");
  delay(1000);

  lcd.setCursor(0, 1);
  lcd.print("SM percentage:");
  lcd.print(percentageSMS);
  delay(1000);

  lcd.clear();
  if (percentage > 40) {
    lcd.print("Light: ");
    lcd.print(percentage);
    lcd.print("%");
  } else {
    lcd.print("There isn't ");
    lcd.setCursor(0, 1);
    lcd.print("enough light");
    delay(800);
    lcd.clear();
    lcd.print("Light percentage is:");
    lcd.setCursor(0, 1);
    lcd.print(percentage);
    lcd.print("%");
  }
  delay(1000);
  lcd.clear();
}

This code is responsible for reading sensor data, controlling the actuators, and displaying information on the LCD. It includes a light duration feature to control the LED bulb based on the amount of light detected during a 24-hour period. The water pump is controlled based on the soil moisture level. The temperature and humidity are read from the DHT11 sensor and displayed on the LCD along with the light and soil moisture percentages.