Arduino Tutorials

How to Setup DHT11 Sensor With Arduino

connect dht11 with arduino

Setup DHT11 Sensor With Arduino

Here I am providing complete information about how to setup the dht11 humidity sensor on an Arduino board. For this, you need to include the dht11 library in your Arduino code. Below you can find dht11 Arduino code and dht11 library.

DHT11

DHT11 is a humidity and temperature sensor. It can be used as humidity sensor as well as the temperature sensor. You can find the dht11 sensor of 2 types in the market. One is with 4 pins and another is with 3 pins. In 3 pin dht11 sensor already 10k Ohm resistor is added inside the module. The operating voltage of this module is 3.3V

dht11 pin configuration

Get DHT11 Sensor for Cheap Here

DHT11 LIBRARY

Download DHT11 Library Here

VIDEO TUTORIAL

4 PIN DHT11 CONNECTIONS WITH ARDUINO UNO

4 pin dht11 connections

You need a 10K Ohm pull up resistor to get the proper data from 4 pin dht11 sensor. Pin configuration of this sensor, Left most pin is 3.3V (VCC), the second leftmost pin is output and the right most pin is ground. In the following code the I declared the pin to get reading from the sensor is Digital pin 4 . You need to add 10K Ohm pull up resistor between VCC and Output. You can find the connections in above circuit.

3 PIN DHT11 CONNECTIONS WITH ARDUINO UNO

3 pin dht11 connections

Pin configuration of the dht11 sensor is, the leftmost pin is 3.3V(VCC), the middle pin is output, the rightmost pin is Ground.In the following code, I declared Digital pin 4 to get data from the sensor. So, we need to connect output pin of the dht11 sensor to the digital pin 4 of Arduino. If you have any confusion, you can find the connections in above circuit.

DHT11 ARDUINO CODE

OUTPUT

You can see the output on the serial monitor. To open serial monitor go to Tools > Serial Monitor . Set the baud rate of serial monitor to 9600. The output is updated every second and can observe the changes in Temperature and Humidity.

temeprature and humidity reading

Project: Make Arduino Weather Station with DHT11 Sensor

8 Comments

  • sir, i use the following codes but it didnt work.
    Stated on IDE: error compiling for board Arduino/Genuino Uno
    Why is it like that?

    #include
    dht DHT;
    #define DHT11_PIN 4

    void setup(){
    Serial.begin(9600);
    }

    void loop()
    {
    int d = DHT.read11(DHT11_PIN);
    Serial.print(“Temperature = “);
    Serial.println(DHT.temperature);
    Serial.print(“Humidity = “);
    Serial.println(DHT.humidity);
    delay(1000);
    }

  • Arduino: 1.8.5 (Windows 10), Board: “Arduino/Genuino Uno”

    C:\Users\Fahad\AppData\Local\Temp\arduino_modified_sketch_968848\sketch_may05a.ino:1:16: fatal error: dht.h: No such file or directory

    #include

    ^

    compilation terminated.

    exit status 1
    Error compiling for board Arduino/Genuino Uno.

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

Leave a Reply