Measure Temperature and Humidity Using DHT22

By Emir

In this tutorial you will learn how to measure ambient temperature and humidity using Arduino board together with DHT22 sensor.

Arduino is a very popular electronic board and DHT22 is a cheap and accurate sensor for measuring temperature and humidity.

Step 1

Bill of materials

What you need:

Step 2

Connect wires

Connect three female pins with DHT22 male pins: 1 - gray, 2 - white and 4 - black (as shown in the picture).

Note: Wire coloring is not important, it is used for easier reference.

show more
Step 3

Add resistor

Add resistor between Vcc and Data pins (1 - gray and 2 - white).

show more
Step 4

Connect wires with Arduino

Connect wires from DHT22 to Arduino pins.

  • 1 - gray to 5V on Arduino;
  • 2 - white to any digital pin (2 to 13 or A0 to A5) on Arduino;
  • 4 - black to ground on Arduino.
show more
Step 5

Download and install library

To use DHT22 you need appropriate library to read sensor data.

Download one here.

Install the library (follow instructions in Read-me file).

Open Arduino IDE and check that it's in a new library added to "File"->"Sketchbook"->"libraries"->"DHT22".

Step 7

Modify code

In example code digital pin 2 is used for Data signal.

Modify code line 6, replace number "2" with the number of pin you are using on your Arduino board for sensor data pin. In our case it is pin "6".

show more
Step 8

Connect Arduino

Connect Arduino with your computer using USB.

Step 9

Upload Code to Arduino

Select "Tools"->"Board"->[Arduino board]. In our case it is Arduino Uno.

Then select "Tools"->"Serial port"->[Your serial port used for communication with Arduino]. In our case it is /dev/tty.usbmodem1411.

Click on "File"->"Upload" to upload code to Arduino.

Step 10

Read data in Serial Monitor

After upload is done successfully, open Serial Monitor to read data from Arduino on your screen.

Serial Monitor is located in Tools menu of Arduino IDE.

Tutorial Forum

There are no posts here yet. Add the first post