Back to Robotics Hub
Intermediate Builds Intermediate Mar 21, 2026

Smart Greenhouse Monitor

Smart Greenhouse Monitor

Project Overview

An excellent introduction to IoT and environmental sensing. We use the DHT11 sensor for ambient climate and a resistive soil moisture sensor to water a plant automatically when it gets too dry.

Components Required

  • 1x Arduino Uno
  • 1x DHT11 Temp/Humidity Sensor
  • 1x Soil Moisture Sensor
  • 1x 5V Relay Module
  • 1x 5V Submersible Water Pump

Wiring Guide

Connect the relay IN pin to Arduino Pin 8. Splice the pump power wire so it runs through the relay's COM and NO terminals. Connect DHT11 data to Pin 2 and the Soil Moisture analog output to A0.

Source Code


#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

int pumpPin = 8;
int soilPin = A0;
int threshold = 400; // Change based on calibration

void setup() {
  Serial.begin(9600);
  dht.begin();
  pinMode(pumpPin, OUTPUT);
  digitalWrite(pumpPin, HIGH); // Relay is active low usually
}

void loop() {
  int moisture = analogRead(soilPin);
  float temp = dht.readTemperature();
  
  if (moisture < threshold) {
    digitalWrite(pumpPin, LOW);  // Turn on pump
    delay(2000);                 // Pump for 2 seconds
    digitalWrite(pumpPin, HIGH); // Turn off pump
  }
  delay(10000); // Check every 10 seconds
}