DHT 11: A temperature sensor

2 min read


In the realm of electronics and sensor technology, DHT11 and DHT22 stand out as two remarkable sensors that have found widespread use in various applications. These sensors are known for their ability to measure temperature and humidity with remarkable precision, making them valuable tools in fields like home automation, weather monitoring, and industrial automation. In this comprehensive guide, we will delve into the working principles, specifications, advantages, disadvantages, applications, and how to connect and code DHT11 and DHT22 sensors with an Arduino.

Working Principle

DHT11 and DHT22 sensors are both part of the Digital Humidity and Temperature (DHT) sensor family. They rely on a capacitive humidity sensor and a thermistor to measure humidity and temperature, respectively.

DHT11 Sensor:

The DHT11 sensor consists of a humidity-sensitive, capacitive-type sensor and a thermistor. The humidity sensor measures the relative humidity by detecting changes in the capacitance.

The thermistor measures the temperature by varying its resistance with temperature changes. The sensor converts the analog values into digital signals and transmits them to the microcontroller.

DHT22 Sensor:

The DHT22, often referred to as the AM2302, operates on a similar principle to the DHT11 but offers higher accuracy and a wider measurement range.

It features a more advanced sensor element and communicates using a single-wire digital protocol.


Difference between DHT11 and DHT22 sensor


  • Affordability: Both DHT11 and DHT22 sensors are cost-effective options for temperature and humidity sensing.

  • Ease of Use: They are simple to interface with microcontrollers like Arduino due to their digital output.

  • Wide Range of Applications: These sensors find applications in weather stations, indoor climate control, greenhouse monitoring, and more.

  • Availability: DHT sensors are widely available and supported by various libraries and platforms.


  • Limited Accuracy: While suitable for many applications, they may not provide the level of accuracy required for highly precise measurements.

  • Response Time: DHT11 and DHT22 sensors have a relatively slow response time, making them unsuitable for applications requiring rapid data acquisition.

  • Calibration: They may require occasional calibration to maintain accuracy.

  • Applications

DHT11 and DHT22 sensors are used in various applications, including:

  • Home automation for climate control and energy efficiency.

  • Weather stations and environmental monitoring.

  • Industrial automation for controlling humidity-sensitive processes.

  • Agriculture, especially in greenhouse environments.

  • HVAC systems to monitor and adjust indoor climate.

  • How to Connect to Arduino and Code

Pin configuration:

Connecting DHT11/DHT22 to an micro-Controller is straightforward

  • Connect the VCC pin to 3.3V or 5V on the Arduino, depending on the sensor model.

  • Connect the GND pin to the ground.

  • Connect the DATA pin to a digital pin on the Arduino (e.g., D2).

Arduino Code:

Install the DHT sensor library from the Arduino Library Manager.