DHT22 Temperature-Humidity Sensor

From Waveshare Wiki
Jump to: navigation, search

[中文]

DHT22 Temperature-Humidity Sensor
DHT22-Temperature-Humidity-Sensor

Temperature-Humidity Sensor, DHT22 Onboard
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

Primary Attribute
Category: Sensor, Moduiles, Temperature/Humidity
{{{userDefinedInfo}}}: {{{userdefinedvalue}}}
Brand: Waveshare
Website
English: Waveshare website
Chinese: 官方中文站点
Onboard Interfaces
I/Os
Related Products

Introduction

Temperature-Humidity Sensor, DHT22 Onboard

More

Working Principle

The schematic diagram is shown as below.

DHT22-Temperature-Humidity-Sensor-User-Manual-1.gif

Here are the pin definitions.

Pin Symbol Descriptions
1 VCC Power supply (3.3V-5.5V)
2 GND Ground
3 DOUT Data output, connected to the pin SDA of AM2302

The AM2302 uses the simplified single-bus technology for communication, in which only one data line is applied for data exchange and data control in the system. In applications, an external pull-up resistor, about 5.1kΩ, is usually required. When the bus is idle, its status will switch to HIGH. The SDA is used for the data communication and synchronization between the microprocessor and the AM2302. It adopts single-bus data format, 40 bits of data in one transmission, high bit first out. The corresponding timing diagram is shown as below.

DHT22-Temperature-Humidity-Sensor-User-Manual-2.gif

The AM2302 data and signal format definition is listed as below.

Name Single-bus data and signal format
Start signal The microprocessor sets the SDA to LOW for a period of time (at least 800μs) [1] to inform the sensor to prepare the data.
Response signal The sensor sets the SDA to LOW for 80μs, and then HIGH for 80μs, to respond the start signal.
Data format After received the start signal, the sensor reads out a string of data (40 bits) through SDA, High bit first out.
Humidity The humidity resolution is16 Bits, high bit first out; The value read out by the sensor is 10 times higher than the actual humidity.
Temp. The temperature resolution is16 Bits, high bit first out; The value read out by the sensor is 10 times higher than the actual temperature.

When the MSB(Bit15) is “1”, it indicates a negative temperature; When the MSB (Bit15) is “0”, it indicates a positive temperature;

The other bits (Bit14 ~ bit 0) indicate the detected temperature value.

Parity bit Parity bit = humidity high + humidity low + temperature high + temperature low
  • Single-bus communication timing

When the host (MCU) sends out a start signal (the SDA is set to LOW for at least 800μs), AM2302 will switch from the Sleep mode to the High-speed mode. After the signal is end, the AM2302 sends a response signal, and then outputs a string of 40 bits data via the SDA, high bit first; the outputted data is in the format of Humidity high, Humidity low, Temperature high, Temperature low and Parity bit. Information collection starts once the data sending is end. After the collection finished, the sensor will switch to the Sleep mode automatically, waiting for next communication. (Notes: The data format of DHT22 (AM2302) is different from that of DHT11.)

  • Example of Peripherals reading

We will present the steps for data reading in the communication between the host and the sensor.

Step 1

After the AM2302 powered up (please wait 2s for AM2302 to become stable. In this period, no command will be sent out on device reading.), the sensor tests the environment temperature and humility, and records relative data. When finished, the sensor enters the Sleep mode automatically. And the SDA data line of AM2302 is pulled up and remains HIGH as the effect of the pull-up resistor. At this moment, the pin SDA of AM2302 is in the INPUT state, detecting any possible external signal.

Step 2

The Microprocessor I/O is set to OUTPUT and outputs LOW level for more than 800us (The typical hold time is 1ms). Then, the microprocessor I/O is set to INPUT and the bus will be released. At this moment, the microprocessor I/O (the SDA data line of AM2302) goes HIGH as the effect of the pull-up resistor. After the host released the bus, AM2302 sends out a response, a LOW level of 80ms, and then outputs a HIGH level of 80ms to inform the peripheral to receive data. The signal transmission is shown as below:

DHT22-Temperature-Humidity-Sensor-User-Manual-3.gif

Step 3

After the AM2302 sending the response, the SDA outputs a string of 40 bits serial data continuously and the microprocessor receives the data according to the changes of I/O level.

Bit data "0" signal: the level is LOW for 50ms and HIGH for 26-28ms;

