• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Need circuit help? Post them in the comments! I've answered over 50,000!

Blog | Categories | About | Contact | Calculators-online
You are here: Home / Sensors and Detectors / Interfacing DHTxx Temperature Humidity Sensor with Arduino
warning message: electricity is dangerous, proceed with caution
P 20160629 080416

Interfacing DHTxx Temperature Humidity Sensor with Arduino

Last Updated on March 23, 2022 by Swagatam 11 Comments

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.  3 Easy Capacitive Proximity Sensor Circuits Explored
  • 2.  Make this EMF Pump Circuit and Go Ghost Hunting
  • 3.  Alcohol Detector Meter Circuit using MQ-3 Sensor Module
  • 4.  How to Use TTP223 Capacitive Touch Switch Module [Pinouts Explained]
  • 5.  Digital Up/Down Volume Control Circuit
  • 6.  Motion Detector Circuit using Doppler Effect

Filed Under: Sensors and Detectors Tagged With: Arduino, DHTxx, Humidity, Interfacing, Sensor, Temperature

About Swagatam

I am an electronics engineer and doing practical hands-on work from more than 15 years now. Building real circuits, testing them and also making PCB layouts by myself. I really love doing all these things like inventing something new, designing electronics and also helping other people like hobby guys who want to make their own cool circuits at home.

And that is the main reason why I started this website homemade-circuits.com, to share different types of circuit ideas..

If you are having any kind of doubt or question related to circuits then just write down your question in the comment box below, I am like always checking, so I guarantee I will reply you for sure!

Previous Post: « Make this Touch free Faucet Circuit for Hands-free Tap Control
Next Post: Make this Digital Temperature, Humidity Meter Circuit using Arduino »
Subscribe
Notify of
guest
guest
11 Comments
Inline Feedbacks
View all comments

Primary Sidebar

circuit simulator image

Subscribe to get New Circuits in your Email

Categories

  • Arduino Projects (90)
  • Audio and Amplifier Projects (132)
  • Automation Projects (17)
  • Automobile Electronics (101)
  • Battery Charger Circuits (84)
  • Datasheets and Components (105)
  • Electronics Theory (140)
  • Free Energy (39)
  • Games and Sports Projects (11)
  • Grid and 3-Phase (19)
  • Health related Projects (25)
  • Home Electrical Circuits (12)
  • Indicator Circuits (15)
  • Inverter Circuits (89)
  • Lamps and Lights (142)
  • Meters and Testers (71)
  • Mini Projects (46)
  • Motor Controller (65)
  • Oscillator Circuits (28)
  • Pets and Pests (15)
  • Power Supply Circuits (89)
  • Remote Control Circuits (50)
  • Security and Alarm (64)
  • Sensors and Detectors (103)
  • SMPS and Converters (31)
  • Solar Controller Circuits (60)
  • Temperature Controllers (42)
  • Timer and Delay Relay (49)
  • Transmitter Circuits (29)
  • Voltage Control and Protection (38)
  • Water Controller (36)

Other Links

  • Privacy Policy
  • Cookie Policy
  • Disclaimer
  • Copyright
  • Videos
  • Sitemap

People also Search

555 Circuits | 741 Circuits | LM324 Circuits | LM338 Circuits | 4017 Circuits | Ultrasonic Projects | SMPS Projects | Christmas Projects | MOSFETs | Radio Circuits | Laser Circuits | PIR Projects |

Social Profiles

  • Twitter
  • YouTube
  • Instagram
  • Pinterest
  • My Facebook-Page
  • Quora
  • Stack Exchange
  • Linkedin
  • Recent Comments

    • David on Simple Buck Converter Circuits using Transistors
    • Swagatam on Simple Buck Converter Circuits using Transistors
    • Swagatam on Pure Sine Wave Inverter Circuit Using IC 4047
    • Swagatam on Pure Sine Wave Inverter Circuit Using IC 4047
    • Swagatam on Simple Delay Timer Circuits Explained

    © 2025 · Swagatam Innovations