Arduino and DHT11 output to LCD module

facebooktwittergoogle_plusredditpinterestlinkedintumblrmail

In this experiment, I wanted to hook up a DHT11 temperature and humidity detector module to the Arduino Uno, and output the temp and humidity data to an LCD module. I’ve provided wiring diagrams, code and guidance below, in case anyone is curious.

arduino_dht11_lcd

You will need the following:

  1. Arduino Uno
  2. Breadboard
  3. LCD module
  4. DHT11
  5. Potentiometer
  6. 220 ohm resistor
  7. A bunch of connectors. If you have no female connectors, you can push the DHT11 straight into the breadboard and make connections from there.

The first thing is the wiring diagram, which is a bit hard to follow, so I’ll add some text to explain which connectors go where:

  1. Arduino GND to breadboard negative power rail
  2. Arduino 5v to breadboard positive power rail
  3. DHT11 positive pin to breadboard positive power rail
  4. DHT11 negative pin to breadboard negative power rail
  5. DHT11 S pin to Arduino Analog A0 // this feeds data from DHT11 to Arduino
  6. LCD 1 to breadboard negative power rail
  7. LCD 2 to breadboard positive power rail
  8. LCD 3 to potentiometer centre pin // this helps to change the LCD brightness
  9. LCD 4 to Arduino Digital Pin 12 // Arduino sends LCD data (LCD character coordinates)
  10. LCD 5 to breadboard negative power rail
  11. LCD 6 to Arduino Digital Pin 11 // Arduino sends LCD data (LCD initiate command)
  12. LCD 11 to Arduino Digital Pin 5 // Arduino sends LCD data
  13. LCD 12 to Arduino Digital Pin 4 // Arduino sends LCD data
  14. LCD 13 to Arduino Digital Pin 3 // Arduino sends LCD data
  15. LCD 14 to Arduino Digital Pin 2 // Arduino sends LCD data
  16. LCD 15 to 220 ohm resistor and then the same 220 ohm resistor to breadboard positive power rail
  17. LCD 16 to breadboard negative power rail
  18. Potentiometer positive pin to breadboard positive power rail
  19. Potentiometer negative pin to breadboard negative power rail

The diagram:

DHT11_arduino_lcd_wiring_diagram

Next, to get the code for the DHT11 bits working, you need to grab and install a DHT11 library: http://playground.arduino.cc/Main/DHTLib which has a folder you will place into your Arduino/libraries folder.

Upload the following code to your Arduino:

 

You should see the LCD displaying temperature and humidity data now.

