Difference Between DHT11, DHT12 and DHT22 Temperature & Humidity Sensor, Internal Look of DHT11, DHT12 and DHT22, DHT11 Vs DHT22/AM2302 Vs DHT12, DHT22 Pinout, DHT11 Pinout, DHT12 Pinout, DHT12 Sensor I2C Communication protocol

Many people have doubts regarding which sensor to use and what is the difference between these temperature sensors, so from this blog you will be clear about the difference between DHT11, DHT12, DHT22.

DHT11 Temperature and Humidity Sensor

DHT11 Temperature and Humidity Sensor, DHT11, DHT11 pinout, Serial Communications of DHT11

The DHT11 module is a temperature and humidity sensing module that uses Digital Signal Acquisition to translate temperature and humidity to a digital reading that a microcontroller can easily read. It makes use of specific digital module capture technology as well as temperature and humidity sensor technology to provide high dependability and long-term stability in its products. A resistive element and a sense of moist NTC temperature measuring devices are included in the sensor, which is coupled to a high-performance 8-bit microprocessor.

DHT11 Pinout:

No: 

Pin Name

Description

1

Vcc

Power supply 3.3V to 5.5V

2

Data

Temperature and Humidity are both outputs through serial data

3


NC

No Connection(not used)

4

Ground

Connected to the ground of the circuit



Serial Communications Description (single-wire bidirectional)

The DHT11 device operates using a single bus. A single bus is complete when just one data line, the data exchange system, is managed by it. A device (master or slave) is linked to the data line via an open-drain or tri-state port to allow the device to send data when it is unable to release the bus and allow other devices to use it; a single bus usually uses an external approximately 5.1k pull up resistor, so that the state is high when the bus is idle. Because they are master-slave structures, only the host may call a slave, and only the slave can reply, the host access devices must precisely follow the sequence of a single bus; otherwise, the device will not react to the host.

The data from the DHT11 sensor is 40 bits in length and is formatted as follows:

8-bit data for integral RH value, 8-bit data for decimal RH value, 8-bit data for integral Temperature value, 8-bit data for decimal Temperature value,  and 8-bit data for checksum.

Consider the data received from the DHT11 Sensor is 

00100101 00000000 00011001 00000000 00111110.

This data can be separated based on the above mentioned structure as follows:

00100101

0000000

00011001

00000000

00111110

High Humidity

Low Humidity

High Temperature

Low Temperature

Checksum (Parity)

 

In order to check whether the received data is correct or not, we must perform a small calculation. Check if the sum of the integral and decimal values of RH and Temperature equals the checksum value, i.e. the last 8-bit data.

00100101 + 00000000 + 00011001 + 00000000 = 00111110

This value is the same as the checksum, indicating that the data obtained is right. Simply convert the binary data to decimal data to obtain the RH and Temperature values.

  • RH = Decimal of 00100101 = 37%
  • Temperature = Decimal of 00011001 = 25°C

Initially Arduino sends a high to low start signal to DHT11 with 18µs delay to ensure DHT’s detection. The Arduino then pulls up the data line and waits 20-40µs for DHT to respond. When DHT detects a start signal, it sends a low voltage level response signal to the Arduino with an 80µs delay. The DHT controller then pulls up the data line and holds it for 80µs for DHT’s arrangement of sending data.

When the data bus voltage is low, the DHT11 is sending a response signal. After that, DHT performs another data line pull-up for 80µs to prepare data transmission.

Data format that is sent by DHT to the Arduino for every bit starts with 50µs low voltage level and length of high voltage level signal decides whether a data bit is 0 or 1.

 

DHT12

DHT12 Temperature and Humidity Sensor, DHT12, DHT12 pinout, Serial Communications of DHT12

The DHT12 Digital Temperature and Humidity Sensor are with a calibrated digital output record. High reliability and long-term stability are ensured by application-specific digital temperature and humidity sensor modules and semiconductors. DHT12 With a single bus, and standards I2C Two kinds of communication and single bus communication mode is fully compatible with DHT11. System integration is easy and rapid because of the standard bus interface. With its ultra-compact size and low power consumption, it's ideal for a variety of applications. I2C Communication follows a defined communication sequence, allowing the user to communicate with the bus directly without the need for extra wiring. Users have the freedom to pick, it's simple to use, and it should cover a wide range of applications. Products for the 4 Lead, easy connection, and unique packages matched to the demands of the user.

 

DHT12 Pinout:

No:

Pin Name

Description

1

VDD

Power supply (2.7V-5.5V)

2

SDA

Serial data, bi-directional

3

Ground

Connected to the ground of the circuit

4

SCL

Serial clock input(Single bus grounding)

 

Serial clock input (SCL)-The SCL pins are used to choose the communication method and the I2C communication clock line.

