
Project: Arduino-Based Temperature and Humidity Monitoring System
1. Introduction
Monitoring temperature and humidity is essential in various applications, such as home automation, greenhouses, industrial settings, and weather stations. This project demonstrates how to build an Arduino-based temperature and humidity monitoring system using a DHT11 sensor and an LCD display to visualize the readings in real-time.
2. Learning Objectives
By completing this project, you will:
- Understand how to interface a DHT11 sensor with an Arduino.
- Learn how to display sensor data on an LCD.
- Develop skills in writing and debugging Arduino code.
- Gain knowledge of data acquisition and display techniques.
3. Tools and Components
Hardware
- Arduino Uno
- DHT11 temperature and humidity sensor
- 16×2 LCD display with I2C module
- Jumper wires
- Breadboard
- 10kΩ potentiometer (if not using I2C for LCD)
Software
- Arduino IDE
- DHT sensor library
- LiquidCrystal_I2C library
4. Background/Definitions
DHT11 Sensor
The DHT11 is a digital sensor used for measuring temperature and humidity. It has:
- A temperature measurement range of 0-50°C
- A humidity range of 20-90%
- An accuracy of ±2°C for temperature and ±5% for humidity
LCD Display with I2C
The 16×2 LCD displays text in two rows, each with 16 characters. Using the I2C module reduces the number of Arduino pins required for connection, simplifying wiring.
I2C Protocol
I2C (Inter-Integrated Circuit) is a serial communication protocol that allows multiple devices to communicate using only two wires: SDA (data) and SCL (clock).
5. Step-by-Step Guide
Step 1: Wiring the Circuit
Connect the components as follows:
- DHT11 Sensor:
- VCC → 5V (Arduino)
- Data → Digital Pin 2 (Arduino)
- GND → GND (Arduino)
- LCD with I2C:
- VCC → 5V (Arduino)
- GND → GND (Arduino)
- SDA → A4 (Arduino)
- SCL → A5 (Arduino)
Step 2: Installing Required Libraries
Open the Arduino IDE and install the required libraries:
- Go to Sketch > Include Library > Manage Libraries.
- Search for DHT sensor library by Adafruit and install it.
- Search for LiquidCrystal_I2C and install it.
Step 3: Writing the Arduino Code
Upload the following code to your Arduino:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
lcd.begin();
lcd.backlight();
dht.begin();
}
void loop() {
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print(" %");
delay(2000);
}
6. Testing and Debugging Tips
- If the LCD does not display correctly, ensure the I2C address (0x27) matches your module. You can use an I2C scanner sketch to find the correct address.
- If the DHT11 sensor returns
NaN, check wiring and ensure the library is installed properly. - Ensure the SDA and SCL lines are correctly connected and not swapped.
7. Extensions
- Add a Buzzer: Make the system trigger an alarm when temperature or humidity exceeds a threshold.
- Data Logging: Store temperature and humidity values on an SD card for later analysis.
- IoT Integration: Use an ESP8266 or ESP32 to send data to a cloud service for remote monitoring.
This project provides a fundamental introduction to using sensors and displays with Arduino, allowing for further enhancements based on specific needs. Happy building!