Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Humidity is an important environmental parameter that can affect various processes and comfort levels in both industrial and domestic settings. Using an Arduino, you can easily measure and monitor humidity levels by interfacing with sensors like the DHT11 or DHT22. This article will guide you through the steps to set up a humidity monitoring system using Arduino.
Examples:
Components Required:
Wiring the Sensor:
Arduino Code: To read data from the DHT sensor, you will need to use the DHT library. You can install it via the Arduino IDE library manager.
#include <DHT.h>
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT11 or DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
delay(2000); // Wait a few seconds between measurements
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" *C");
}
Uploading the Code:
Explanation:
readHumidity()
function returns the current humidity as a percentage.readTemperature()
function returns the current temperature in Celsius.