
🌡️ Arduino Project: Smart Temperature and Humidity Monitor with LCD Display
🧭 1. Introduction
In this project, you’ll build a real-time temperature and humidity monitor using a DHT11 sensor and a 16×2 LCD display with I2C communication. This project introduces key concepts in sensor interfacing, data acquisition, and data display. You’ll see how to read environmental data and show it in a readable format on an LCD screen.
Real-world applications include home automation, greenhouse monitoring, weather stations, and HVAC systems.
🎯 2. Learning Objectives
- Understand how to interface a digital sensor with an Arduino board.
- Learn how to display sensor data using an I2C LCD.
- Gain experience using libraries for sensor and LCD communication.
- Practice debugging basic embedded hardware setups.
🧰 3. Tools and Components
You’ll need the following items:
- 1 Arduino Uno (or any compatible Arduino board)
- 1 DHT11 temperature and humidity sensor
- 1 16×2 LCD display with I2C module (for simplified wiring)
- 1 Breadboard
- Around 10 jumper wires (male-to-male)
- 1 USB cable to connect Arduino to your computer
- Arduino IDE software installed on your computer
Optional: If your DHT11 does not have a pull-up resistor built-in, you may need a 10kΩ resistor between the VCC and DATA lines.
📚 4. Background / Key Definitions
DHT11 Sensor:
A basic, low-cost digital sensor that can measure temperature (0–50°C) and humidity (20–90%). It communicates using a single digital pin.
I2C Communication:
A two-wire protocol used to communicate between microcontrollers and peripherals like sensors or displays. The two lines are:
- SDA (Serial Data Line)
- SCL (Serial Clock Line)
Why I2C LCD?
Without I2C, an LCD typically requires 6–10 connections. With an I2C backpack module, only two Arduino pins (A4 and A5 for Uno) are needed for communication, leaving the rest available for other devices.
🛠️ 5. Step-by-Step Instructions
Wiring the Components
DHT11 Sensor Connections:
- VCC to 5V on Arduino
- GND to GND on Arduino
- DATA to Digital Pin 2 on Arduino
LCD with I2C Module Connections:
- GND to GND on Arduino
- VCC to 5V on Arduino
- SDA to A4 (on Arduino Uno)
- SCL to A5 (on Arduino Uno)
Tip: Make sure the I2C address of your LCD is known. Most common are
0x27or0x3F.
Setting Up the Arduino IDE
Before writing the code, install the following libraries:
- Open Arduino IDE.
- Go to Sketch > Include Library > Manage Libraries.
- Search for and install these libraries:
- DHT sensor library by Adafruit
- Adafruit Unified Sensor
- LiquidCrystal_I2C by Frank de Brabander
Arduino Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
// Initialize the LCD at I2C address 0x27 with 16 columns and 2 rows
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Define DHT sensor type and pin
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
lcd.begin();
lcd.backlight();
dht.begin();
lcd.print("Initializing...");
delay(2000);
}
void loop() {
float humidity = dht.readHumidity();
float temperature = dht.readTemperature(); // Celsius
// If reading fails, show error
if (isnan(humidity) || isnan(temperature)) {
lcd.clear();
lcd.print("Sensor Error");
return;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print((char)223); // Degree symbol
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print("%");
delay(2000); // Refresh every 2 seconds
}
🧪 6. Testing and Debugging Tips
- If the LCD doesn’t show anything: Use an I2C scanner sketch to find the correct I2C address.
- If “Sensor Error” appears on the LCD: This means the DHT11 didn’t respond. Double-check wiring and ensure the sensor has stabilized after powering on.
- Readings not changing? Try breathing lightly over the sensor or warming it with your hand to test responsiveness.
- Flickering display? Avoid constant screen updates by ensuring at least a 2-second delay between updates.
🚀 7. Extensions and Upgrades
- Add a button to toggle between Celsius and Fahrenheit.
- Use a DHT22 sensor for better accuracy and wider range.
- Log data to an SD card with a data logger module.
- Display data remotely by connecting to Wi-Fi using an ESP8266 or ESP32.
- Control appliances (like a fan or humidifier) using a relay module based on temperature or humidity thresholds.
Let me know if you’d like a visual circuit diagram, or a version of this project using ESP8266 for IoT features. I’m happy to build on this!