Serial data (SDA)-SDA PIN for a three-State structure, used for reading and writing data.

 

DHT12 Sensor I2C Communication protocol

DHT12 Support I2C Way to communicate, in full accordance with I2C Standard protocol prepared, can be linked directly in I2C Bus sensor SDA PIN I2C Databus, SCL I2C Clock bus, customers need to both pin a 1KΩ~10KΩPull-up resistor. I2C Address for 0xB8(DEV SEL); I2C The communication rate cannot be higher than 400KHZ。

 

The data from the DHT12 sensor is 40 bits in length and is formatted as follows:

 Single bus data example: 

The name

Single bus format definition

The starting signal 

Host data bus (SDA) Down over time (18ms), Tells sensors to prepare data

The corresponding signal 

Sensor data bus (SDA), Lower 80µs And higher 80µs In response to host the starting signal 

Data format 

Receives a host after the starting signal, sensors at once from the data bus (SDA) 40 Data, high

Humidity 

Humidity high - humidity integer data, humidity low -humidity decimal data.

Temperature 

Temperature high-temperature integer data, temperature low- temperature decimal data, and low-temperature Bit8,  1 The negative temperature, otherwise positive temperature.

Check digit 

Check digit=Humidity high+ Humidity is low+ Temperature highs+ Low temperature

 

 Example: receiving 40 Data for: 00111000 00001000 00011010 00000110 01100000 Humidity integral digits Humidity scale Temperature integer bit Temperature scale Check digit 00111000+00001000+00011010+00000110=01100000(Check digit) receive data properly: Humidity:00111000 (Binary) =>56 (Decimal)00001000(Binary)=>8 (Decimal) =>Humidity=56.8%RH Temperature:00011010 (Binary) =>26 (Decimal)00000110(Binary)=>6 (Decimal) =>Temperature= 26.6 degrees Celsius

 

 Example two: received 40 Data for: 00111000 00001000 00011010 10000110 11100000 Humidity integral digits Humidity scale Temperature integer bit Temperature scale Check digit 00111000+00001000+00011010+10000110=11100000(Check digit) receive data properly: Humidity:00111000 (Binary) =>56 (Decimal)00001000(Binary)=>8 (Decimal) =>Humidity=56.8%RH Temperature: temperature low 8Bit 为 1 It indicates sampling the temperature to minus-temperature 00011010 (Binary) =>26 (Decimal) 10000110 (Binary, Ignore 8Bit)=>6(Decimal)

=>Temperature=-26.6 degrees Celsius 

 

Communication between the host and the sensor, reads the data:

DHT12 After power-up (start to wait 2 seconds to cross the unstable condition of the sensor) tested environment temperature and humidity data, and record data, sensor automatic goes in hibernation. The pull-up resistor has remained high, at this time DHT12’s SDA PIN is input, detects external signals.

 Hosting by SDA Databus, output’s low level, and low level for at least 200ms released by bus. DHT12 detects a bus free, issue 80µs Low level than immediately 80µs High-level signal, as shown below:

 DHT12 After the response is sent immediately by the continuous serial data bus, the host under the bus level receives 40 Bit data. Bit data"0" Format:50µs Low level plus 26-28µs High level; data"1" Format:50µs Low level plus 70µs High level; data"0", Bit data"1" Signal format.

 The data bus output’s 40 Data, continue to output low level 50µs Free bus to enter State after. At the same time DHT12 An environmental temperature and humidity data, and records the data automatically after entering hibernation.

 

 

 DHT22 (DHT22 also named AM2302)

DHT22 Temperature and Humidity Sensor, DHT22, DHT22 pinout, Serial Communications of DHT22, DHT22 also named AM2302

DHT22 outputs a digital signal that has been calibrated. It employs a proprietary digital signal collection approach as well as humidity sensing technology to ensure its dependability and stability. It has an 8-bit single-chip microprocessor coupled to its sensor devices. Every sensor in this model is temperature adjusted and calibrated in a precise calibration chamber, and the calibration-coefficient is recorded in the type of program in OTP memory so that when the sensor detects, it will quote the coefficient from memory. DHT22's small size, low power consumption, and high transmission distance (20m) make it suitable for a wide range of demanding application scenarios. The connection is relatively straightforward because of the single-row packaging with four pins.

 

DHT22 Pinout:

No:

Pin Name

Description

1

VDD

Power supply 3.3-6VDC

2

Data

Signal

3

NULL

4

Ground

Connected to the ground of the circuit

 

Communication and signal:

