Skip to Content


info@hub360.com.ng 07044715478

GREENHOUSE CONTROLLER

February 18, 2025 by
GREENHOUSE CONTROLLER
My Company (Chicago), Hub360
| No comments yet

The Greenhouse Controller is an advanced automated system designed to monitor and regulate critical environmental parameters such as temperature, humidity, and light intensity within a greenhouse. By integrating sensors like the DHT11/DHT22 (for temperature and humidity) and an LDR (Light Dependent Resistor), along with actuators such as fans, heaters, and LED lights, this system ensures optimal conditions for plant growth. The Arduino microcontroller acts as the brain, collecting sensor data, processing it, and controlling devices to maintain the desired environment.

This project is a practical demonstration of how automation can enhance greenhouse efficiency, reduce manual intervention, and improve plant health. Whether you're a hobbyist, a farmer, or an educator, this system offers a hands-on way to explore the intersection of technology and agriculture.

Components Required

  • Arduino Uno
  • DHT11/DHT22 Sensor
  • LDR (Light Dependent Resistor)
  • Relay Module (4-channel)
  • Fan
  • Heater
  • LED (for light simulation)
  • LCD Display (16x2)
  • Resistors (10kΩ)
  • Power Supply
  • Breadboard 
  • Jumper Wires

Circuit Diagram

1. DHT11/DHT22 Sensor

  • Data Pin: Connect to digital pin D12 on the Arduino.
  • VCC Pin: Connect to 5V on the Arduino.
  • GND Pin: Connect to GND on the Arduino.

2. LDR (Light Dependent Resistor)

  • One Leg: Connect to 5V on the Arduino.
  • Other Leg: Connect to a 10kΩ resistor in series, then to GND.
  • Junction: Connect to analog pin A0 on the Arduino to read light intensity.

3. Relay Module

  • Input Pins: Connect to digital pins D8 (fan), D9 (heater), and D10 (light).
  • Output Terminals: Connect to the fan, heater, and LED light.
  • Power: Connect VCC to 5V and GND to GND on the Arduino.

4. LCD Display (16x2)

  • VSS: Connect to GND.
  • VDD: Connect to 5V.
  • V0: Connect to the middle pin of a 10kΩ potentiometer for contrast adjustment.
  • RS: Connect to D2.
  • E: Connect to D3.
  • D4-D7: Connect to D4-D7 on the Arduino.
  • A & K: Connect to 5V and GND for backlight.

5. Power Supply

  • Power the system

6. Upload the Code 

  • Use the Arduino IDE to upload the program for real-time monitoring and  automated control.



CODE

#include <DHT.h>

#include <LiquidCrystal.h>


#define DHTPIN 12 // DHT11 connected to D12

#define DHTTYPE DHT11


DHT dht(DHTPIN, DHTTYPE);


// LCD pin assignments (D2-D7)

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);


const int ldrPin = A0; // LDR connected to A0

const int fanRelay = 8; // Fan relay connected to D8

const int heaterRelay = 9; // Heater relay connected to D9

const int lightRelay = 10; // Light relay connected to D10


void setup() {

  dht.begin(); // Initialize DHT sensor

  lcd.begin(16, 2); // Initialize LCD

 

  pinMode(fanRelay, OUTPUT);

  pinMode(heaterRelay, OUTPUT);

  pinMode(lightRelay, OUTPUT);

 

  digitalWrite(fanRelay, LOW); // Ensure devices are off initially

  digitalWrite(heaterRelay, LOW);

  digitalWrite(lightRelay, LOW);

}


void loop() {

  float temp = dht.readTemperature(); // Read temperature

  float humidity = dht.readHumidity(); // Read humidity

  int light = analogRead(ldrPin); // Read light intensity


  // Display data on LCD

  lcd.setCursor(0, 0);

  lcd.print("Temp: ");

  lcd.print(temp);

  lcd.print("C");

 

  lcd.setCursor(0, 1);

  lcd.print("Hum: ");

  lcd.print(humidity);

  lcd.print("%");

 

  delay(2000); // Wait 2 seconds before next reading


  // Temperature Control

  if (temp > 30){

​digitalWrite(fanRelay, HIGH); // Turn on fan if too hot

  }

else {

​ digitalWrite(fanRelay, LOW);

 }


  if (temp < 20){

​digitalWrite(heaterRelay, HIGH); // Turn on heater if too cold

}

  else{

​digitalWrite(heaterRelay, LOW);

}


  // Light Control

  if (light < 500){

​ digitalWrite(lightRelay, HIGH); // Turn on light if too dark

}

  else{

​digitalWrite(lightRelay, LOW);

}

}

CODE EXPLANATION

1. Libraries and Pin Definitions

  • Libraries:
    • DHT.h: For interfacing with the DHT11/DHT22 sensor.
    • LiquidCrystal.h: For controlling the LCD display.
  • Pin Definitions:
    • DHTPIN: DHT11 connected to D12.
    • ldrPin: LDR connected to A0.
    • fanRelay, heaterRelay, lightRelay: Relays connected to D8, D9, and D10.

2. setup() Function

  • Initializes the DHT sensor and LCD.
  • Configures relay pins as outputs and ensures devices are off initially.

3. loop() Function

  • Reads temperature, humidity, and light intensity.
  • Displays data on the LCD.
  • Controls devices based on thresholds:
    • Fan: Turns on if temperature > 30°C.
    • Heater: Turns on if temperature < 20°C.
    • Light: Turns on if light intensity < 500.

OBSERVING FUNCTIONALITY

  1. Temperature Test: Simulate high or low temperatures near the DHT11 to observe fan or heater activation.
  2. Light Intensity Test: Cover the LDR to simulate darkness; the LED should turn on.
  3. Display Check: Ensure the LCD updates temperature and humidity readings in real time.

COMMON PROBLEMS AND SOLUTIONS

  1. Sensors Not Reading Correctly:
    • Check connections and ensure correct pin configuration.
    • Test the sensor independently using a simple Arduino sketch.
  2. Actuators Not Responding:
    • Verify relay module wiring and power connections.
    • Confirm the relay control logic in the code.
  3. LCD Not Displaying Data:
    • Double-check the wiring of the LCD pins.
    • Ensure the LCD library is installed and configured correctly.

Conclusion

The Greenhouse Controller is a powerful example of how automation can revolutionize agriculture. By maintaining optimal environmental conditions, this system ensures healthier plant growth, reduces resource waste, and minimizes manual labor. Its modular design allows for easy expansion, such as adding IoT connectivity or integrating additional sensors for soil moisture or CO2 levels.

Whether you're building a small-scale hobby greenhouse or prototyping for large-scale agricultural applications, this project offers a practical and educational introduction to smart farming. So, grab your components, upload the code, and watch your greenhouse thrive with automation! Happy tinkering!


Comments

Share this post
Tags
Archive
Sign in to leave a comment