Illustration of a automated iot greenhouse system.

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

  • ESP8266 or ESP32 microcontroller
  • Temperature and humidity sensor (e.g., DHT22 or BME280)
  • Soil moisture sensor
  • Light intensity sensor (e.g., BH1750)
  • Relay modules to control fans, lights, and pumps
  • Water pump and irrigation system
  • Heater/fan control unit
  • Wi-Fi connectivity for remote monitoring

PureVPN – 84% Off for a Limited Time!

As seen in Forbes, PCMag & TechRadar

High-Speed VPN for Streaming & Security 6,500+ Servers in 78+ Countries Unblocks Netflix, Hulu, BBC iPlayer & More

– 84% OFF + 5 Extra Months FREE!

🔗 Claim Your 84% Discount Now!

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

  • Automatic control of heating, lighting, and irrigation
  • Real-time monitoring of environmental conditions
  • Web interface for remote monitoring
  • Data logging and trend analysis

Future Enhancements

  • Mobile app for controlling the greenhouse remotely
  • Integration with weather forecasts for proactive control
  • Machine learning to optimize plant growth conditions

Contact Us

Microautomation logo featuring a modern, abstract design with interconnected gears, circuit lines, and microcontroller elements, symbolizing automation and technology.

If you have any questions or inquiries, feel free to reach out to us at Microautomation.no@icloud.com .

Follow our Socials for the newest updates!

Follow us on Facebook Follow us on Reddit Follow us on Instagram