Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Controlled Smart Greenhouse System with Environmental Monitoring

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Smart Greenhouse System with Environmental Monitoring

Circuit Documentation

Summary

The circuit is designed to monitor and control environmental conditions for a greenhouse system. It includes sensors for measuring soil moisture, light intensity, and air temperature and humidity. The system uses an Arduino UNO as the central microcontroller to process sensor data and control actuators such as a fan, a water pump, and an LED strip based on predefined thresholds. The actuators are controlled via 12V single-channel relays. An I2C LCD screen displays the temperature, humidity, soil moisture, and light levels.

Component List

Wiring Details

Module LDR

Soil Moisture Module

Fan

12V White LED Strip

I2C LCD 16x2 Screen

5V Mini Water Pump

Battery 12V

12V Single Channel Relay

Arduino UNO

DHT11 Sensor V2

Capacitive Soil Moisture Sensor V1.2

Documented Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>

// Define pin connections
#define DHTPIN 2              // DHT11 data pin connected to D2
#define DHTTYPE DHT11         // Defining the DHT sensor type as DHT11
#define SOIL_MOISTURE_PIN A0  // Soil moisture sensor connected to A0
#define LDR_PIN A1            // LDR sensor connected to A1
#define RELAY_FAN_PIN 3       // Relay controlling fan connected to D3
#define RELAY_PUMP_PIN 4      // Relay controlling water pump connected to D4
#define RELAY_LED_PIN 5       // Relay controlling LED strip connected to D5

// Initialize DHT sensor with the correct pin and type
DHT dht(DHTPIN, DHTTYPE);

// Initialize LCD (I2C address, columns, rows)
LiquidCrystal_I2C lcd(0x27, 16, 2); 

void setup() {
  // Start serial communication for debugging
  Serial.begin(9600);

  // Start DHT sensor
  dht.begin();
  
  // Initialize LCD display (16 columns, 2 rows)
  lcd.begin(16, 2);
  lcd.backlight();
  
  // Set pin modes
  pinMode(SOIL_MOISTURE_PIN, INPUT);
  pinMode(LDR_PIN, INPUT);
  pinMode(RELAY_FAN_PIN, OUTPUT);
  pinMode(RELAY_PUMP_PIN, OUTPUT);
  pinMode(RELAY_LED_PIN, OUTPUT);

  // Ensure all relays (fan, pump, LED) are off initially
  digitalWrite(RELAY_FAN_PIN, LOW);
  digitalWrite(RELAY_PUMP_PIN, LOW);
  digitalWrite(RELAY_LED_PIN, LOW);

  // Welcome message on LCD
  lcd.setCursor(0, 0);
  lcd.print("Greenhouse Sys");
  delay(2000);
  lcd.clear();
}

void loop() {
  // Read and map soil moisture value to percentage
  int soilMoistureValue = analogRead(SOIL_MOISTURE_PIN);
  int soilMoisturePercent = map(soilMoistureValue, 1023, 0, 0, 100); 

  // Read and map light level (LDR) to percentage
  int ldrValue = analogRead(LDR_PIN);
  int lightLevel = map(ldrValue, 0, 1023, 0, 100);

  // Read temperature and humidity values from DHT11 sensor
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  // Display temperature and humidity on LCD
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print("C Hum: ");
  lcd.print(humidity);
  lcd.print("%");

  // Display soil moisture and light level on LCD
  lcd.setCursor(0, 1);
  lcd.print("Soil: ");
  lcd.print(soilMoisturePercent);
  lcd.print("% Light: ");
  lcd.print(lightLevel);
  lcd.print("%");

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

  // Control water pump based on soil moisture
  if (soilMoisturePercent < 30) {
    digitalWrite(RELAY_PUMP_PIN, HIGH);  // Turn on water pump
  } else {
    digitalWrite(RELAY_PUMP_PIN, LOW);   // Turn off water pump
  }

  // Control LED strip based on light level
  if (lightLevel < 40) {
    digitalWrite(RELAY_LED_PIN, HIGH);  // Turn on LED strip
  } else {
    digitalWrite(RELAY_LED_PIN, LOW);   // Turn off LED strip
  }

  // Delay for 2 seconds before the next reading
  delay(2000);
}

This code is designed to run on the Arduino UNO microcontroller. It initializes the sensors and LCD, reads sensor data, and controls the fan, water pump, and LED strip based on the sensor readings. The LCD displays the current temperature, humidity, soil moisture, and light levels.