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

Arduino UNO Based Temperature and Humidity Monitoring System

Image of Arduino UNO Based Temperature and Humidity Monitoring System

Circuit Documentation

Summary

This circuit integrates a DHT11 Humidity and Temperature Sensor with an Arduino UNO microcontroller. The DHT11 sensor is a digital sensor that provides ambient temperature and humidity readings. The Arduino UNO serves as the central processing unit, interfacing with the DHT11 sensor to collect data and process it. A resistor is included in the circuit to provide the necessary pull-up for the data line of the DHT11 sensor. The circuit is designed to read temperature and humidity data from the DHT11 sensor and output the readings to the serial monitor.

Component List

DHT11 Humidity and Temperature Sensor

  • Description: A digital sensor that measures ambient temperature and humidity.
  • Pins: VDD, DATA, NULL, GND

Arduino UNO

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

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 comments within the circuit design.

Wiring Details

DHT11 Humidity and Temperature Sensor

  • VDD: Connected to Arduino UNO Digital Pin 7 (D7) and one terminal of the Resistor.
  • DATA: Connected to Arduino UNO Digital Pin 2 (D2) and the other terminal of the Resistor.
  • GND: Connected to Arduino UNO Ground (GND).

Arduino UNO

  • D7: Connected to DHT11 VDD and one terminal of the Resistor.
  • D2: Connected to DHT11 DATA and the other terminal of the Resistor.
  • GND: Connected to DHT11 GND.

Resistor

  • One terminal: Connected to DHT11 VDD and Arduino UNO Digital Pin 7 (D7).
  • Other terminal: Connected to DHT11 DATA and Arduino UNO Digital Pin 2 (D2).

Documented Code

The code for the Arduino UNO microcontroller is written in C++ and is designed to interface with the DHT11 sensor using the Adafruit DHT sensor library. The code initializes the sensor, reads temperature and humidity data, and outputs the readings to the serial monitor.

Main Sketch (sketch.ino)

/**
 * This example demonstrates how to collect temperature and humidity measurements
 * from the Adafruit DHT11 sensor. Measurements are printed out to the serial monitor.
 *
 * - Make sure to first install the following libraries through the Arduino Library Manager:
 *   - DHT Sensor Library (by Adafruit)
 *   - Adafruit Unified Sensor (by Adafruit)
 * - When you open the serial monitor to view measurements from the DHT11, make sure
 * that you select 9600 baud so that the serial monitor can receive data from the Arduino.
 *
 * This example was originally written by Adafruit Industries LLC.
 */

#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN 2     // Digital pin connected to the DHT sensor 
// Feather HUZZAH ESP8266 note: use pins 3, 4, 5, 12, 13 or 14 --
// Pin 15 can work but DHT must be disconnected during program upload.

// Uncomment the type of sensor in use:
#define DHTTYPE    DHT11     // DHT 11
//#define DHTTYPE    DHT22     // DHT 22 (AM2302)
//#define DHTTYPE    DHT21     // DHT 21 (AM2301)

// See guide for details on sensor wiring and usage:
//   https://learn.adafruit.com/dht/overview

DHT_Unified dht(DHTPIN, DHTTYPE);

uint32_t delayMS;

void setup() {
  Serial.begin(9600);
  // Initialize device.
  dht.begin();
  Serial.println(F("DHTxx Unified Sensor Example"));
  // Print temperature sensor details.
  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("------------------------------------"));
  // Print humidity sensor details.
  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("------------------------------------"));
  // Set delay between sensor readings based on sensor details.
  delayMS = sensor.min_delay / 1000;
}

void loop() {
  // Delay between measurements.
  delay(delayMS);
  // Get temperature event and print its value.
  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"));
  }
  // Get humidity event and print its value.
  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("%"));
  }
}

DHT Sensor Library (DHT.h, DHT.cpp)

The DHT sensor library provides the necessary functions to interact with the DHT sensor. It includes methods for reading temperature and humidity, as well as calculating the heat index.

Adafruit Unified Sensor Library (Adafruit_Sensor.h, Adafruit_Sensor.cpp)

The Adafruit Unified Sensor library provides a common interface for various sensors to be used with the Adafruit Sensor interface. It includes definitions for sensor types, units, and sensor-specific data structures.

Additional Notes

  • The code assumes that the necessary libraries (DHT Sensor Library and Adafruit Unified Sensor) are installed.
  • The serial monitor baud rate is set to 9600.
  • The DHT sensor is connected to digital pin 2 on the Arduino UNO.
  • The DHTTYPE is defined as DHT11 to match the sensor used in the circuit.