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

DHT11+Sensor: Temperature and Humidity Monitoring with Arduino

Importance and Utility of DHT11+Sensor

The DHT11 sensor is a popular choice for temperature and humidity monitoring in various applications. It provides a cost-effective solution with reliable performance, making it suitable for both hobbyist and professional projects. By using the DHT11 sensor with Arduino, you can easily measure and monitor temperature and humidity levels in real-time.

Project: Temperature and Humidity Monitoring with DHT11 Sensor

In this project, we will create a temperature and humidity monitoring system using the DHT11 sensor and Arduino. The objectives of this project are to:

  1. Measure and display real-time temperature and humidity readings.
  2. Provide a user-friendly interface to view the data.
  3. Implement an alert system for abnormal temperature or humidity levels.

List of Components:

  1. Arduino Uno - 1x
  2. DHT11 Sensor - 1x
  3. Breadboard - 1x
  4. Jumper Wires - Male to Male - 10x
  5. 10k Ohm Resistor - 1x

You can find these components at the following links:

  • Arduino Uno: [Link to purchase]
  • DHT11 Sensor: [Link to purchase]
  • Breadboard: [Link to purchase]
  • Jumper Wires: [Link to purchase]
  • 10k Ohm Resistor: [Link to purchase]

Examples:

Example 1: Reading Temperature and Humidity Values

#include <DHT.h>

#define DHTPIN 2          // Pin connected to the DHT sensor
#define DHTTYPE DHT11     // DHT sensor type

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  dht.begin();
}

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

  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.print(" °C");

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.print(" %");

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

Explanation:

  • The code starts by including the DHT library and defining the pin and sensor type.
  • In the setup() function, the serial communication is initialized, and the DHT sensor is also initialized.
  • The loop() function reads the temperature and humidity values from the sensor using the readTemperature() and readHumidity() functions, respectively.
  • The values are then printed to the serial monitor with appropriate labels.
  • A delay of 2 seconds is added before taking the next reading.

Example 2: Alert System for Abnormal Temperature

#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  dht.begin();
}

void loop() {
  float temperature = dht.readTemperature();

  if (temperature > 30) {
    Serial.println("High temperature detected!");
    // Add your alert mechanism here, e.g., sending an email or activating a buzzer
  }

  delay(2000);
}

Explanation:

  • This example extends the previous code by adding an alert system for high temperature readings.
  • If the temperature exceeds 30°C, a message is printed to the serial monitor.
  • You can add your own alert mechanism, such as sending an email or activating a buzzer, to notify the user about the high temperature.

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.