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:
- Libraries for LCD and DHT added in code.
- The code sets the DHT and LCD pins.
- In setup() DHT and LCD start working.
- In loop() Arduino read temperature and humidity from DHT.
- If reading is okay then it shows on serial monitor and LCD.
Circuit Working:

Parts List:
| Components | Quantity |
|---|---|
| Resistor | |
| 470Ω 1/4 watt | 1 |
| Semiconductors | |
| Arduino UNO | 1 |
| IC 7809 | 1 |
| DHT11 Sensor | 1 |
| LCD Display 16×2 | 1 |
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:
- First, collect all parts in the circuit.
- Next, use IC 7809 to give stable 9V power to Arduino.
- Then put 470Ω resistor from LCD backlight anode to Arduino 5V.
DHT11 sensor connection:
- Now Connect VCC to Arduino 5V, connect GND to Arduino GND and then connect DATA to Arduino pin 2
LCD to Arduino connection:
- Connect VDD to Arduino 5V
- Connect VSS to Arduino GND
- Connect RS to Arduino pin 12
- Connect R/W to Arduino GND
- Connect E to Arduino pin 11
- Connect D4 to Arduino pin 5
- Connect D5 to Arduino pin 4
- Connect D6 to Arduino pin 3
- Connect D7 to Arduino pin 2
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.
Leave a Reply