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

Arduino UNO and DHT11 Sensor-Based Temperature and Humidity Monitor

View and Edit Project In Cirkit DesignerImage of Arduino UNO and DHT11 Sensor-Based Temperature and Humidity Monitor

Circuit Documentation

Summary

This circuit involves an Arduino UNO microcontroller interfaced with a DHT11 temperature and humidity sensor. The Arduino reads temperature and humidity data from the DHT11 sensor and sends the data to a serial monitor for display.

Component List

DHT11 Sensor

Arduino UNO

Wiring Details

DHT11 Sensor

Arduino UNO

Code Documentation

/*
 * This Arduino Sketch reads temperature and humidity data from a DHT11 sensor
 * connected to pin A0 of an Arduino UNO. The data is then sent to the serial
 * monitor on a PC for display.
 */

#include <DHT.h>

#define DHTPIN A0     // Pin where the DHT11 is connected
#define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600); // Initialize serial communication
  dht.begin();        // Initialize the DHT sensor
}

void loop() {
  // Wait a few seconds between measurements
  delay(2000);

  // Reading temperature or humidity takes about 250 milliseconds!
  float h = dht.readHumidity();    // Read humidity
  float t = dht.readTemperature(); // Read temperature in Celsius

  // 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");
}

This code initializes the DHT11 sensor and reads the temperature and humidity data every 2 seconds. The data is then printed to the serial monitor. If the sensor fails to read data, an error message is displayed.