Interface of Temperature Sensor(DHT11) with Arduino UNO

Introduction

In this tutorial, we are going to learn how to interface an Temperature sensor (DHT11) to an Arduino UNO. And we will learn how to measure temperature using Temperature sensor.

Theory(DHT11)

Temperature sensor (DHT11) is basically used for measure the temperature and also the humidity. It is a digital sensor. It gives digital value as output. We are going to connect the Temperature Sensor with an Arduino UNO.

DHT11 Module

There are a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal signal on the data pin.

Technical Details

  • Operating Voltage : 3v-5v
  • While it receives data maximum current required is 2.5mA .
  • Having an accuracy of 5% with 20-80% of humidity readings.
  • Having an accuracy of ±2° with 0-50°C of temperature readings.
  • Body size is 15.5mm x 12mm x 5.5mm.

Having 3 pins,

  • VCC
  • GND
  • Data Pin

Requirements

PartsQuantityLinks
Arduino UNO1
A-B cable1
DHT11 Module1
Bread Board1
Connecting WiresAs per required
TABLE

Circuit Diagram

The connection of DHT11 and UNO is very simple

  1. VCC to 5v of UNO
  2. GND to GND of UNO
  3. Data pin to one digital pin of UNO

Program

For programming this concept we need to understand some basic syntax of Arduino IDE. The first thing is we need to install Arduino . After that we need to know about How to use Serial Monitor in Arduino IDE .

NOTE: You need to install the DHT11 library to the Arduino IDE. You can download DHT.h library from github.

#include "string.h" // Header file string.h
#include "DHT.h" // Header file DHT.h

#define DHTPIN 2 // I have devlared here DHTPIN is connected to 2 no pin of UNO.
#define DHTTYPE DHT11 // DHTtype is DHT11
DHT dht (DHTPIN, DHTTYPE);

void setup()
{
  Serial.begin(9600); // Initiallization of Serial monitor
  Serial.println("TEMP SHOWING");
  dht.begin(); // Initiallization of DHT11
}

void loop()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  Serial.println("Temperature: " +String(t));
  Serial.println("Humidity: " +String(h));
  delay(1000);
}

Leave a Reply

Your email address will not be published. Required fields are marked *