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

Raspberry Pi 5 and DHT11 Sensor-Based Temperature and Humidity Monitoring with LED Indicator

View and Edit Project In Cirkit DesignerImage of Raspberry Pi 5 and DHT11 Sensor-Based Temperature and Humidity Monitoring with LED Indicator

Circuit Documentation

Summary of the Circuit

This circuit integrates a Raspberry Pi 5 with a DHT11 Humidity and Temperature Sensor and a red two-pin LED. The Raspberry Pi 5 serves as the central processing unit, interfacing with the DHT11 sensor to read environmental data and controlling the LED to blink at regular intervals. The DHT11 sensor is powered by the Raspberry Pi and communicates data back to it via a GPIO pin. The LED is directly driven by another GPIO pin on the Raspberry Pi and is used to indicate the operational status of the circuit.

Component List

Raspberry Pi 5

DHT11 Humidity and Temperature Sensor

LED: Two Pin (red)

Wiring Details

Raspberry Pi 5

DHT11 Humidity and Temperature Sensor

LED: Two Pin (red)

Documented Code

/*
 * This Arduino Sketch interfaces a DHT11 sensor and an LED with a Raspberry Pi.
 * The DHT11 sensor reads temperature and humidity data, which can be sent to
 * the Raspberry Pi via GPIO 18. The LED connected to GPIO 14 will blink at a
 * regular interval.
 */

#include <DHT.h>

#define DHTPIN 18 // GPIO 18 for DHT11 data pin
#define DHTTYPE DHT11 // DHT 11
#define LEDPIN 14 // GPIO 14 for LED

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  pinMode(LEDPIN, OUTPUT); // Initialize the LED pin as an output
  dht.begin(); // Initialize the DHT11 sensor
  Serial.begin(9600); // Initialize serial communication
}

void loop() {
  // Blink the LED
  digitalWrite(LEDPIN, HIGH); // Turn the LED on
  delay(1000); // Wait for a second
  digitalWrite(LEDPIN, LOW); // Turn the LED off
  delay(1000); // Wait for a second

  // Read temperature and humidity from DHT11
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Print the results to the Serial Monitor
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println(" *C");
}

Note: The code provided is intended for an Arduino environment, which is not directly compatible with the Raspberry Pi. However, the logic and functionality can be adapted to the Raspberry Pi using a suitable programming language such as Python with the appropriate libraries for GPIO access and DHT11 sensor communication.