Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based Temperature and Humidity Monitor with I2C LCD Display and Buzzer

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Temperature and Humidity Monitor with I2C LCD Display and Buzzer

Circuit Documentation

Summary

This circuit involves an Arduino UNO microcontroller interfacing with an I2C LCD 16x2 screen, a KY-015 DHT11 temperature and humidity sensor, and a Piezo Buzzer. The Arduino UNO reads temperature and humidity data from the DHT11 sensor and displays it on the LCD screen. Additionally, the Piezo Buzzer can be used for audible alerts.

Component List

Arduino UNO

I2C LCD 16x2 Screen

KY-015 DHT11

Piezo Buzzer

Wiring Details

Arduino UNO

I2C LCD 16x2 Screen

KY-015 DHT11

Piezo Buzzer

Code Documentation

Arduino UNO Code

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

// Set up the LCD display with I2C address (usually 0x27) and 16x2 character size
LiquidCrystal_I2C lcd(0x27, 16, 2);

// DHT sensor setup
#define DHTPIN 2           // Pin connected to the DHT11 data pin
#define DHTTYPE DHT11      // Use DHT11 sensor (can be changed to DHT22 if using a DHT22 sensor)

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // Initialize the LCD and turn on the backlight
  lcd.begin(16, 2);  // Corrected to include the number of columns and rows
  lcd.backlight();

  // Start the DHT sensor
  dht.begin();

  // Print initial message
  lcd.setCursor(0, 0);    // Set cursor to column 0, row 0
  lcd.print("Temp & Humidity");
  delay(2000);
  lcd.clear();
}

void loop() {
  // Read temperature in Celsius
  float temperature = dht.readTemperature();
  // Read humidity percentage
  float humidity = dht.readHumidity();

  // Check if the readings are valid (i.e., not NaN)
  if (isnan(temperature) || isnan(humidity)) {
    lcd.setCursor(0, 0);
    lcd.print("Error reading");
    lcd.setCursor(0, 1);
    lcd.print("sensor data");
    return;
  }

  // Display the temperature on the LCD
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print(" C");

  // Display the humidity on the LCD
  lcd.setCursor(0, 1);
  lcd.print("Hum: ");
  lcd.print(humidity);
  lcd.print(" %");

  // Delay for a second before refreshing data
  delay(1000);
}

This code initializes the I2C LCD and the DHT11 sensor, reads temperature and humidity data, and displays the readings on the LCD screen. If the sensor data is invalid, an error message is displayed. The loop continuously updates the display with new readings every second.