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

ESP32-Based Smart Environmental Monitoring System with Wi-Fi Connectivity

View and Edit Project In Cirkit DesignerImage of ESP32-Based Smart Environmental Monitoring System with Wi-Fi Connectivity

Circuit Documentation

Summary

This document provides a detailed overview of an IoT project using an ESP32 microcontroller. The circuit integrates various sensors and actuators to monitor environmental conditions and respond accordingly. The sensors include a DS18B20 temperature sensor, a sound sensor, a DHT22 humidity and temperature sensor, an MQ135 gas sensor, and an LDR light sensor. The actuators include a fan, a buzzer, an LED, a humidifier, a heater element, and an LCD display. The ESP32 reads data from the sensors and controls the actuators based on the sensor readings.

Component List

  1. ESP32 (30 pin)

    • Description: Microcontroller with Wi-Fi and Bluetooth capabilities.
    • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3
  2. DS18B20 Temperature Sensor

    • Description: Digital temperature sensor.
    • Pins: GND, VCC, OUT
  3. Sound Sensor

    • Description: Sensor to detect sound levels.
    • Pins: 5V +, OUT, GND
  4. DHT22

    • Description: Humidity and temperature sensor.
    • Pins: +, Out, -
  5. Module LDR

    • Description: Light-dependent resistor module.
    • Pins: VCC, GND, DO, AO
  6. Fan

    • Description: Cooling fan.
    • Pins: GND, 5V
  7. Heater Element

    • Description: Heating element.
    • Pins: VCC, GND
  8. Buzzer

    • Description: Sound-producing device.
    • Pins: GND, IN
  9. LED: Two Pin (red)

    • Description: Red LED.
    • Pins: cathode, anode
  10. LCD Display (16 pin)

    • Description: 16x2 character LCD display.
    • Pins: VSS, VDD, VO, RS, R_W, E, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7, A, K
  11. MQ 135

    • Description: Gas sensor.
    • Pins: D OUT, A OUT, GND, VCC
  12. Humidifier

    • Description: Device to add moisture to the air.
    • Pins: GND, 5V

Wiring Details

ESP32 (30 pin)

DS18B20 Temperature Sensor

Sound Sensor

DHT22

Module LDR

Fan

Heater Element

Buzzer

LED: Two Pin (red)

LCD Display (16 pin)

MQ 135

Humidifier

Code Documentation

/*
 * EAS IOT Project
 * This code initializes and reads data from various sensors connected to the
 * ESP32 microcontroller and controls actuators based on sensor readings.
 * Sensors: DS18B20 Temperature Sensor, Sound Sensor, DHT22, MQ 135, LDR
 * Actuators: Fan, Buzzer, LED, Humidifier, Heater Element, LCD Display
 */

#include <OneWire.h>
#include <DallasTemperature.h>
#include <DHT.h>
#include <LiquidCrystal.h>

// Pin Definitions
#define SOUND_SENSOR_PIN 34
#define BUZZER_PIN 25
#define LED_PIN 23
#define DHT_PIN 21
#define MQ135_DIGITAL_PIN 19
#define LDR_DIGITAL_PIN 32
#define DS18B20_PIN 22

// DHT Sensor
#define DHTTYPE DHT22
DHT dht(DHT_PIN, DHTTYPE);

// DS18B20 Sensor
OneWire oneWire(DS18B20_PIN);
DallasTemperature sensors(&oneWire);

// LCD Display
LiquidCrystal lcd(14, 12, 27, 26, 25, 33);

void setup() {
  // Initialize Serial Monitor
  Serial.begin(115200);

  // Initialize Sensors
  dht.begin();
  sensors.begin();

  // Initialize Actuators
  pinMode(BUZZER_PIN, OUTPUT);
  pinMode(LED_PIN, OUTPUT);

  // Initialize LCD
  lcd.begin(16, 2);
  lcd.print("EAS IOT Project");
}

void loop() {
  // Read Sound Sensor
  int soundValue = digitalRead(SOUND_SENSOR_PIN);
  Serial.print("Sound: ");
  Serial.println(soundValue);

  // Read DHT22 Sensor
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println(" *C");

  // Read DS18B20 Sensor
  sensors.requestTemperatures();
  float tempC = sensors.getTempCByIndex(0);
  Serial.print("DS18B20 Temperature: ");
  Serial.print(tempC);
  Serial.println(" *C");

  // Read MQ135