In this article, we are going to learn about the DHT11 Temperature and Humidity Sensor, its features and how it works. The DHT11 is a frequently used temperature and humidity sensor, which is equipped with a dedicated NTC for temperature measurement and an 8-bit microcontroller for generating the temperature and humidity values as serial data.
Pin Description of
Pin No. | Pin Name | Pin Description |
1 | VCC | Power supply 3.5V to 5.5V |
2 | DATA | Outputs both Temperature and Humidity through serial Data |
3 | NC | Not in use |
4 | GND | Ground |
Communication with Microcontroller
DHT11 uses only one wire for communication voltage levels with a certain time value defining logical one or logical zero on this pin. The communication process is divided into three steps, first, the request is sent to the DHT11 sensor, then the sensor sends a response pulse and then it starts sending data totalling 40 bits to the microcontroller.
Start pulse (Request)
To start communication with DHT11, we must first send the start pulse to the DHT11 sensor. To provide the start pulse, lower (lower) the data pin by at least 18 ms and then pull it up as shown in the figure.
Response
After receiving the start pulse, the DHT11 sensor sends the response pulse, which indicates that the DHT11 has received the start pulse. The impulse response is low for 54 µs and then high for 80 µs.
Data
After sending the response pulse, the DHT11 sensor sends the data containing the humidity and temperature values as well as a checksum. The data frame has a total length of 40 bits, contains 5 segments (bytes) and each segment is 8 bits long. These 5 segments, the first two segments, contain humidity values in decimal integer form. This value tells us the relative percentage of humidity in the air. The first 8 bits are the integer parts and the next 8 bits are the fractions. This value gives us the temperature in Celsius form.
The last segment is the checksum, which contains the checksum of the first four segments. The checksum byte is the direct sum of the humidity and temperature values. And we can check whether it matches the checksum value or not. If this is not the case, there is an error in the data received. As soon as the data has been received, the DHT11 pin goes into low power mode until the next start pulse.
End of frame
After sending 40-bit data, the DHT11 sensor sends low-level 54us and then goes up. After that, DHT11 goes into sleep mode.
Characteristics and specifications of DHT11
- Ultra-low-cost
- 3 to 5V power and I/O
- 2.5mA max current use during conversion (while requesting data)
- Good for 20-80% humidity readings with 5% accuracy
- Good for 0-50°C temperature readings ±2°C accuracy
- No more than 1 Hz sampling rate (once every second)
- Body size 15.5mm x 12mm x 5.5mm
- 4 pins with 0.1″ spacing