Humidity Sensor Basics

by ArjunG32 in Circuits > Arduino

413 Views, 0 Favorites, 0 Comments

Humidity Sensor Basics

IMG_20190909_185520.jpg
IMG_20190909_185508.jpg
IMG_20190909_185452.jpg

This is a basic tutorial on how to use the DHT 11 sensor module with an Arduino board.

Supplies

  1. DHT11 module
  2. Arduino Uno/nano/etc...
  3. Jumper wires
  4. Bread board

Make the Connections

IMG_20190909_185751.jpg
IMG_20190909_185735.jpg
IMG_20190909_185720.jpg
Screenshot (118).png

VCC goes into the 5V port of the arduino

GND goes into one of the Ground(GND) of the arduino

and finally we have the Data pin(the middle pin) which goes into any one of the digital pins(D2-D13)

Code It

Adding Library to arduino
#include<dht.h><br>
dht DHT;
//Set the pin for the DHT sensor
#define DHT11_PIN 6
void setup()
{
  Serial.begin(115200);
  Serial.println("DHT TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");
  Serial.println(DHT_LIB_VERSION);
  Serial.println();
  Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}
void loop()
{
  // DISPLAY DATA
  Serial.print(DHT.humidity, 1);
  Serial.print(",\t");
  Serial.println(DHT.temperature, 1);
  delay(2000);
}
//
// END OF FILE
//

Using the Library DHT.h the coding becomes very easy, and extracting temperature and humidity is a piece of cake

The humidity value is stored in DHT.humidity and temperature in DHT.Temperature. All you have got to do is set the DHT11_PIN to the pin number you have plugged the sensor into

If you need help with including libaries use the above tutorial,hopefully it is helpful.

Downloads

Output