Arduino Tutorials – Lesson 16 – Humidity Sensor Using Arduino UNO

Creating Humidity Sensor program using Arduino UNO

Required Components

  1. Humidity Sensor(DHT22) -1 no
  2. Arduino UNO -1 no
  3. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Humidity Sensor to the Arduino UNO board.
  3. Connect the Arduino UNO board 2nd pin to the Humidity Sensor.
  4. Connect Humidity Sensor board VCC, GND to 5V, GND of Arduino Uno Board.
  5. Check the Cicuit Connections.
  6. Check the Arduino program.
  7. Run the Arduino program.

Arduino Program

#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

void setup() 
{
  Serial.begin(9600);
  Serial.println("DHTxx test!");
  dht.begin();
}

void loop( )
{
  delay(2000);
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);
  if (isnan(h) || isnan(t) || isnan(f)) 
  {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  float hif = dht.computeHeatIndex(f, h);
  float hic = dht.computeHeatIndex(t, h, false);
  Serial.print ("Humidity: ");
  Serial.print (h);
  Serial.print (" %\t");
  Serial.print ("Temperature: ");
  Serial.print (t);
  Serial.print (" *C ");
  Serial.print (f);
  Serial.print (" *F\t");
  Serial.print ("Heat index: ");
  Serial.print (hic);
  Serial.print (" *C ");
  Serial.print (hif);
  Serial.println (" *F");
}

Usage

  1. Industrial process &control systems
  2. Office automation
  3. Clothes dryer
  4. Microwave ovens
  5. Printers

Leave a Reply

Your email address will not be published. Required fields are marked *