Maker.io main logo

RHT03 (DHT22) Humidity and Temperature Sensor Hookup Guide

2019-06-25 | By SparkFun Electronics

License: See Original Project

Courtesy of SparkFun

Introduction

Measure relative humidity and temperature with the RHT03 (a.k.a DHT22) low cost sensor on a single wire digital interface connected to an Arduino!

Humidity and Temperature Sensor - RHT03

Required Materials

To follow along with this tutorial, you will need the following materials. You may not need everything though depending on what you have.

RHT03 (DHT22) Humidity and Temperature Sensor Hookup Guide Wish List SparkFun Wish List

Suggested Reading

If you aren’t familiar with the following concepts, we recommend checking out these tutorials before continuing.

  • Installing an Arduino Library: How do I install a custom Arduino library? It's easy! This tutorial will go over how to install an Arduino library using the Arduino Library Manager. For libraries not linked with the Arduino IDE, we will also go over manually installing an Arduino library.
  • What is an Arduino? What is this 'Arduino' thing anyway?
  • Installing Arduino IDE: A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.
  • How to Install FTDI Drivers: How to install drivers for the FTDI Basic on Windows, Mac OS X, and Linux.

Hardware Overview

Pinout

The pins of the RHT03 (DHT22) are labeled in the image below.

1_Pinout

 

2_Table1

Hardware Hookup

Heads up! The sensor's pins are small. For a more secure connection, you may want to think about eventually soldering this to a protoboard after prototyping.

Connect the RHT03 to your Arduino as shown below. Since we are using a 5V Arduino, we will be using 5V to power the sensor. If you are using a 3.3V Arduino, you will need to connect it to a 3.3V pin for your respective development board.

3_Connect-the-RHT03

Note: A 10k pull-up resistor can be added to the data pin, though it seems to work without it. If you really need, you can still add a pull-up resistor between VCC and the data pin.

4_Connect-the-RHT03_2

Head's Up! The Fritzing part for the RHT03 (DHT22) can be found in the Fritzing software! Simply type RHT03 in the parts search.

Library Installation

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

We’ve written an Arduino library to make reading the RHT03 a breeze. You will need to manually install the RHT03 Arduino library from the GitHub repository by downloading a *.zip. Once downloaded, click Sketch > Include Library > Add .ZIP Library... to have the Arduino IDE unzip the library into it's respective folder.

SPARKFUN RHT03 ARDUINO LIBRARY (ZIP)

Arduino Example

After installing the library, open the example from the Arduino IDE by clicking File > Examples > SparkFun RHT03 Arduino Library > RHT03-Example-Serial. Select the board that you are using (if you are using the RedBoard with the ATmega328P, select Arduino/Genuino Uno) and COM port that the board enumerated on and hit upload.

5_Arduino-Example

Open the serial monitor at 9600 baud to view the output. You should see the relative humidity and temperature in °F and °C. Try blowing some air at the sensor. The sensor should react to the water vapor contained in the exhaled air.

6_Output

Heads up! You'll want to be patient as your Arduino reads the sensor. The example code checks to see if we receive a valid output from the sensor. If we receive a valid reading, the values will update respectively. If you check the datasheet, the sensor's output is typically is 2 seconds.

More Examples

Looking for more examples? Check out the following tutorials to read the sensor with other development boards!

ESP8266

If you are using the ESP8266 with the RHT03 (DHT22), try checking out experiment 1 of the Internet of Things Experiment Guide to capture temperature and humidity data from a sensor and post it to our ThingSpeak channel.

7_ESP8266-Thing-Example

Particle Photon

If you are using the Particle Photon with the RHT03 (DHT22), try checking out experiment 6 of the SparkFun Inventor's Kit for Photon Experiment Guide to read the serial data with a photocell.

8_Particle-Photon-Example

Resources & Going Further

Now that you've successfully got your RHT03 up and running, it's time to incorporate it into your own project! For more information, check out the resources below:

制造商零件编号 SEN-10167
SENSOR HUMID/TEMP 5V DTL 2% MOD
SparkFun Electronics
制造商零件编号 DEV-13975
REDBOARD ATMEGA328 EVAL BRD
SparkFun Electronics
制造商零件编号 CAB-11301
CBL USB2.0 A PLUG-MIN B PLUG 6'
SparkFun Electronics
制造商零件编号 PRT-08431
JUMPER WIRE M/M 6" 10PCS
SparkFun Electronics
制造商零件编号 PRT-12043
BREADBOARD TERM STRIP 1.85X1.38"
SparkFun Electronics
制造商零件编号 PRT-12702
BREADBOARD GENERAL PURPOSE PTH
SparkFun Electronics
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum