How to interface DHT and LCD with Arduino UNO

This project demonstrates a simple temperature and humidity monitoring system using an Arduino, a DHT11 sensor, and a Liquid Crystal Display (LCD). It measures real-time temperature and humidity and displays the data on an LCD screen. The project is ideal for beginners interested in environmental monitoring.

Key Features:

  1. DHT11 Sensor Integration:

    • The DHT11 sensor reads temperature (in degrees Celsius) and relative humidity values.
  2. LCD Display:

    • A 16x2 Liquid Crystal Display shows the temperature and humidity values in a user-friendly format.
  3. Temperature Threshold:

    • A predefined threshold value (30°C) can be utilized to implement conditional alerts or actions in the future.
  4. Serial Monitoring:

    • Data is also transmitted to the Serial Monitor, enabling debugging and extended functionality.

Components Required:

  • Arduino Board (e.g., Uno or Mega)
  • DHT11 Sensor
  • 16x2 LCD with I2C or pin-based connection
  • Jumper wires
  • Breadboard

Working:

  1. The DHT11 sensor continuously measures temperature and humidity.
  2. These values are sent to the Arduino and displayed on the LCD.
  3. The Serial Monitor logs the sensor readings for additional verification.

This project is a practical way to learn about sensors, displays, and basic Arduino programming, and it can be further expanded for IoT applications or home automation systems.

Schematic:



Schematic



Lcd wiring


Code:

#include <Wire.h>
#include <LiquidCrystal.h>
#include <DHT.h>
#define DHTTYPE DHT11  
#define DHTPIN  A0       // DHT11 sensor is used
DHT dht11(DHTPIN, DHTTYPE);  // configure DHT library


LiquidCrystal lcd(12, 11, 5, 4, 3, 2, 10, 9, 8, 7);

const int THRESHOLD = 30; // Temperature threshold


void setup() {
  Wire.begin(); // Join I2C bus with address #8
  Serial.begin(9600);
  dht11.begin(); // Initialize serial for debugging
  lcd.begin(16, 2);  
}

void loop() {
  byte RH = dht11.readHumidity();
  // read temperature in degree Celsius
  byte Temp = dht11.readTemperature();

  Serial.println(RH);
  Serial.println(Temp);
  delay(100); // Nothing to do in the main loop
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("T=");
  lcd.setCursor(5, 0);
  lcd.print(Temp);
  lcd.setCursor(0, 1);
  lcd.print("H=");
  lcd.setCursor(5, 1);
  lcd.print(RH);
  delay(2000);

 

}




Link:

https://drive.google.com/file/d/12lKgOUsaQ5QA98qq2Qc9sck5EctAbQjE/view?usp=drive_link


Comments