Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO with DHT11 Temperature and Humidity Sensor

Image of Arduino UNO with DHT11 Temperature and Humidity Sensor

Circuit Documentation

Summary

This circuit is designed to measure temperature and humidity using a DHT11 sensor interfaced with an Arduino UNO. The DHT11 sensor is a digital temperature and humidity sensor that provides calibrated digital output. A resistor is used to pull up the data line for the DHT11 sensor. The Arduino UNO reads the sensor data and outputs the temperature and humidity readings to the serial monitor.

Component List

DHT11 Humidity and Temperature Sensor

  • Description: A digital sensor that measures ambient temperature and humidity.
  • Pins: VDD (Power Supply), DATA (Serial Data), NULL (No Connection), GND (Ground).

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P.
  • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5 (Analog input pins), SCL, SDA, AREF, D0-D13 (Digital pins).

Resistor

  • Description: A passive two-terminal electrical component that implements electrical resistance as a circuit element.
  • Value: 10,000 Ohms (10kΩ).

Comment

  • Description: A placeholder for additional notes or comments in the circuit design.

Wiring Details

DHT11 Humidity and Temperature Sensor

  • VDD connected to Arduino UNO 5V.
  • DATA connected to Arduino UNO Digital Pin 2 through a 10kΩ pull-up resistor.
  • GND connected to Arduino UNO GND.

Arduino UNO

  • 5V provides power to the DHT11 sensor.
  • Digital Pin 2 receives data from the DHT11 sensor.
  • GND provides a common ground reference.

Resistor (10kΩ)

  • One end connected to Arduino UNO Digital Pin 2.
  • The other end connected to DHT11 DATA pin.

Documented Code

The following code is written for the Arduino UNO to interface with the DHT11 sensor. It includes the necessary libraries and initialization for reading temperature and humidity data from the sensor and printing the results to the serial monitor.

#include "Adafruit_Sensor.h"
#include "DHT.h"
#include "DHT_U.h"

#define DHTPIN 2     // Digital pin connected to the DHT sensor
#define DHTTYPE    DHT11     // DHT 11

DHT_Unified dht(DHTPIN, DHTTYPE);

uint32_t delayMS;

void setup() {
  Serial.begin(9600);
  dht.begin();
  Serial.println(F("DHTxx Unified Sensor Example"));
  sensor_t sensor;
  dht.temperature().getSensor(&sensor);
  Serial.println(F("------------------------------------"));
  Serial.println(F("Temperature Sensor"));
  Serial.print  (F("Sensor Type: ")); Serial.println(sensor.name);
  Serial.print  (F("Driver Ver:  ")); Serial.println(sensor.version);
  Serial.print  (F("Unique ID:   ")); Serial.println(sensor.sensor_id);
  Serial.print  (F("Max Value:   ")); Serial.print(sensor.max_value); Serial.println(F("°C"));
  Serial.print  (F("Min Value:   ")); Serial.print(sensor.min_value); Serial.println(F("°C"));
  Serial.print  (F("Resolution:  ")); Serial.print(sensor.resolution); Serial.println(F("°C"));
  Serial.println(F("------------------------------------"));
  dht.humidity().getSensor(&sensor);
  Serial.println(F("Humidity Sensor"));
  Serial.print  (F("Sensor Type: ")); Serial.println(sensor.name);
  Serial.print  (F("Driver Ver:  ")); Serial.println(sensor.version);
  Serial.print  (F("Unique ID:   ")); Serial.println(sensor.sensor_id);
  Serial.print  (F("Max Value:   ")); Serial.print(sensor.max_value); Serial.println(F("%"));
  Serial.print  (F("Min Value:   ")); Serial.print(sensor.min_value); Serial.println(F("%"));
  Serial.print  (F("Resolution:  ")); Serial.print(sensor.resolution); Serial.println(F("%"));
  Serial.println(F("------------------------------------"));
  delayMS = sensor.min_delay / 1000;
}

void loop() {
  delay(delayMS);
  sensors_event_t event;
  dht.temperature().getEvent(&event);
  if (isnan(event.temperature)) {
    Serial.println(F("Error reading temperature!"));
  }
  else {
    Serial.print(F("Temperature: "));
    Serial.print(event.temperature);
    Serial.println(F("°C"));
  }
  dht.humidity().getEvent(&event);
  if (isnan(event.relative_humidity)) {
    Serial.println(F("Error reading humidity!"));
  }
  else {
    Serial.print(F("Humidity: "));
    Serial.print(event.relative_humidity);
    Serial.println(F("%"));
  }
}

This code initializes the DHT11 sensor and sets up the serial communication. In the setup() function, it prints the sensor details to the serial monitor. The loop() function reads the temperature and humidity from the sensor and prints them to the serial monitor. If there is an error reading from the sensor, an error message is printed.