Arduino UNO Controlled Smart Greenhouse System with Environmental Monitoring
View and Edit Project In Cirkit Designer
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
- Module LDR: A light-dependent resistor module used to measure the intensity of light.
- Soil Moisture Module: A sensor module used to measure the moisture level in the soil.
- Fan: An electric fan used to regulate air circulation and temperature.
- 12V White LED Strip: A strip of LEDs used to provide supplemental lighting.
- I2C LCD 16x2 Screen: A 16x2 character LCD display with an I2C interface for showing sensor readings and system status.
- 5V Mini Water Pump: A small pump used for irrigation purposes.
- Battery 12V: A 12-volt battery that provides power to the system.
- 12V Single Channel Relay: An electromechanical switch used to control high-power devices with a low-power signal.
- Arduino UNO: A microcontroller board based on the ATmega328P, used as the main controller for the system.
- DHT11 Sensor V2: A sensor for measuring ambient temperature and humidity.
- Capacitive Soil Moisture Sensor V1.2: A sensor used to measure the moisture content in the soil.
Wiring Details
Module LDR
- VCC: Connected to 3.3V from Arduino UNO.
- GND: Connected to GND from Arduino UNO.
- DO: Not connected in this circuit.
- AO: Connected to A0 on Arduino UNO.
Soil Moisture Module
- Positive: Not connected in this circuit.
- Negative: Not connected in this circuit.
- Analog: Not connected in this circuit.
- Digital: Not connected in this circuit.
- Ground: Connected to GND from Arduino UNO.
- VCC: Connected to 3.3V from Arduino UNO.
Fan
- GND: Connected to the negative terminal of the 12V battery.
- 5V: Connected to the Normally Open (NO) terminal of the relay controlled by D3 on Arduino UNO.
12V White LED Strip
- +12V: Connected to the Normally Open (NO) terminal of the relay controlled by D5 on Arduino UNO.
- GND: Connected to the negative terminal of the 12V battery.
I2C LCD 16x2 Screen
- SCL: Connected to SCL on Arduino UNO.
- SDA: Connected to SDA on Arduino UNO.
- VCC (5V): Connected to 5V from Arduino UNO.
- GND: Connected to GND from Arduino UNO.
- Other Pins: Not connected in this circuit.
5V Mini Water Pump
- Positive Pin: Connected to the Normally Open (NO) terminal of the relay controlled by D4 on Arduino UNO.
- Negative Pin: Connected to the negative terminal of the 12V battery.
Battery 12V
- +: Connected to the Common (COM) terminal of all relays.
- -: Connected to GND of the circuit.
12V Single Channel Relay
- NC: Not connected in this circuit.
- COM: Connected to the positive terminal of the 12V battery.
- NO: Connected to the respective devices (fan, pump, LED strip).
- IN: Connected to the respective control pins on Arduino UNO (D3, D4, D5).
- GND: Connected to GND from Arduino UNO.
- VCC: Connected to 5V from Arduino UNO.
Arduino UNO
- Digital and Analog Pins: Connected to various components as per the control requirements.
- 5V and 3.3V: Provide power to the sensors and relay modules.
- GND: Common ground for the circuit.
DHT11 Sensor V2
- GND: Connected to GND from Arduino UNO.
- DAT: Connected to D2 on Arduino UNO.
- VCC: Connected to 3.3V from Arduino UNO.
Capacitive Soil Moisture Sensor V1.2
- GND: Connected to GND from Arduino UNO.
- VCC: Connected to 5V from Arduino UNO.
- AOUT: Connected to A1 on Arduino UNO.
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.