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

How to Measure and Monitor Humidity Using Arduino

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:

  1. Components Required:

    • Arduino Uno or any compatible board
    • DHT11 or DHT22 humidity and temperature sensor
    • Jumper wires
    • Breadboard
    • USB cable to connect Arduino to a computer
  2. Wiring the Sensor:

    • Connect the VCC pin of the DHT sensor to the 5V pin on the Arduino.
    • Connect the GND pin of the DHT sensor to the GND pin on the Arduino.
    • Connect the data pin of the DHT sensor to digital pin 2 on the Arduino.
  3. 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");
    }
  4. Uploading the Code:

    • Connect your Arduino board to your computer using the USB cable.
    • Open the Arduino IDE, paste the code, and upload it to your Arduino board.
    • Open the Serial Monitor (Tools -> Serial Monitor) to view the humidity and temperature readings.
  5. Explanation:

    • The DHT library provides functions to read humidity and temperature from the sensor.
    • The readHumidity() function returns the current humidity as a percentage.
    • The readTemperature() function returns the current temperature in Celsius.
    • The data is printed to the Serial Monitor for real-time monitoring.

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.