Contents
Temperature and humidity Sensor
The DHTxx series is a commonly used Temperature and humidity sensor. The sensor comes with a dedicated NTC to measure temperature and an 8-bit microcontroller to output the values of temperature and humidity as serial data.
The sensor is also factory calibrated and hence easy to interface with other MCU. DHT11/DHT22 sensors are popular among the Arduino projects. The DHT sensors are inexpensive sensors for measuring temperature and humidity.
These sensors contain a chip that does analog to digital conversion and spits out a digital signal with the temperature and humidity.
These signals are easy to read with (MCU).
SPECIFICATIONS OF DHT11 Vs DHT22
There two types

1. DHT11 (AM2302)
a. Range: 20 – 90%
b. Absolute accuracy:±5%
c. Repeatability:±1%
d. Stability:1% per year.
e. Operating Voltage: 3.5V to 5.5V
f. Operating current: 0.3mA (measuring) 60uA (standby)
g. Output: Serial data
h. Resolution: Temperature and Humidity both are 16-bit
2. DHT22
a. Range: 20 – 100%
b. Absolute accuracy:±2%
c. Repeatability:±1%
d. Stability: 0.5% per year
e. Operating Voltage: 3.5V to 5.5V
f. Operating current: 0.3mA (measuring) 60uA (standby)
g. Output: Serial data
h. Resolution: Temperature and Humidity both are 16-bit
PIN DETAILS:
PIN DETAILS | Arduino Wiring |
Pin-1 VCC | 5V |
Pin-2 Data out | Digital Oin out |
Pin-3 (NC) | No Connection |
Pin-4 Ground | Gnd |
FEATURE:
1. Full range temperature compensated.
2. Relative humidity and temperature measurement.
3. Calibrated digital signal.
4. Outstanding long-term stability.
5. Extra components not needed.
6. Long transmission distance.
7. Low power consumption.
8. 4 pins packaged and fully interchangeable.
ALL SENSOR DETAILS:
1. HC-05 – Bluetooth
2. Mpu 6050 accelerometer-gyroscope- -module
3. Flame-sensor
4. Rotary-encoder
5. Force-sensor-fsr400
6. Current-sensor-acs712
7. Flex-sensor
8. IR-sensor-tcrt5000
9. Pulse-sensor-pin
10. Color-sensor-tcs230
11. SD-card-module
12. Oled-with-arduino
13. Addressable-rgb-led-strip-ws1812
14. Relay-module
15. TFT-1-8-display-st7735r
16. 8×8-dot-matrix-display-max7219
17. Smoke-sensor-mq-2
18. Ultrasonic-sensor-HC-sr04
19. PIR-motion-sensor-hc-sr501
20. Tilt-sensor-sw-520d
21. Microphone-sound-sensor
22. Reed-switch-reed-sensor
23. Rfid-reader-Em18
24. Rfid-tag
25. RTC-real-time-clock-ds1307
26. Temperature-sensor-ds18b20
27. Moisture-sensor
28. Rain-sensor
29. Pressure-sensor
30. Accelerometer
31. MOC-3021-circuit
32. DHT11-DHT22-temperature-and-humidity-sensor
APPLICATIONS:
a. Measure temperature and humidity.
b. Local Weather station.
c. Automatic climate control.
d. Environment monitoring.
HOW TO TEST DHT SENSOR WITH ARDUINO UNO.
Open Arduino IDE installed Computer and you want to add or install the DNT Library.
Follow the below given steps
1. Download the DHT11 library.
2. Install the DHT11 in your Arduino IDE: go to Sketch >>Include Library >>Add.
3. Restart your Arduino IDE
4. Go to File >>Examples >>DHT sensor library >>DHTtester
5. Upload the code
For example : Copy and Paste below given code with your Arduino IDE Sketch, compile and upload, test with serial monitor.
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include “DHT.h”
#define DHTPIN 2 // what digital pin we’re connected to
// Uncomment whatever type you’re using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors. This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println(“DHTxx test!”);
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds ‘old’ (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(“Failed to read from DHT sensor!”);
return;
}
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(“Humidity: “);
Serial.print(h);
Serial.print(” %\t”);
Serial.print(“Temperature: “);
Serial.print(t);
Serial.print(” *C “);
Serial.print(f);
Serial.print(” *F\t”);
Serial.print(“Heat index: “);
Serial.print(hic);
Serial.print(” *C “);
Serial.print(hif);
Serial.println(” *F”);
}
For Arduino IDE Software: Download Here. Download DHT library: Here