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

Arduino Mega 2560 Environmental Control System with DHT11 Sensor and I2C LCD

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560 Environmental Control System with DHT11 Sensor and I2C LCD

Circuit Documentation

Summary

This circuit is an environmental control system that monitors temperature and humidity using a DHT11 sensor and controls various devices such as an exhaust fan, intake fan, sprinkler, and compressors. The system is managed by an Arduino Mega 2560 microcontroller, which also displays the current temperature and humidity on a 16x2 I2C LCD. The exhaust fan activates when the temperature exceeds a set range, followed by the intake fan after 20 seconds. The sprinkler activates when humidity falls below a set range. The compressors operate on specific schedules and durations.

Component List

  1. Exhaust Fan 12"

    • Pins: Live, Neutral
    • Description: Controls air exhaust based on temperature.
  2. Fan

    • Pins: GND, 5V
    • Description: Controls air intake based on temperature.
  3. DHT11

    • Pins: DATA, GND, VCC
    • Description: Measures temperature and humidity.
  4. 16x2 I2C LCD

    • Pins: GND, VCC, SDA, SCL
    • Description: Displays temperature and humidity readings.
  5. Arduino Mega 2560

    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, SDA, SCL, AREF
    • Description: Microcontroller that manages the entire system.
  6. 2 Channel Relay Module

    • Pins: N.O. 2, COM 2, N.C. 2, N.O. 1, COM 1, N.C. 1, pin 7-12, VCC+, VCC- (GND), IN 1, IN 2
    • Description: Controls the exhaust fan and intake fan.
  7. Water Pump

    • Pins: VCC, GND
    • Description: Activates based on humidity levels.
  8. Relay 12V

    • Pins: ground, in, VCC, NO, COM, NC
    • Description: Controls the water pump.
  9. 4 Channel Relay Module

    • Pins: N.O. 4, COM 4, N.C. 4, N.O. 3, COM 3, N.C. 3, N.O. 2, COM 2, N.C. 2, N.O. 1, COM 1, N.C. 1, Pin 13-24, VCC+, VCC- (GND), IN 1-4
    • Description: Controls the compressors.
  10. USB Male 2 Pin Connection

    • Pins: Negative -, Positive +
    • Description: Provides power to the circuit.

Wiring Details

Exhaust Fan 12"

Fan

DHT11

16x2 I2C LCD

Arduino Mega 2560

2 Channel Relay Module

Water Pump

Relay 12V

4 Channel Relay Module

Code Documentation

/*
 * This Arduino sketch controls an environmental system based on temperature and
 * humidity readings from a DHT11 sensor. The system includes an exhaust fan,
 * intake fan, sprinkler, and three compressors. The exhaust fan activates when
 * the temperature exceeds a set range, followed by the intake fan after 20
 * seconds. The sprinkler activates when humidity falls below a set range. The
 * compressors operate on specific schedules and durations. The current
 * temperature and humidity are displayed on a 16x2 I2C LCD.
 */

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

#define DHTPIN 2
#define DHTTYPE DHT11
#define EXHAUST_FAN_PIN 3
#define INTAKE_FAN_PIN 4
#define SPRINKLER_PIN 5
#define COMPRESSOR1_PIN 6
#define COMPRESSOR2_PIN 7
#define COMPRESSOR3_PIN 8

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

const float TEMP_MIN = 30.0;
const float TEMP_MAX = 36.0;
const float HUMIDITY_MIN = 85.0;
const float HUMIDITY_MAX = 95.0;

void setup() {
  pinMode(EXHAUST_FAN_PIN, OUTPUT);
  pinMode(INTAKE_FAN_PIN, OUTPUT);
  pinMode(SPRINKLER_PIN, OUTPUT);
  pinMode(COMPRESSOR1_PIN, OUTPUT);
  pinMode(COMPRESSOR2_PIN, OUTPUT);
  pinMode(COMPRESSOR3_PIN, OUTPUT);
  lcd.begin();
  lcd.backlight();
  dht.begin();
}

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

  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temp);
  lcd.print("C");
  lcd.setCursor(0, 1);
  lcd.print("Humidity: ");
  lcd.print(humidity);
  lcd.print("%");

  if (temp > TEMP_MAX) {