• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Get free circuit help 24/7

New Projects | Privacy Policy | About us | Contact | Disclaimer | Copyright | Videos | Circuits for Beginners | Basic Circuits | Hobby Projects | Transistor Circuits | LED Drivers 

You are here: Home / Sensors and Detectors / Interfacing DHTxx Temperature Humidity Sensor with Arduino

Interfacing DHTxx Temperature Humidity Sensor with Arduino

Last Updated on March 23, 2022 by Swagatam 11 Comments

caution electricity can be dangerous

In this article we are going to take a look at DHTxx series sensors, which is used for measuring temperature and humidity, both the functionality is integrated into one module.

We are going to see their specification, so that you can choose best sensor for your project and finally we are going to interface it with arduino and read the values in serial monitor of arduino IDE software.

DHTxx consist of just two series DHT11 and DHT22. The major difference between them is their specification and cost. DHT11 is low end sensor and DHT22 is high end one. DHT22 is more expensive than DHT11, but low end is decent enough for hobby project unless you do some serious measurement with you project.

DHTxx is 4-pin device one of them is NC or no connection so, we are going to use just 3-pins. Two of them are supply pins and remaining one is output pin. The sensor may look simple, but it requires a library for handling it.

The sensor consists of a thermistor, a humidity sensing device and a microcontroller embedded in a module. Their specifications are as follows:

DHT11:
• Operating voltage range is 3 to 5V.
• Its maximum current consumption is 2.5mA.
• It can measure humidity ranging from 20% to 80% -/+ 5% accuracy.
• It can measure temperature ranging from 0 to 50 degree Celsius +/- 2% accuracy.
• It refreshes it value every one second.
• Its size is 15.5mm x 12mm x 5.5mm

DHT22:
• Operating voltage is 3 to 5V
• Its maximum current consumption is 2.5mA.
• It can measure humidity ranging from 0% to 100% 2-5 % accuracy.
• It can measure temperature ranging from -40 to +125 degree Celsius +/- 0.5% accuracy.
• It refreshes it value twice every one second.
• Its size is 15.1mm x 25mm x 7.7mm
From the above raw specifications you can choose which one is optimum for your project.

DHT11 Temperature Humidity Sensor

The data pin always should be connected with a pull-up resistor from 4.7K to 10K. The above illustrated sensor came with PCB with eliminated NC pin and with pull-up resistor. But some sensors come without those feature, without the pull-up resistor the readings send to arduino will be fatally error values.

Now we are going to interface DHT sensor with arduino. Before proceeding the project download the library file form the following link:

https://arduino-info.wikispaces.com/file/detail/DHT-lib.zip

You just need these four components: DHTxx sensor, arduino Uno, USB cable, and a PC.

Just insert the sensor on analog pins of the arduino as illustrated in prototype and dump the code to arduino, open the serial monitor and you can see the readings.
Author’s prototype:

Interfacing DHTxx Temperature Humidity Sensor with Arduino
//----------------------Program developed by R.Girish-------------//
#include <dht.h>
dht DHT;
#define DHTxxPIN A1
int p = A0;
int n = A2;
int ack;
int f;
void setup(){
  Serial.begin(9600);
  pinMode(p,OUTPUT);
  pinMode(n,OUTPUT);
}
void loop()
{
  digitalWrite(p,1);
  digitalWrite(n,0);
  ack=0;
  int chk = DHT.read11(DHTxxPIN);
  switch (chk)
  {
    case DHTLIB_ERROR_CONNECT:
        ack=1;
        break;
  }
  if(ack==0)
  {
  f=DHT.temperature*1.8+32;
  Serial.print("Temperature(°C) = ");
  Serial.println(DHT.temperature);
  Serial.print("Temperature(°F) = ");
  Serial.print(f);
  Serial.print("\n");
  Serial.print("Humidity(%) = ");
  Serial.println(DHT.humidity);
  Serial.print("\n");
  delay(500);
}
if(ack==1)
{
  Serial.print("NO DATA");
  Serial.print("\n\n");
  delay(500);
}
}
//----------------------Program developed by R.Girish-------------//

Serial monitor output:

You'll also like:

  • 1.  AC Phase, Neutral, Earth Fault Indicator Circuit
  • 2.  Satellite Signal Strength Meter Circuit
  • 3.  Morse Code Flasher Circuit for Lighthouse
  • 4.  Temperature to Voltage Converter Circuit
  • 5.  4 Automatic Day Night Switch Circuits Explained
  • 6.  How to Build a Rain Sensor Circuit

About Swagatam

I am an electronic engineer (dipIETE ), hobbyist, inventor, schematic/PCB designer, manufacturer. I am also the founder of the website: https://www.homemade-circuits.com/, where I love sharing my innovative circuit ideas and tutorials.
If you have any circuit related query, you may interact through comments, I'll be most happy to help!

Have Questions? Please Comment below to Solve your Queries! Comments must be Related to the above Topic!!

Subscribe
Notify of
11 Comments
Newest
Oldest
Inline Feedbacks
View all comments

Primary Sidebar

Calculators

  • 3-Phase Power (15)
  • 324 IC Circuits (19)
  • 4017 IC Circuits (52)
  • 4060 IC Circuits (25)
  • 555 IC Circuits (98)
  • 741 IC Circuits (19)
  • Arduino Engineering Projects (83)
  • Audio and Amplifier Projects (114)
  • Battery Chargers (82)
  • Car and Motorcycle (94)
  • Datasheets (46)
  • Decorative Lighting (Diwali, Christmas) (33)
  • Electronic Components (100)
  • Electronic Devices and Circuit Theory (36)
  • Electronics Tutorial (116)
  • Fish Aquarium (5)
  • Free Energy (34)
  • Fun Projects (13)
  • GSM Projects (9)
  • Health Related (20)
  • Heater Controllers (29)
  • Home Electrical Circuits (102)
  • How to Articles (20)
  • Incubator Related (6)
  • Industrial Electronics (28)
  • Infrared (IR) (40)
  • Inverter Circuits (98)
  • Laser Projects (12)
  • LED and Light Effect (93)
  • LM317/LM338 (21)
  • LM3915 IC (25)
  • Meters and Testers (65)
  • Mini Projects (148)
  • Motor Controller (67)
  • MPPT (7)
  • Oscillator Circuits (26)
  • PIR (Passive Infrared) (8)
  • Power Electronics (34)
  • Power Supply Circuits (77)
  • Radio Circuits (10)
  • Remote Control (48)
  • Security and Alarm (61)
  • Sensors and Detectors (121)
  • SG3525 IC (5)
  • Simple Circuits (75)
  • SMPS (29)
  • Solar Controllers (60)
  • Timer and Delay Relay (53)
  • TL494 IC (5)
  • Transformerless Power Supply (8)
  • Transmitter Circuits (40)
  • Ultrasonic Projects (16)
  • Water Level Controller (45)

Calculators

  • AWG to Millimeter Converter
  • Battery Back up Time Calculator
  • Capacitance Reactance Calculator
  • IC 555 Astable Calculator
  • IC 555 Monostable Calculator
  • Inductance Calculator
  • LC Resonance Calculator
  • LM317, LM338, LM396 Calculator
  • Ohm’s Law Calculator
  • Phase Angle Phase Shift Calculator
  • Power Factor (PF) Calculator
  • Reactance Calculator
  • Small Signal Transistor(BJT) and Diode Quick Datasheet
  • Transistor Astable Calculator
  • Transistor base Resistor Calculator
  • Voltage Divider Calculator
  • Wire Current Calculator
  • Zener Diode Calculator

© 2023 · Swagatam Innovations

wpDiscuz