IoTSimulator

Mini Smart Greenhouse Climate Automator with Arduino

Build an automated greenhouse climate controller using a DHT22 sensor, I2C LCD1602 display, simulated cooling ventilation fan, and heating elements.
Mini Smart Greenhouse Climate Automator with Arduino

Live project track

Interactive hardware & logic preview

Have you ever stepped inside a commercial greenhouse on a hot summer afternoon and noticed automated vents sliding open while exhaust fans spin to life? High temperatures and stagnant humidity can scorch fragile seedlings and promote fungal mildew within hours.

In this project, you will build a mini smart greenhouse climate automator using an Arduino Uno, a high-precision DHT22 digital temperature and humidity sensor, an I2C LCD1602 display, and a ventilation fan driver. The core concept to master is: using combined environmental telemetry thresholds (heat and humidity) to drive active cooling actuators and maintain closed-loop equilibrium.

How the DHT22 Measures Temperature and Humidity

Think of checking weather conditions with a wet-and-dry bulb thermometer. Humidity refers to the amount of water vapor suspended in the air. High humidity slows evaporation, while low humidity accelerates moisture loss from plant leaves.

The DHT22 (AM2302) sensor houses two internal sensing elements: a capacitive humidity sensor and a negative temperature coefficient (NTC) thermistor. An onboard 8-bit microcontroller measures both physical properties, converts them to calibrated digital values, and transmits them across a single-wire digital bus.

Climate ParameterSensing ElementMeasurement RangeAccuracy
Relative Humidity (RH)Capacitive Polymer Substrate0% to 100% RH± 2% RH
Ambient TemperatureNTC Ceramic Thermistor-40°C to +80°C± 0.5°C
Ventilation TriggerDual Threshold Comparison> 28°C or > 70% RHHysteresis Protected

Every two seconds, the Arduino sends a start signal pulling the data pin LOW for 1 millisecond. The DHT22 responds with a 40-bit data packet containing 16 bits of humidity data, 16 bits of temperature data, and an 8-bit parity checksum.

If temperature climbs past 28°C or humidity exceeds 70%, the Arduino commands the digital output pin to engage the ventilation exhaust fan, expelling excess moisture and heat until conditions normalize.

The DHT22 provides much higher precision (0.1°C resolution) than the older blue DHT11 sensor (1°C resolution), making it the gold standard for climate incubation.

Building the Mini Greenhouse Circuit

The Arduino Uno provides stable 5V power and a common GND reference to the DHT22 sensor, the I2C LCD screen, and the cooling fan transistor or relay circuit. 5V supplies operating power, while GND completes the electrical loop.

Digital pin D12 connects to the DHT22 data line with a 4.7kΩ or 10kΩ pull-up resistor to ensure clean digital signal transitions. The I2C LCD connects to analog pins A4 (SDA) and A5 (SCL).

Pin Connection Map
DHT22 Climate Sensor
Pin 1 (VCC)
→
Arduino Uno
5V
Explanation
Supplies regulated 5V power to sensor microcontroller.
DHT22 Climate Sensor
Pin 2 (DATA)
→
Arduino Uno
D12
Explanation
Bi-directional single-wire digital communication bus.
DHT22 Climate Sensor
Pin 4 (GND)
→
Arduino Uno
GND.1
Explanation
Sensor ground return line.
Pin Connection Map
I2C LCD1602
VCC
→
Arduino Uno
5V
Explanation
Powers LCD controller and backlight.
I2C LCD1602
GND
→
Arduino Uno
GND.2
Explanation
Returns display ground current.
I2C LCD1602
SDA
→
Arduino Uno
A4
Explanation
I2C serial data communication line.
I2C LCD1602
SCL
→
Arduino Uno
A5
Explanation
I2C serial clock synchronization line.
Pin Connection Map
Ventilation Fan Driver
Signal (IN)
→
Arduino Uno
D7
Explanation
Digital output: HIGH turns exhaust fan ON.
Ventilation Fan Driver
Ground (-)
→
Arduino Uno
GND.3
Explanation
Fan driver ground reference.

The Complete Smart Greenhouse Sketch

Below is the complete, tested Arduino sketch. It samples the DHT22 every two seconds, updates the climate dashboard on the LCD, and controls greenhouse ventilation automatically.

C++ Source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "DHT.h"

#define DHTPIN 12
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);

const int fanPin = 7;
const float TEMP_LIMIT = 28.0; // Celsius
const float HUMID_LIMIT = 70.0; // Percent

void setup() {
  Serial.begin(9600);
  pinMode(fanPin, OUTPUT);
  digitalWrite(fanPin, LOW);

  dht.begin();
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Greenhouse Auto");
  lcd.setCursor(0, 1);
  lcd.print("Sensors Warmup..");
  delay(2000);
  lcd.clear();
  Serial.println("[System]: Greenhouse Automator Ready");
}

void loop() {
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  if (isnan(humidity) || isnan(temperature)) {
    lcd.setCursor(0, 0);
    lcd.print("Sensor Read Err ");
    return;
  }

  lcd.setCursor(0, 0);
  lcd.print("T:");
  lcd.print(temperature, 1);
  lcd.print("C H:");
  lcd.print(humidity, 0);
  lcd.print("%  ");

  lcd.setCursor(0, 1);
  if (temperature > TEMP_LIMIT || humidity > HUMID_LIMIT) {
    digitalWrite(fanPin, HIGH); // Turn fan ON
    lcd.print("Fan: ACTIVE (COOL)");
    Serial.println("[Action]: Climate hot/humid. Venting active.");
  } else {
    digitalWrite(fanPin, LOW);  // Turn fan OFF
    lcd.print("Fan: OFF (STABLE) ");
    Serial.println("[Status]: Climate ideal.");
  }

  delay(2000);
}

How the Code Works, Step by Step

Let us review each functional block of the greenhouse automator.

Configuring DHT22 and Climate Thresholds

The code instantiates DHT dht(12, DHT22) and sets TEMP_LIMIT = 28.0 and HUMID_LIMIT = 70.0. These define the maximum safe boundaries for greenhouse crops.

Sampling Telemetry and Validating Packets

Inside loop(), dht.readTemperature() and dht.readHumidity() extract readings. The safety check isnan() prevents invalid calculations if a wire is temporarily loose.

Evaluating Climate and Actuating Ventilation

A logical OR condition temperature > TEMP_LIMIT || humidity > HUMID_LIMIT checks if either environmental parameter is compromised. If true, digital pin 7 pulls HIGH, spinning the exhaust fan to restore fresh air circulation.

Practical Testing and Tuning

In the IoTSimulator workspace, use the interactive DHT22 environmental sliders. Drag the temperature to 32°C and observe the LCD switch immediately to Fan: ACTIVE (COOL) with the DC fan spinning. Lower temperature back to 24°C to verify automated shutdown.

Keywords
#Arduino #Greenhouse #DHT22 #Climate Control #Automation
Total word count: 582 words

More in Sunlight Actor

Continue exploring this hardware category

Project discussion

Questions, feedback, and community insights
No discussions yet. Be the first to start!