DHT11 and DHT22 are the most popular types of humidity sensor . They can measure relative humidity in percentage and temperature in degree celcius , it can measure temperature range of 0 to 50 °C and relative humidity 20% to 90% .This sensor is normal type of sensor which has three leg in which two pins are used for ground and vcc and from one pin data can be observed .Data are normally digital in nature so we do not need to convert it into another form . we can direct measure the output value digitally . If you want to make a project using humidity sensor please check our project section of microcontrollers there you will find some material for it .
I have searched for DHT11 and DHT22 library on internet for proteus simulation but they didn't worked on my proteus file so Here i will show you real world hardware configuration for it .
before coding please include lcd.h and lcd.c files download it from this link and the code explanation is shown in below the code
code explanation for DHT11
- First initialize the lcd.h library. you can find more about interfacing LCD with avr in learn avr section of this website
- Define pin no. to interface DHT11 sensor, in our program we define PD6 (Pin no. 20).
- Send the start pulse to DHT11 sensor, making low to high.
- Receive the response pulse from the DHT11 sensor.
- After receiving the response, receive 40-bit data serially from DHT11 sensor.
- Display these received data on LCD16x2 along with error indication
Generally DHT11 uses only one line for communication. The voltage levels with certain time value defines the logic one or logic zero on this pin. The communication process is divided in three steps, first is to send request to DHT11 sensor then sensor will send response pulse and then it starts sending data of total 40 bits to the microcontroller.
It will be a good idea to read data sheet of DHT11 sensor to know exact internal timming diagram instead of explaining all things here so please read data sheet .You can download datasheet from this link dht11