

DHT-11 is a temperature & humidity sensor in one package. It utilizes exclusive digital-signal-collecting-technique and humidity sensing technology, assuring its reliability and stability. Its sensing elements is connected with 8-bit single-chip computer. Every sensor of this model is temperature compensated and calibrated in accurate calibration chamber and the calibration-coefficient is saved in type of program in OTP memory, when the sensor is detecting, it will cite coefficient from memory. Small size & low consumption & long transmission distance(20m) enable DHT-11 to be suited in all kinds of harsh application occasions.
Characteristics:
- Low Cost
- Supply voltage 3 to 5V
- Max current 2.5mA (while requesting data)
- 20-80% humidity range with 5% accuracy
- 0-50C temperature range with +-2C
Inside the package looks like this:
The interesting thing in this module is the protocol that uses to transfer data. All the sensor readings are sent using a single wire bus which reduces the cost and extends the distance.
In order to send data over a bus you have to describe the way the data will be transferred, so that transmitter and receiver can understand what says each other. This is what a protocol does. It describes the way the data are transmitted.
On DHT-11 the 1-wire data bus is pulled up with a resistor to VCC. So if nothing is occurred the voltage on the bus is equal to VCC.

Request:
To make the DHT-11 to send you the sensor readings you have to send it a request. The request is, to pull down the bus for more than 18ms in order to give DHT time to understand it and then pull it up for 40uS.

Response:
What comes after the request is the DHT-11 response. This is an automatic reply from DHT which indicates that DHT received your request. The response is ~54uS low and 80uS high.

Data:
What will come after the response is the sensor data. The data will be packed in a packet of 5 segments of 8-bits each. Totally 5×8 =40bits.

First two segments are Humidity read, integral & decimal. Following two are Temperature read in Celsius, integral & decimal and the last segment is the Check Sum which is the sum of the 4 first segments. If Check Sum's value isn't the same as the sum of the first 4 segments that means that data received isn't correct.
How to Identify Bits:
Each bit sent is a follow of ~54uS Low in the bus and ~24uS to 70uS High depending on the value of the bit.
Bit '0' : ~54uS Low and ~24uS High
Bit '1' : ~54uS Low and ~70uS High

End Of Frame:
At the end of packet DHT sends a ~54uS Low level, pulls the bus to High and goes to sleep mode.
Logic Analyzer Snapshots
In the following image you can see the request sent from the MCU to the DHT and following the packet. Because the request has very long duration as you can see is about 20mS and packet received is in uS we can't view the data bits.

If we zoom at the data bits we can read the values. You can see after the Request follows the Response, and Data bits. I have drawn some color notes to be more understandable.

If we decode the above data we have.
Humidity 0b00101011.0b00000000 = 43.0%
Temperature 0b00010111 = 23 C.
The last two segments can't be seen in this image because of zoom.
Implementation:
What we have to do to read a DHT-11 sensor is:
- Send request
- Read response
- Read each data segment and save it to a buffer
- Sum the segments and check if the result is the same as CheckSum
If the CheckSum is correct, the values are correct so we can use them. If CheckSum is wrong we discard the packet.
To read the data bits can use a counter and start count uSeconds of High level. For counts > 24uS we replace with bit '1'. For counts <=24 we replace with bit'0'
Here you can find some code to read DHT-11 using an Atmega8 at 16Mhz



Anyone who has worked on circuits before has used an analog potentiometer. If you are new in electronics here is a quick explanation of what a potentiometer is. In a few words a potentiometer is a varying resistor which value changes by turning the knob. By the Ohm Law V=I*R implies that it can be used for voltage or current adjustments. An example of potentiometers use is in front panels for varying values e.g in a work bench power supply to adjust the voltage or the current.
easier to use in analog circuits.






home