Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
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:
List of Components:
You can find these components at the following links:
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:
setup()
function, the serial communication is initialized, and the DHT sensor is also initialized.loop()
function reads the temperature and humidity values from the sensor using the readTemperature()
and readHumidity()
functions, respectively.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: