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

ESP32-Based Temperature-Activated LED with DHT11 Sensor

View and Edit Project In Cirkit DesignerImage of ESP32-Based Temperature-Activated LED with DHT11 Sensor

Circuit Documentation

Summary

This circuit involves an ESP32 microcontroller, a DHT11 temperature and humidity sensor, a red LED, and a 220 Ohm resistor. The ESP32 reads temperature data from the DHT11 sensor and controls the LED based on the temperature readings. If the temperature exceeds 30°C, the LED is turned on; otherwise, it remains off.

Component List

ESP32

LED: Two Pin (red)

DHT11

Resistor

Wiring Details

ESP32

LED: Two Pin (red)

DHT11

Resistor

Code Documentation

ESP32 Code

#include <DHT.h>

#define DHTPIN 4       // DHT22 sensor pin
#define DHTTYPE DHT11  // DHT11 sensor type
#define LEDPIN 26      // LED pin

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  pinMode(LEDPIN, OUTPUT);
  digitalWrite(LEDPIN, LOW);
  dht.begin();
}

void loop() {
  float temperature = dht.readTemperature();
  if (isnan(temperature)) {
    Serial.println("Error reading temperature!");
    return;
  }

  if (temperature >= 30.0) {
    digitalWrite(LEDPIN, HIGH);
  } else {
    digitalWrite(LEDPIN, LOW);
  }

  delay(1000); // Delay 1 second
}

DHT11 Code

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

This documentation provides a comprehensive overview of the circuit, including a summary, detailed component descriptions, wiring details, and the embedded code for the microcontrollers.