DHT11

Components and supplies :-

  1. DHT11 Temperature & Humidity Sensor (3 pins)
  2. Arduino UNO
  3. Breadboard (generic)
  4. Jumper wires (generic)

Apps and platforms:

  1. Arduino IDE

Project description :-

Ever wanted to know the temperature and humidity around you? If yes, this project will be very helpful for you. If no, it’ll be cool anyway. What I mean is, you can use this in anything from home automations to smart watches.

What is humidity?

Humidity is the water vapor around you mixed with air. It is measured in per cents. So, if the humidity is 60 per cent(which is the average humidity), then 60 per cent of the air around you is water vapor. If it is 100%, then it means either the sensor is not correct, the sensor is broken/damaged, the Arduino crashed, the Arduino can’t receive any signal, there’s an error in the code or you’re  underwater *. If it’s 0%, it means all the reasons above except the last one, you’re in space or you’re in the middle of a desert**.

* Correction: it means the air cannot hold any more water.

**  The air in a desert does  contain some  water but it is a very little amount compared to a normal place. The Sahara Desert has a mean humidity of 25%.

My sensor has 3 pins and it’s fitted on a board. If yours has 4 pins, then you need to build this circuit after the sensor:

Then, build the circuit!

Details about the code

You need to follow these instructions to make it work:

  1. You need to add the library to the Arduino IDE.
  2. Upload the code.
  3. When the code is uploaded, open the Serial Monitor and set the baud rate to 9600.
  4. You will see the humidity and temperature.

Code:

1 #include <dht11.h>
2 #define DHT11PIN 4
3
4 dht11 DHT11;
5
6 void setup()
7 {
8 Serial.begin(9600);
9
10 }
11
12 void loop()
13 {
14 Serial.println();
15
16 int chk = DHT11.read(DHT11PIN);
17
18 Serial.print("Humidity (%): ");
19 Serial.println((float)DHT11.humidity, 2);
20
21 Serial.print("Temperature   (C): ");
22 Serial.println((float)DHT11.temperature, 2);
23
24 delay(2000);
25
26 }