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, as this DHT11 give temperature in Celsius and humidity in percent and then Arduino read sensor and show on LCD.

Also, this circuit is good for checking room, garden or weather and furthermore, it is good for learning how sensor and Arduino work together.

Arduino Code:

#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:

How to Measure Humidity and Temperature using Arduino and DHT11

Parts List:

ComponentsQuantity
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 and 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 and then send data to Arduino with small signal blinks, then need command to start and take little time to finish.

After that Microcontroller read data and send to LCD and LCD show temperature and humidity and then finally, 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:

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

Also, code is simple and good for starting and if required we can add more things later.

Exit mobile version