The DHT11 Sensor is low-cost digital Humidity and Temperature measuring sensor. In this article, we will interface the DHT11 sensor with Arduino and measure the temperature and humidity.

Working of DHT11 Sensor

Inside the sensor, there are two main components humidity sensing component and an NTC temperature sensor.

DHT11 has an inbuild Negative Temperature coefficient thermistor to measure temperature which decreases its resistance with the increase in temperature.

To measure humidity it has two electrodes filled with a moisture-holding substance between them. So, the humidity changes conductivity of the substance is changes, and this data is processed by the IC and made data ready for the controller.

DHT11 key features

  • DHT11 sensor work 3.5v to 5.5v and consume 0.3mA (measuring) 60uA (standby).
  • It can sense 0°C to 50°C with the accuracy of ±1°C & 20% to 90% humidity with the accuracy of ±1%.
  • The sensor gives serial output with 16-bit resolution.
  • Dimension: 3.5 x 2 x 6.5 cm

Pinout

DHT11 sensor has 3 pins

  • VCC is the positive terminal of the sensor. It can work from 3.5v to 5.5v.
  • GND is the negative terminal of the sensor.
  • DATA pin is the digital output pin.

Material Required

For this project we need the following components:-

NameQuantity
Arduino1
DHT11 sensor1
Jumper wiresas per requirement

DHT11 connection with Arduino

Code

First, include the DHT11 library in your Arduino IDE. Sketch>include librarry>manage library search for dht and install it.

#include <dht.h>

#define dataPin 8 // Defines pin number to which the sensor is connected
dht DHT; // Creats a DHT object

void setup() {
  Serial.begin(9600);
}
void loop() {
  int readData = DHT.read22(dataPin); // Reads the data from the sensor
  float t = DHT.temperature; // Gets the values of the temperature
  float h = DHT.humidity; // Gets the values of the humidity
  
  // Printing the results on the serial monitor
  Serial.print("Temperature = ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print("    Humidity = ");
  Serial.print(h);
  Serial.println(" % ");
  
  delay(2000); // Delays 2 secods, as the DHT22 sampling rate is 0.5Hz
}
Newsletter SignupLoving Our Content?

Subscribe to our weekly newsletter below and never miss any update that is most likely to blow your mind.