DHT22 Temperature Sensor

This project will use a DHT22 temperature sensor that will activate a buzzer alarm once the temperature reaches as specified threshold as well as activate a red LED. If the temperature is below the threshold then a green LED will activate to signify the temperature being in an acceptable range. This project teaches you to develop a temperature alarm, which can be used for pet enclosures, monitoring the heat index/humidity of a room, or for a weather station.

Required Items:

DHT22       100ΩResistor     RGB LED (Common Cathode)        10KΩResistor        Buzzer

 

Library Download:

 

Fritzing Sketch:

 

Notes: The Fritzing sketch above shows an RHT01, which has one extra pin than the DHT22. This extra pin is not used anyway, but it is good to be aware of this.

Also note there is a wire connecting the 5v of the “DHT22” to the data pin, which must have a 10KΩ resistor connected to it for accurate readings.

A lot of designers have a resistor for each color pin on the RGB LED, which is a complete waste of resources. Instead, connect one 100Ω resistor to the negative since all electrical energy must go through the negative pin.

 

DHT22 Alarm Code (Fahrenheit):

Using the code and illustrations as reference, connect, upload, and open the serial monitor, where you will see the temperature and heat index displayed, updating every two seconds. The following text is a non-fully inclusive list of code adjustments you can make. Note that to show/remove a topic you would remove/add ‘//’ in front of the line without the quotation marks unless otherwise specified.

Show/Remove Celsius Temp.:          Lines 48-49

Show/Remove Fahrenheit Temp.:   Lines 50-51

Show Humidity (*F):                         Remove ‘false’ in Line 39, add ‘, false’                                                           (no quotes) on Line 41.

Show Humidity (*C):                         Remove ‘false’ in Line 41, add ‘, false’                                                           (no quotes) on Line 39.

Show/Remove Heat Index (*F):        Lines 56-57

Show/Remove Heat Index (*C):        Lines 54-55

Note that the limit temperature can be adjusted by changing the number in Line 60. Note that the given number is in Fahrenheit, to change the number to Celsius, use this calculator. To increase the temperature of the sensor, breathe heavily immediately in front of it and cool it down by either leaving it alone or placing it in a cool environment.