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.
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.
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:
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:
Thermistor equation:
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).
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!