Signaling and communication for communication between the MCU and the DHT22, single-bus data is used, and it takes 5mS for a single time communication. There are two parts to data: integral and decimal, the following is the formula for data.

 DHT22 send out higher data bit firstly! DATA=8 bit integral RH data+8 bit decimal RH data+8 bit integral T data+8 bit decimal T data+8 bit check-sum If the data transmission is right, check-sum should be the last 8 bit of "8 bit integral RH data+8 bit decimal RH data+8 bit integral T data+8 bit decimal T data".

 MCU send out start signal to DHT22:

 Data-bus's free status is high voltage level. When communication between MCU and DHT22 begins, a program of MCU will transform the data bus's voltage level from high to low level and this process must beyond at least 1ms to ensure DHT22 could detect MCU's signal, then MCU will wait 20-40us for DHT22's response.  

DHT22 send a response signal to MCU:

 When DHT22 detect the start signal, DHT22 will send out a low-voltage-level signal and this signal last 80us as a response signal, then program of DHT22 transform data bus's voltage level from low to a high level and last 80us for DHT22's preparation to send data. 

DHT22 send data to MCU:

 When DHT22 is sending data to MCU, every bit's transmission begins with a low-voltage-level that last 50us, the following high-voltage-level signal's length decide the bit is "1" or "0".

DHT11 Vs DHT22/AM2302 Vs DHT12

The DHT22 is the more costly model, but it offers superior characteristics. It has a temperature measurement range of -40°C to +125°C with +-0.5°C precision, whereas the DHT12 has a temperature range of -20°C to 60°C with +-0.5°C accuracy and the DHT11 has a temperature range of 0°C to 50°C with +-2 degrees accuracy. The DHT22 sensor also has a greater humidity measurement range, ranging from 0 to 100 percent with 2-5 percent accuracy, compared to the DHT12 humidity range of 20 to 95 percent with 5 percent accuracy and the DHT11 humidity range of 20 to 80 percent with 5 percent accuracy.

 Though the DHT22 is more precise, accurate, and functions across a wider temperature and humidity range, the DHT11 and DHT12 excel in three areas. It costs less, is smaller, and has a higher sampling rate. The DHT11 and DHT12 have a sampling rate of 1Hz, or one reading per second, whereas the DHT22 has a sampling rate of 0.5Hz or one reading per two seconds.

The operating voltage of the sensors, on the other hand, is between 3 and 5 volts. The nice part is that DHT11 and DHT22 sensors are swappable,' which means that if you use one in your project, you can simply remove it and replace it with another. Your code may need to be altered a little, but still, at least the wiring is the same, however, this is not possible with the DHT12 due to a pin design mismatch.

 

Internal Look

Internal Look difference between DHT11, DHT12 and DHT22

Here is the internal look of the sensors, as DHT12 looks wide from the outside compared to other sensors so as it is from the inside. The DHT22 has a Humidity sensor as well as a thermistor for sensing temperature and humidity. DHT11 has got a decent size.

 Comparison

DHT11

DHT12

DHT22

Power supply: DC 3.3~5.5V

Power supply: DC 2.7~5.5V

Power supply 3.3-6V DC

Supply current: Measure 0.3mA Standby 60μA

Supply current: Measure 800μA

Current supply: Measuring- 1~1.5mA

Relative Humidity:

Resolution:16Bit

Repeatability:±1%RH

Accuracy:25℃ ±5%RH 

Response time:1/e (63%)25℃ 6s 1m/s Air 6s

Relative humidity:

Resolution:  0.1%R H 

Measuring range:  20-95%R H 

Precision 60%RH

Repeatability:± 0.3 %RH 

Response time: 1/e(63%) s

Relative humidity:

Operating range: 0-100%RH

Accuracy humidity: +-2%RH(Max+-5%RH)

Resolution: 0.1%RH 

Repeatability:+-1%RH

Temperature:

Resolution:16Bit

Repeatability:±1℃

Accuracy:25℃ ±2℃

Response time:1/e (63%) 10S



Temperature:

Resolution:0.1 ℃,16 bit

Precision: 25 ℃ ± 0.5

Measuring range: - 20 ~ 60 ℃

Repeatability: ± 0.2 ℃

Response time: 1/e(63%) < 20 S 

Temperature:

Operating range:-40~80Celsius

Accuracy:<+-0.5Celsius

Resolution: 0.1Celsius

Repeatability:+-0.2 Celsius

 

Arduino temperature sensorDht 11 sensorDht sensorDht11Dht11 raspberry piDht11 temperature and humidity sensorDht12Dht12 arduinoDht12 raspberry piDht12 sensorDht22Dht22 arduinoDht22 raspberry piDigital temperature meterDs18b20K type thermocoupleLm35Lm35 temperature sensorNtc thermistorRtd sensorSensors & modulesTemperature meterTemperature sensorThermistorThermocoupleThermocouple thermometer