How to Interface Temperature Sensor(DHT11) with Arduino UNO

shape
shape
shape
shape
shape
shape
shape
shape
blog-details
June, 2021

INTRODUCTION

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

THEORY

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

 

There are a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital 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,

I)VCC

II)GND

III)Data Pin

 

REQUIREMENTS

 

Parts Quantity
Arduino UNO 1
A-B cable 1
DHT11 Module 1
Bread Board 1
Connecting Wires As per required

 

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 the DHT.h library from GitHub.

 

/*
 Tested by robogenesis. in
 Data will show in your serial monitor.
*/

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

#define DHTPIN 2 // I have declared 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);
}

 

Comments

client
client

Leave a Reply