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

Arduino UNO and DHT11 Temperature and Humidity Sensor

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

Circuit Documentation

Summary

This circuit involves an Arduino UNO microcontroller interfaced with a DHT11 temperature and humidity sensor. The Arduino UNO reads data from the DHT11 sensor and outputs the temperature and humidity readings via the serial monitor.

Component List

Arduino UNO

DHT11

Wiring Details

Arduino UNO

DHT11

Code Documentation

Arduino UNO Code

#include "DHT.h"

DHT dht11(4, DHT11);

void setup() {
  Serial.begin(9600);
  dht11.begin();
  pinMode(4, INPUT);
}

void loop() {
  delay(6000);
  float hum = dht11.readHumidity();
  float tempc = dht11.readTemperature();
  float tempf = dht11.readTemperature(true);

  if (isnan(hum) || isnan(tempc) || isnan(tempf)) {
    Serial.println("Can't read from dht11 sensor");
  } else {
    Serial.print("Humidity: ");
    Serial.print(hum);
    Serial.println("%");
    Serial.print("Temperature: ");
    Serial.print(tempc);
    Serial.println("deg.C");
    Serial.print(tempf);
    Serial.println("deg.F");
  }
}

This code initializes the DHT11 sensor on pin D4 of the Arduino UNO. It reads the humidity and temperature (in both Celsius and Fahrenheit) every 6 seconds and prints the values to the serial monitor. If the sensor readings are not available, it outputs an error message.