Site icon Circuit Ideas for You

How to Measure Humidity and Temperature using Arduino and DHT11

This project show How to Measure Humidity and Temperature using Arduino and DHT11

DHT11 give temperature in Celsius and humidity in percent.

Arduino read sensor and show on LCD.

This circuit is good for checking room, garden or weather.

It is also good for learning how sensor and Arduino work together.

Coding:

#include <DHT.h>
#include <LiquidCrystal.h>

// Define pins
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11

// Define LCD pins (adjust according to your connections)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Create DHT instance
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize LCD
  lcd.begin(16, 2); // Set number of columns and rows

  // Initialize DHT sensor
  dht.begin();
}

void loop() {
  // Read data from DHT sensor
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // Check if readings are valid
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;   

  }

  // Display data on LCD
  lcd.setCursor(0, 0);
  lcd.print("Humidity: ");
  lcd.print(h);
  lcd.print("%");

  lcd.setCursor(0, 1);
  lcd.print("Temp: ");
  lcd.print(t);
  lcd.print("C");

  // Print data to serial monitor for debugging
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print("%  ");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println("C ");

  delay(2000);
}

Code Explanation:

Circuit Working:

Parts List:

ComponentQuantity
Resistor
470Ω 1/4 watt1
Semiconductors
Arduino UNO1
IC 78091
DHT11 Sensor1
LCD Display 16×21

We use DHT11 sensor as it give temperature and humidity.

It look like one sensor but does both the jobs.

Gives good data, work long time and is cheap and easy.

Inside it has small computer which uses special way to measure.

Send data to Arduino with small signal blinks.

Need command to start and take little time to finish.

Microcontroller read data and send to LCD.

LCD show temperature and humidity.

470Ω resistor control LCD backlight.

How to Build:

To Measure Humidity and Temperature using Arduino and DHT11 following are the steps to follow:

DHT11 sensor connection:

LCD to Arduino connection:

Conclusion:

This tutorial for How to Measure Humidity and Temperature show how to use Arduino, DHT11 and LCD to measure temperature and humidity.

Code is simple and good for starting.

We can add more things later if required.

References:

Using DHT11 temp. and humidity sensor to measure & display the temp and humidity using an LCD without using any external libraries

Exit mobile version