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

ESP32-Based Smart Temperature and Humidity Monitor with LED and Buzzer Alerts

View and Edit Project In Cirkit DesignerImage of ESP32-Based Smart Temperature and Humidity Monitor with LED and Buzzer Alerts

Circuit Documentation

Summary

This circuit is designed to monitor temperature and humidity using a DHT11 sensor and an ESP32 microcontroller. It includes visual and auditory alerts using LEDs and a piezo buzzer. The circuit reads temperature and humidity data from the DHT11 sensor and triggers the LEDs and buzzer based on predefined thresholds.

Component List

  1. DHT11 Humidity and Temperature Sensor

    • Description: Measures temperature and humidity.
    • Pins: VDD, DATA, NULL, GND
  2. ESP32 (30 pin)

    • Description: Microcontroller used to process sensor data and control outputs.
    • 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
  3. LED: Two Pin (red)

    • Description: Red LED used for visual alerts.
    • Pins: cathode, anode
  4. Piezo Buzzer

    • Description: Buzzer used for auditory alerts.
    • Pins: negative pin, positive pin
  5. LED: Two Pin (blue)

    • Description: Blue LED used for visual alerts.
    • Pins: cathode, anode

Wiring Details

DHT11 Humidity and Temperature Sensor

ESP32 (30 pin)

LED: Two Pin (red)

Piezo Buzzer

LED: Two Pin (blue)

Code Documentation

#include <DHT.h>

#define DHTPIN 5 // Pin where the DHT11 data pin is connected
#define DHTTYPE DHT11
const int tempLedPin = 14; // LED pin for Temperature
const int humidityLedPin = 2; // LED pin for Humidity
const int buzzerPin = 4; // Buzzer pin
const float HUMIDITY_HIGH_THRESHOLD = 85.0; // High humidity threshold
const float HUMIDITY_LOW_THRESHOLD = 65.0; // Low humidity threshold
const float TEMP_HIGH_THRESHOLD = 20.0; // High temperature threshold
const float TEMP_LOW_THRESHOLD = 18.0; // Low temperature threshold

DHT dht(DHTPIN, DHTTYPE);

void setup() {
    Serial.begin(115200);
    dht.begin();
    pinMode(tempLedPin, OUTPUT);
    pinMode(humidityLedPin, OUTPUT);
    pinMode(buzzerPin, OUTPUT);
}

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

    if (humidity > HUMIDITY_HIGH_THRESHOLD || humidity < HUMIDITY_LOW_THRESHOLD) {
        digitalWrite(humidityLedPin, HIGH);
        tone(buzzerPin, 3000);
    } else {
        digitalWrite(humidityLedPin, LOW);
        noTone(buzzerPin);
    }

    if (temperatureC > TEMP_HIGH_THRESHOLD || temperatureC < TEMP_LOW_THRESHOLD) {
        digitalWrite(tempLedPin, HIGH);
        tone(buzzerPin, 3000);
    } else {
        digitalWrite(tempLedPin, LOW);
        noTone(buzzerPin);
    }

    Serial.print("Temperature (°C): ");
    Serial.print(temperatureC);
    Serial.print(" , Humidity (RH %): ");
    Serial.println(humidity);
    delay(30000); // Wait for 30 seconds
}

This code initializes the DHT11 sensor and sets up the pins for the LEDs and buzzer. In the loop function, it reads the temperature and humidity values and triggers the LEDs and buzzer if the values exceed the predefined thresholds. The data is also printed to the serial monitor every 30 seconds.