Measures the Temperature and humidity of the room.

What will I learn?

You will learn how to communicate with the DHT-11 and DHT-22 humidity and temperature sensors.


A Computer with a configured Arduino IDE tested and working. If you don’t know how to get the basic set up working, check out my guide for Getting started (1/5)

This instruction relies on the LiquidCrystal library and Adafruit Unified sensor library, so these must be installed before uploading the code to Arduino. You can download the two libraries from here:

Click the “Clone or download” button and then choose “Download zip” to download it as a zip file.

To install it, extract the two library zip files ( and to the library directory of where you installed the Arduino IDE. After this, you must restart all open Arduino IDE editors.
Now you can upload code to the Arduino utilizing the DHT library.

Important notes

  • Respect minus and plus, otherwise you may damage the components.

What you need

  • Breadboard
  • Dupont wires & connection wires
  • CP2102
  • Arduino Pro Mini
  • DHT-22 sensor (or DHT-11 if you accuracy isn’t important)

Connecting instructions

  • Arduino VCC -> DHT-22 pin 1
  • Arduino GND -> DHT-22 pin 4
  • Arduino D2 -> DHT-22 pin 2

See below for an outline of the pins for DHT-22:





* Connecting instructions:
* - Arduino VCC -> DHT22 pin 1
* - Arduino GND -> DHT22 pin 4
* - Arduino D2 -> DHT22 pin 2
* Author: Jakob Maaløe
#include <DHT.h>;

#define dhtPin 2 // The Data pin for the DHT-22
#define DHTTYPE DHT22 // We are using the DHT-22
DHT dht(dhtPin, DHTTYPE); // Initialize DHT sensor
int chk;
float humidity;
float temperature;

void setup() {


void loop() {
// Read the data and store it to variables humidity and temperature
humidity = dht.readHumidity();
temperature = dht.readTemperature();

// Print the Temperature and Humidity values to the serial monitor
Serial.print("Humidity: ");

Serial.print("%, Temp: ");

Serial.println(" Celsius");

delay(2000); // Delay for 2 seconds

Next steps

You could make it wireless or add an LCD display to show the temperature and humidity… Use the LCD display project or snail mail alarm on this page for inspiration.

Or… you can continue to the next project, the Snail-mail alarm.