29 Comments

  1. Pingback: Guide: Arduino + DHT11 output to LCD - VISUALS+CODE

  2. would love to see this with multi dht11 and a button to toggle between them.

  3. dht sensor;
    why is this part of program not getting compiled
    i have project on this topic and problem was that program use to compile on some and use to show
    C:\Users\Danish\Documents\Arduino\trial_program_temp_humid_9-6-16\trial_program_temp_humid_9-6-16.ino:3:17: fatal error: dht.h: No such file or directory

    #include

    ^

    compilation terminated.

    exit status 1
    Error compiling for board Arduino/Genuino Uno.
    this error on most of pc it even show such on mine pc i have include library as u said but problem remains plz help

  4. Hello, i have a problem,i installed the libraries and conected evereything up as you said but it says humidity 0.00 and temp 0.00
    how can i fix this?
    sincerly

    • Here is the simple code that will make it work correctly. I had the same issue and just figured it out. I put some comments about the changes I made and stuff I figured out…. Make sure you have the 3 libraries that are noted “#include”

      // ***** Works for temp and humid display on LCD I2C 7/3/2016 *****

      // Shows Farhenheit, Celsius & Humidity

      #include
      #include
      #include

      //For LCD display 2 rows x 16 Characters
      //For LCD with built in controller
      //LCD pin SDA to Arduino Analog pin A4
      //LCD pin SCL to Arduino Analog pin A5
      //LCD power is 5V

      //DHT11 Temp and humidity sensor in Celsius
      //Signal wire of DHT11 to Arduino Digital pin 8
      //DHT11 sensor power is 5V (middle pin on sensor)

      LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
      dht DHT;

      /*—–( Declare Constants, Pin Numbers )—–*/

      #define DHT11_PIN 8 //DHT11 Signal wire to pin 8

      void setup()
      {
      lcd.begin(16,2); //16 by 2 character display
      }

      void loop()
      {
      delay(1000); //wait a sec (recommended for DHT11)
      int chk = DHT.read11(DHT11_PIN);
      switch (chk)

      lcd.clear(); //Clears any previous message on LCD

      //Print temp on line 1 (use 0 to indicate line 1)
      //(0,0) indicates (Character position from left, Row 0=1 1=2)
      lcd.setCursor(0,0); //next print line shows on LCD line 1
      lcd.print(“Temp= “);
      lcd.print(DHT.temperature, 0);
      lcd.print(” C “);
      lcd.print(DHT.temperature * 1.8 + 32, 0); //Farhenheit conversion
      lcd.print(” F “);

      //Print Humidity on line 2 (use 1 to indicate line 2)
      //(0,1) indicates (Character position from left, Row 0=1 1=2)
      lcd.setCursor(0,1); //next print line shows on LCD line 2
      lcd.print(“Humidity = “);
      lcd.print(DHT.humidity, 0);
      lcd.print(” %”);

      delay(15000); //Shows data for 15 sec then refreshes screen with next line
      lcd.clear(); //Clears any previous message on LCD
      }

  5. It works for me at once! Thanks a lot.

  6. Not is corect thist sketch. have a problem whit dht sensor
    #include
    #include

    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
    int greenPin = A0;
    DHT sensor; this have problem

    void setup()
    {

  7. Why don’t shows tempereture under 0 degres?

  8. Hello, I’m a beginner in Arduino so I wanted to try out some simple projects. I hooked up everything correctly, but I need help on ‘ grab and install a DHT11 library’ I went to the link but I couldn’t find out how to grab/install. Please help.

  9. The easiest way to change it to F, is this:

    On the line
    lcd.print(sensor.temperature);

    change it to
    lcd.print(sensor.temperature * 1.8+32);

    That’s it.

  10. Please help me someone i have a Potentiometer mono 50k and a Potentiometer mono 100k , which of the two is best to use it in the diagram above, or if none is good what specifications must have a potentiometer as the picture.

    Please help me.

  11. uso da poco arduino, non so come si scarica la libreria, qualcuno può aiutarmi?

  12. Please admin or who made this project my display doesn’t start what is wrong , and please tell mel how i eliminate the potentiometer and i see in second picture are 2 wires missing like in first photo.

    Please help meeeeeee

  13. Hi I’m new to this. I don’t no how to copy the library files to arduinodroid. I’ve copied them into 2 files in the library but I’m still getting error messages am I supposed to put all 3 codes into 1 sketch? Please help. I haven’t a clue lol

  14. issashaib42@gmail.com

    Hellow I connected dht eleven with arduino and display -999 for temperature and humidity

  15. Please use something like fritzing to make your schematics.

  16. There were too many errors with the Arduino compiler/verify even with 2 of the included dht libraries

  17. I found an error

    #include
    #include

    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
    int greenPin = A0;
    dht11 sensor;

    void setup()
    {
    lcd.begin(16,2); //16 by 2 character display
    }

    void loop()
    {
    delay(1000); //wait a sec (recommended for DHT11)
    sensor.read(greenPin);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(“Humidity = “);
    lcd.print(sensor.humidity);
    lcd.setCursor(0,1);
    lcd.print(“Temp = “);
    lcd.print(sensor.temperature);

    }

  18. #include wrong
    #include correct

    dht sensor; wrong
    dht11 sensor correct

    sensor.read11(greenPin); wrong
    sensor.read(greenPin); correct this is important

  19. I got an error message.
    Arduino: 1.8.8 (Linux), Board: “Arduino/Genuino Uno”

    In file included from /home/brucez/Arduino/libraries/DHT_sensor_library/DHT_U.cpp:22:0:
    /home/brucez/Arduino/libraries/DHT_sensor_library/DHT_U.h:25:29: fatal error: Adafruit_Sensor.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.
    Please help. I don’t know what to do.

  20. try changing
    from/home/brucez/Arduino/libraries/DHT_sensor_library/DHT_U.h:2
    To
    #include dht11();

    Keith

  21. #include
    #include

    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
    int greenPin = A0;
    dht sensor;

    void setup()
    {
    lcd.begin(16,2); //16 by 2 character display
    }

    void loop()
    {
    delay(1000); //wait a sec (recommended for DHT11)
    sensor.read11(greenPin);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(“Humidity = “);
    lcd.print(sensor.humidity);
    lcd.setCursor(0,1);
    lcd.print(“Temp = “);
    lcd.print(sensor.temperature);
    }

    can i use the same code and connections for the display 20×4-line-lcd-display

  22. What is the difference between Arduino and micro controller, I interfaced Arduino to LCD only 4 data lines, rs, enable but 8051 micro controller I connected all the data lines to 8051 port what is the difference b/w both controllers ??
    http://bigbelectronics.in/product.php?product=20×4-line-lcd-display-blue-backlight-hd44780-all-arduino-rasp-pi-avr-arm-8051

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">