Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

Building a Smart Home Temperature Monitor with Arduino

In this article, we will explore how to create a smart home temperature monitor using an Arduino microcontroller. This project is crucial for anyone interested in home automation, as it allows for real-time temperature monitoring and control. By integrating a temperature sensor with an Arduino, we can gather temperature data and display it on an LCD screen. Additionally, we can set up alerts for specific temperature thresholds. This project is designed to be beginner-friendly and is a great way to get started with Arduino and microcontroller projects.

Project: The objective of this project is to create a smart temperature monitoring system that displays the current temperature on an LCD screen and triggers an alert when the temperature exceeds a predefined threshold. The functionalities include:

  • Reading temperature data from a sensor.
  • Displaying the temperature on an LCD screen.
  • Triggering an LED alert if the temperature goes beyond a set limit.

Components List:

  • Arduino Uno (1)
  • DHT11 Temperature and Humidity Sensor (1)
  • 16x2 LCD Display with I2C Module (1)
  • LED (1)
  • 220-ohm Resistor (1)
  • Breadboard (1)
  • Jumper Wires (various)

Examples: Below is the Arduino code for the smart home temperature monitor project. The code reads temperature data from the DHT11 sensor, displays it on the LCD, and turns on an LED if the temperature exceeds 30°C.

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

// Define the DHT sensor type and pin
#define DHTTYPE DHT11
#define DHTPIN 2

// Initialize the DHT sensor
DHT dht(DHTPIN, DHTTYPE);

// Initialize the LCD with I2C address 0x27 and 16x2 characters
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Define the LED pin
const int ledPin = 13;

// Set the temperature threshold
const float tempThreshold = 30.0;

void setup() {
  // Start the serial communication
  Serial.begin(9600);

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

  // Initialize the LCD
  lcd.begin();
  lcd.backlight();

  // Set the LED pin as output
  pinMode(ledPin, OUTPUT);

  // Display a welcome message
  lcd.setCursor(0, 0);
  lcd.print("Temp Monitor");
  delay(2000);
  lcd.clear();
}

void loop() {
  // Read temperature as Celsius
  float temp = dht.readTemperature();

  // Check if the reading is valid
  if (isnan(temp)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Print the temperature to the serial monitor
  Serial.print("Temperature: ");
  Serial.print(temp);
  Serial.println(" *C");

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

  // Check if the temperature exceeds the threshold
  if (temp > tempThreshold) {
    // Turn on the LED
    digitalWrite(ledPin, HIGH);
  } else {
    // Turn off the LED
    digitalWrite(ledPin, LOW);
  }

  // Wait for 2 seconds before the next reading
  delay(2000);
}

Code Explanation:

  • Libraries: The code includes libraries for the DHT sensor (DHT.h) and the LCD (LiquidCrystal_I2C.h).
  • Initialization: The DHT sensor and LCD are initialized in the setup() function. The LED pin is set as an output.
  • Reading Temperature: The loop() function reads the temperature from the DHT sensor and checks if the reading is valid.
  • Displaying Temperature: The temperature is displayed on the LCD screen.
  • Temperature Alert: If the temperature exceeds the threshold, the LED is turned on; otherwise, it is turned off.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.