Project: Smart Temperature and Humidity Monitor using Arduino and DHT11 Sensor
Project: Smart Temperature and Humidity Monitor using Arduino and DHT11 Sensor file EeFyxXmbhjfihkAdU8GQ5N

Project: Smart Temperature and Humidity Monitor using Arduino and DHT11 Sensor


1. Introduction

This project is a Smart Temperature and Humidity Monitor using an Arduino microcontroller and a DHT11 sensor. The system reads temperature and humidity levels and displays them on an LCD screen. This project is useful for home automation, weather monitoring, and greenhouse management.

2. Learning Objectives

By completing this project, you will learn:

  • How to interface a DHT11 sensor with an Arduino.
  • How to use an LCD display (16×2) with Arduino.
  • How to write Arduino code for sensor data acquisition and display.
  • How to troubleshoot basic hardware connections and errors.

3. Tools and Components

You will need:

  • Arduino Uno
  • DHT11 Temperature and Humidity Sensor
  • 16×2 LCD Display
  • I2C Module for LCD (optional, for easier connections)
  • 10kΩ Potentiometer (for adjusting LCD contrast, if not using I2C)
  • Jumper wires
  • Breadboard
  • USB cable for programming Arduino
  • Arduino IDE (for programming)

4. Background and Definitions

  • DHT11 Sensor: A digital sensor that measures temperature and humidity using a capacitive humidity sensor and a thermistor.
  • Arduino Uno: A microcontroller board based on the ATmega328P, commonly used for DIY electronics projects.
  • 16×2 LCD: A Liquid Crystal Display that can show 16 characters per row across 2 rows, commonly used in embedded systems.
  • I2C Module: A module that simplifies LCD wiring by reducing the required pins.

5. Step-by-Step Guide

Step 1: Circuit Connections

Connecting the DHT11 Sensor

  • Connect the VCC pin of the DHT11 sensor to the 5V pin on the Arduino.
  • Connect the Data pin of the DHT11 sensor to Digital Pin 2 on the Arduino.
  • Connect the GND pin of the DHT11 sensor to the GND pin on the Arduino.

Connecting the 16×2 LCD (Without I2C Module)

  • Connect the VSS pin to GND.
  • Connect the VDD pin to 5V.
  • Connect the V0 pin to the middle pin of a 10kΩ potentiometer.
  • Connect the RS pin to Digital Pin 7.
  • Connect the RW pin to GND.
  • Connect the E pin to Digital Pin 6.
  • Connect the D4, D5, D6, and D7 pins to Digital Pins 5, 4, 3, and 2, respectively.
  • Connect the A pin to 5V (for backlight).
  • Connect the K pin to GND.

Connecting the 16×2 LCD (With I2C Module)

  • Connect the VCC pin to 5V.
  • Connect the GND pin to GND.
  • Connect the SDA pin to Analog Pin A4.
  • Connect the SCL pin to Analog Pin A5.

Step 2: Install Required Libraries

  1. Open the Arduino IDE.
  2. Go to Sketch → Include Library → Manage Libraries.
  3. Search for DHT sensor library by Adafruit and install it.
  4. Search for LiquidCrystal_I2C (if using I2C LCD) and install it.

Step 3: Arduino Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>

#define DHTPIN 2      // Pin where the DHT11 data pin is connected
#define DHTTYPE DHT11 // Define the sensor type

DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2); // Change 0x27 to 0x3F if needed

void setup() {
    lcd.begin();
    lcd.backlight();
    dht.begin();
}

void loop() {
    float temperature = dht.readTemperature(); // Read temperature in Celsius
    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); // Refresh data every 2 seconds
}

6. Testing and Debugging Tips

  • If the LCD does not display text, check:
    • Contrast adjustment (via potentiometer if using a non-I2C LCD).
    • I2C address (change 0x27 to 0x3F in the code if needed).
  • If temperature and humidity show nan (not a number):
    • Ensure the correct DHT pin is used.
    • Check if the DHT sensor is receiving power.

7. Extensions and Improvements

  • Add a Buzzer: Sound an alarm if the temperature/humidity exceeds a certain threshold.
  • Data Logging: Save temperature and humidity data to an SD card for analysis.
  • Wireless Transmission: Use ESP8266 or Bluetooth to send data to a smartphone.
  • OLED Display: Replace the 16×2 LCD with an OLED for better visuals.

This project is a great starting point for learning Arduino sensors and displays, and it can be expanded for more advanced applications like IoT-based weather stations. Happy building!