element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Experimenting with Waterproof Connectors
  • Challenges & Projects
  • Design Challenges
  • Experimenting with Waterproof Connectors
  • More
  • Cancel
Experimenting with Waterproof Connectors
Blog E.W.C Blog 3 - Using the DHT22
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Experimenting with Waterproof Connectors to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: me_Cris
  • Date Created: 20 May 2023 5:25 PM Date Created
  • Views 409 views
  • Likes 7 likes
  • Comments 0 comments
  • experimenting with Waterproof Connectors
Related
Recommended

E.W.C Blog 3 - Using the DHT22

me_Cris
me_Cris
20 May 2023

Hello everyone!

In this blog I would like to talk more about the DHT22 module, make a comparison with the DHT11, and present the way I used the sensor with my board.

I gathered a lot of information by consulting google. Grinning

DHTxx is a sensor that measures two physical aspects of the environment, temperature and humidity. The water content present in the air is called humidity. The gaseous state of water is called vapor. As the air temperature rises, more water vapor can be generated. The sensor calculates the relative humidity using capacitive measurements. In addition, it can measure the temperature in the environment using a thermistor as a temperature sensor. It is available in two variants, one with three pins and the other with four pins, but one remains unconnected. It is recommended to use a pull-up resistor from 5k...10k ohms for the communication between the sensor and the microcontroller.

The DHTxx sensor series contains two versions. They look a bit similar and have the same pin configuration, but they have different characteristics, shown in the following table:

Comparison parameter DHT11 DHT22
Operating voltage 3-5V 3-5V
Maximum absorbed current 2.5mA 2.5mA
Humidity range 20-80% / 5% 0-100% / 2-5%
Temperature range 0-50°C / ±2°C -40...80°C / ±0.5°C
Sampling rate 1 Hz (reading per second) 0.5 Hz (reading every 2 seconds)
Physical dimensions 15.5x12x5.5 mm 15.1x25x7.7 mm

DHT22 is the more expensive version, but which obviously has better specifications. The temperature measurement range is from -40°C to +125°C with an accuracy of ±0.5 degrees, while the temperature range of the DHT11 is from 0°C to 50°C with an accuracy of ±2 degrees. Also, the DHT22 sensor has a better humidity measurement range, from 0 to 100% with an accuracy of 2-5%, while the DHT11 humidity range is from 20 to 80% with an accuracy of 5% .

Although the DHT22 is more accurate and operates over a wider temperature and humidity range; there are three things the DHT11 is better at than the DHT22: it is less expensive, smaller in size, and has a higher sample rate. The sampling rate of the DHT11 is 1 Hz, i.e. one reading every second, while the sampling rate of the DHT22 is 0.5 Hz, i.e. one reading every two seconds. However, the operating voltage of both sensors is 3 to 5 volts, while the maximum current used during conversion (while requesting data) is 2.5 mA.

image

Sensor DHT22 a); DHT11 b)

Inside the case, on the sensing side, there is a humidity sensing component along with an NTC temperature sensor or thermistor. The moisture sensing component is obviously used to measure humidity, and is composed of two electrodes with a moisture-retaining substrate (usually salt or a polymer of conductive material) between them. Ions are released from the substrate as water vapor is absorbed by it, which in turn increases the conductivity between the electrodes. The change in resistance between the two electrodes is proportional to the relative humidity. Higher relative humidity decreases the resistance between the electrodes, while lower relative humidity increases the resistance between the electrodes.

The formula for calculating relative humidity is:

RH = (ρw/ρs) * 100; where ρw is the vapor density and ρs is the saturation vapor density.


Relative humidity is expressed as a percentage. At 100% RH, condensation occurs, and at 0% RH, the air is completely dry. 

Internal structure of the humidity sensor:

image

To measure the temperature a temperature sensor / NTC thermistor. A thermistor is a thermal resistor - a resistor that changes its resistance as temperature changes. Technically, all resistors are thermistors - their resistance changes slightly with temperature - but the change is usually very small and difficult to measure. Thermistors are made so that the resistance changes drastically with temperature, with a change of 100 ohms or more per degree The term "NTC" stands for "Negative Temperature Coefficient", meaning that the resistance decreases with increasing temperature.

Dependence of thermistor resistance on temperature:

image

Thermistor equation:

image where T1 is the first temperature value measured in Kelvin; T2 is the second temperature value measured in Kelvin; R1 is the resistance of the terminus at temperature T1; R2 is the resistance of the thermistor at temperature T2.

On the other side of the module is a small integrated circuit that measures and processes the analog signal with the built-in calibration coefficients, performs the analog-to-digital conversion and outputs a digital signal with the temperature and humidity read. 

This sensor is used in various applications such as: measuring humidity and temperature in heating, ventilation and air conditioning systems, weather stations also use these sensors to predict weather conditions, etc.

The compact size and sample rate have made this sensor popular with hobbyists. Some of the sensors that can be used as an alternative to the DHT11 sensor are DHT22, AM2302, SHT71.

Previously, I used DHT22 with an Arduino board, when I received the kit for this challenge, I made the necessary adaptations for LattePanda.
As the DHT22 module has only three pins, two of which are for power and one for data, the connections with the Arduino board are few. Basically, what we can change is only the pin to which we connected the DHT22 (digital pin).

image


The sketch I started from looks like this:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

#include "DHT.h"
#define DHTPIN 4 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);

byte degree[8] = {
0B00111,
0B00101,
0B00111,
0B00000,
0B00000,
0B00000,
0B00000,
0B00000
};

void setup() {
Serial.begin(9600);
lcd.init();
lcd.clear();
lcd.backlight();
lcd.createChar(0, degree); // create "°" symbol
dht.begin();

}
void loop() {

// Read temperature and humidity
float h = dht.readHumidity();
float t = dht.readTemperature();

// display temperature
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.setCursor(7, 0);
lcd.print(t);
lcd.setCursor(13, 0);
lcd.write((byte)0);
lcd.setCursor(14, 0);
lcd.print("C");

// display humidity
lcd.setCursor(0, 1);
lcd.print("Umid: ");
lcd.setCursor(7, 1);
lcd.print(h);
lcd.setCursor(13, 1);
lcd.print("%");

delay(100);

} // end void loop

I also added a 16x2 LCD with I2C interface. The components could also be seen in the previous blog posted by me.

Another blog with a soil moisture sensor is coming.
Thank you. Have a nice day!

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube