Automated Greenhouse System

Control temperature, humidity, light, and watering for optimal plant growth using IoT technology.

Project Overview

This project utilizes sensors and actuators to automatically manage environmental conditions within a greenhouse. By leveraging IoT devices like the ESP8266 or ESP32, the system will autonomously control heating, ventilation, lighting, and irrigation based on real-time sensor data.

Components Required

Circuit Diagram

The microcontroller (ESP8266/ESP32) is connected to sensors for monitoring temperature, humidity, soil moisture, and light levels. Relays control the irrigation pump, greenhouse lights, and ventilation fans based on sensor readings. Data is sent to a web interface for monitoring.

Greenhouse Circuit Diagram

Sample Code

The following code snippet reads sensor data and controls the actuators based on pre-set thresholds:


// Automated Greenhouse System Code
#include 
#include 
#include 
#include 
#include 

// Define pins for relays
#define RELAY_FAN D1
#define RELAY_LIGHTS D2
#define RELAY_WATER_PUMP D3

// Define sensors
#define DHTPIN D4
#define SOIL_SENSOR_PIN A0
DHT dht(DHTPIN, DHT22);
Adafruit_BME280 bme;  // BME280 for temp, humidity, and pressure

// Wi-Fi credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";

void setup() {
  Serial.begin(115200);
  dht.begin();
  bme.begin();
  
  pinMode(RELAY_FAN, OUTPUT);
  pinMode(RELAY_LIGHTS, OUTPUT);
  pinMode(RELAY_WATER_PUMP, OUTPUT);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");
}

void loop() {
  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();
  int soilMoisture = analogRead(SOIL_SENSOR_PIN);
  float lightLevel = bme.readLight();

  // Control fan
  if (temperature > 30) {
    digitalWrite(RELAY_FAN, HIGH);  // Turn on fan
  } else {
    digitalWrite(RELAY_FAN, LOW);   // Turn off fan
  }

  // Control lights
  if (lightLevel < 200) {
    digitalWrite(RELAY_LIGHTS, HIGH);  // Turn on lights
  } else {
    digitalWrite(RELAY_LIGHTS, LOW);   // Turn off lights
  }

  // Control water pump
  if (soilMoisture < 500) {
    digitalWrite(RELAY_WATER_PUMP, HIGH);  // Turn on pump
  } else {
    digitalWrite(RELAY_WATER_PUMP, LOW);   // Turn off pump
  }

  delay(5000);  // Repeat every 5 seconds
}
            

Web Interface for Monitoring

The following HTML structure shows how you can create a web interface for monitoring real-time data from the greenhouse:


// Web Interface HTML



  
  
  Greenhouse Dashboard
  


  

Greenhouse Monitoring Dashboard

Temperature: -- °C

Humidity: -- %

Soil Moisture: --

Light Level: --

Features

Future Enhancements