book collections email follower instructable user

Step 3: DHT22 Humidity Sensor

Picture of DHT22 Humidity Sensor

Learning objectives

  • To measure humidity.
  • To analyze how temperature affects evaporation.

The DHT22 temperature and humidity sensor is a device that contains a thermistor to measure temperature and a capacitive sensor to measure humidity. It also includes a chip with the necessary information to calibrate the sensor, making it very easy to read temperature and humidity with a microcontroller like Arduino.


Connecting the sensor

Although the DHT22 sensor has four pins, we'll use the version that comes mounted in a module. This way we'll avoid the use of an external resistor, and the number of pins is reduced to three.

Connect the pins in the module to the Arduino board as follows:

  • DAT or OUT (data): any digital pin in Arduino
  • VCC or + (positive power): +5V
  • GND or – (negative power): GND

Reading the sensor

To read this sensor, we must first add a library to the Arduino IDE. The library we'll use to read the DHT22 sensor is called SimpleDHT. You can download it from this link:

Once the library is added, you can try an example program to check that the sensor is working correctly. Go to File > Examples, and open the DHT22Default sketch in the SimpleDHT examples. Have a look at the code of this example. In the setup, the serial communication is initialized at a rate of 115200 bauds, so you'll probably have to adjust this value in the serial monitor (or, if you prefer, just change this number in the sketch). You must as well take into account that this sketch assumes that the sensor is connected to digital pin 2. One last important thing worth mentioning about this sensor is that, according to the datasheet, its sampling rate is 0,5 Hz, meaning that you can only take new data every 2 seconds.

Now upload the example sketch and open the serial monitor to read the values of humidity and temperature.

Activities for students

Take one container and fill it with cold water. Put the humidity sensor close to the surface of the water, and record how the humidity has changed after one minute. Now take an identical container and fill it with the same amount of water, but this time with warm water. Measure the change in humidity in the same amount of time. Compare both values and extract a conclusion.