Bit data "1" signal: the level is LOW for 50ms and HIGH for 70ms;

The relative signal diagram is shown as below:

DHT22-Temperature-Humidity-Sensor-User-Manual-4.gif

After the SDA of AM2302 outputted the 40 bits of data, it remains LOW level for 50ms, and then switches to INPUT state and goes HIGH as the effect of the pull-up resistor. At the same time, the AM2302 internally re-tests the environmental temperature and humidity, and records the relative data. When finished, the MCU will enter the Sleep mode automatically. Only when the MCU receives the new start signal from the host, the sensor will wake up and enter the working state.

How to use

In this section, we will illustrate how to use this module with the examples of working with the development boards, Nucleo-F103RB, Arduino UNO and Open103Z. The relative operation steps and phenomena will be present in detail.

NUCLEO-F103RB

  1. Connect the pin DOUT of DHT22 to the port D2 of Nucleo-F103RB.
  2. Start the software Keil to Open the project \ mbed\Temerature-Humidity Sensor.uvproj , and then compile and download it.
  3. Open the serial monitor to select the right serial port, and make following configurations:

Baud rate: 9600; Data bit: 8; Stop bit: 1; Parity bit: None; Flow control: None.

After the settings completed, the temperature and humility data will be sent out from the serial port.

Arduino UNO

  1. Connect the pin DOUT of DHT22 to the port D2 of UNO.
  2. Copy the file folder DHTxx to the root directory of Arduino: Arduino\libraries. Click File --> Examples --> DHTxx--> DHTxx to run the cooperative program, and then compile and download it.
  3. Click Tools -> Port to choose the serial port for the Arduino development board, and then open the serial monitor to make the following configurations: No line ending, 9600 baud.

After the settings completed, the temperature and humility data will be sent out from the serial port.

Open103Z

  1. Connect the pin DOUT of DHT22 to the port PA3 of Open103Z.
  2. Start the software Keil to run the program Open103Z\MDK_Project\DHT22, and then compile and download it.
  3. Open the serial monitor to select the right serial port, and make following configurations:

Baud rate: 9600; Data bit: 8; Stop bit: 1; Parity bit: None; Flow control: None.

After the settings completed, the temperature and humility data will be sent out from the serial port.

Resources

Software

FAQ

Question:
What other choices do I have?
Answer:
Perhaps you'd like:

Color Sensor

Color-Sensor
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}

Flame Sensor

Flame-Sensor
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}

Hall Sensor

Hall-Sensor
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}

Infrared Reflective Sensor

Infrared-Reflective-Sensor-1
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}

Laser Sensor

Laser-Sensor
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}

Liquid Level Sensor

Liquid-Level-Sensor
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}

Moisture Sensor

Moisture-Sensor
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}

MQ5 Gas Sensor

MQ-5-Gas-Sensor
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}

Rotation Sensor

Rotation-Sensor
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}

Sound Sensor

Sound-Sensor
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}

DHT11 Temperature-Humidity Sensor

Temperature-Humidity-Sensor
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}

Tilt Sensor

Tilt-Sensor-1
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}

UV Sensor

UV-Sensor
{{{2}}}
{{{3}}}
{{{4}}}
{{{5}}}
{{{6}}}
{{{7}}}
{{{8}}}
{{{9}}}
{{{10}}}
{{{11}}}
{{{12}}}
{{{13}}}
{{{14}}}
{{{15}}}
{{{16}}}
{{{17}}}
{{{18}}}
{{{19}}}
{{{20}}}
{{{21}}}
{{{22}}}
{{{23}}}
{{{24}}}
{{{25}}}
{{{26}}}
{{{27}}}
{{{28}}}
{{{29}}}
{{{30}}}
{{{31}}}
{{{32}}}
{{{33}}}
{{{34}}}
{{{35}}}
{{{36}}}
{{{37}}}
{{{38}}}
{{{39}}}
{{{40}}}
{{{41}}}
{{{42}}}
{{{43}}}
{{{44}}}
{{{45}}}
{{{46}}}
{{{47}}}
{{{48}}}
{{{49}}}
{{{50}}}


Support

Mail.png Contact your seller (fast response and most recommended)

or send emails to service@waveshare.com (not fast enough but please be patient) for help.

Our working time: 09:00-18:00 (UTC+8 Monday to Saturday)