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

Arduino Mega 2560-Based Smart Environmental Control System with DHT22 and Photocell

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560-Based Smart Environmental Control System with DHT22 and Photocell

Circuit Documentation

Summary

This document provides a detailed overview of a circuit designed to monitor environmental conditions and control various actuators. The circuit includes sensors for temperature and humidity, a photocell, multiple motors, a fan heater, a water pump, and a relay module. An Arduino Mega 2560 microcontroller is used to process sensor data and control the actuators based on predefined conditions.

Component List

  1. DHT22

    • Description: Digital temperature and humidity sensor.
    • Pins: +, Out, -
  2. Photocell (LDR)

    • Description: Light-dependent resistor used to measure light intensity.
    • Pins: pin 0, pin 1
  3. Motor and Wheels

    • Description: DC motor with attached wheels.
    • Pins: vcc, GND
  4. 12V Battery

    • Description: Power source providing 12V.
    • Pins: VCC, GND
  5. Fan Heater 12V

    • Description: 12V fan heater.
    • Pins: Ground, 12V
  6. Water Pump

    • Description: 12V water pump.
    • Pins: VCC, GND
  7. Resistor

    • Description: 1000 Ohms resistor.
    • Pins: pin1, pin2
  8. PTC

    • Description: Positive temperature coefficient thermistor.
    • Pins: Neutral, Live
  9. 12V to 5V Step Down Power Converter

    • Description: Converts 12V input to 5V output.
    • Pins: VIN 9v-36v, VIN+, VIN-, USB OUTPUT 5V, 5v OUTPUT, GND
  10. 4 Channel Relay Module

    • Description: Relay module with 4 channels.
    • 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, Pin 14, Pin 15, Pin 16, Pin 17, Pin 18, Pin 19, Pin 20, Pin 21, Pin 22, Pin 23, Pin 24, VCC+, VCC- (GND), IN 1, IN 2, IN 3, IN 4
  11. Fan 140mm

    • Description: 140mm fan.
    • Pins: 12V, GND, PWM
  12. Arduino Mega 2560

    • Description: Microcontroller board based on the ATmega2560.
    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, D21/SCL, D20/SDA, D19/RX1, D18/TX1, D17 PWM/RX2, D16 PWM/TX2, D15/RX3, D14/TX3, D0 RX0, D1 TX0, D2 PWM, D3 PWM, D4 PWM, D5 PWM, D6 PWM, D7 PWM, D8 PWM, D9 PWM, D10 PWM, D11 PWM, D12 PWM, D13 PWM, AREF, SDA, SCL, D52, D50, D48, D46, D44, D42, D40, D38, D36, D34, D32, D30, D28, D26, D24, D22, D53, D51, D49, D47, D45, D43, D41, D39, D37, D35, D33, D31, D29, D27, D25, D23

Wiring Details

DHT22

Photocell (LDR)

Motor and Wheels

12V Battery

Fan Heater 12V

Water Pump

Resistor

PTC

12V to 5V Step Down Power Converter

4 Channel Relay Module

Fan 140mm

Arduino Mega 2560

Code Documentation

#include <DHT.h>

// Define pin for the DHT sensor
#define DHTPIN 2      // Pin where the DHT sensor is connected
#define DHTTYPE DHT22 // DHT 22 (AM2302) sensor

// Define the fan control pin
#define FAN_PIN 7     // Pin to control the exhaust fan (e.g., through a relay or transistor)
#define FAN_exst 27

// Initialize the DHT sensor
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // Start the serial communication
  pinMode(FAN_exst,OUTPUT);
  Serial.begin(9600);
  
  // Initialize the DHT sensor
  dht.begin();
  
  // Set the fan control pin as an output
  pinMode(FAN_PIN, OUTPUT);
  
  // Initially, turn off the fan
  digitalWrite(FAN_PIN, LOW);
}

void loop() {
  // Wait a few seconds between readings
  delay(2000); 
  
  // Get humidity and temperature values from the DHT sensor
  float humidity = dht.read