Skip to content

Measure temperature/humidity using DHT11 + LCD i2c + Arduino

 

Hello here,

Before proceeding, if you need to buy DHT11 sensor, check Seeedstudio by clicking here !

In this tutorial we gonna see how to simply use the DHT11 module, It’s a module that can measure ambient temperature 0-50°C and humidity up to 95% RH (Relative humidity), it’s very good for Home Automation projects or DIY projects for daily use.

Also there are a lot of modules that have the same function as this one, you can check them here:

For this we gonna need:

  • DHT 11 (obvious 😃 ) note here that I’m using 3 pins version there are 4 pins one.
2 Versions of DHT11 sensor
  • Arduino board here I’ll use Uno
  • LCD i2c screen
  • Breadboard and jump wires

The LCD i2c is totally optional but usually used with this module as a classic learning project, in case you don’t know how to use one check here:LCD i2c tutorial.

The LCD I used is a I2C version, there are the standard versions but they require a lot of pins, and also in this case you’ll need another library and code functions.

 

Wiring:

DHT11 (3 pins version) wired with LCD i²c and an Arduino

 

Libraries:

DHT library: Download library here

LCD i2c New_Liquid_Crystal library: Download LCD i2c library here

 

Codes

You can download the codes: Download codes here or check below:

Code 1:

The code 1 works with the Serial monitor, it shows the ambient temperature in °C and humidity in %RH, and refresh every 1s.

 

Code2:

The second code works with LCD i²c screen, it shows both temperature and humidity over there.

 

Yassine View All

Automation and Electrical Engineer, Electronics amateur trying to share my little projects.

14 thoughts on “Measure temperature/humidity using DHT11 + LCD i2c + Arduino Leave a comment

    • Hi, if you’re talking about the libraries they’re in .ZIP format just go to Arduino IDE -> Sketch -> Include library -> Add .ZIP library and look for the library file and it will install.
      For the codes just extract the .RAR file and you’ll find codes .INO there.

  1. Arduino: 1.8.3 (Windows 10), Board: “Arduino/Genuino Uno”

    DHT11_LCD:24: error: expected ‘)’ before numeric constant

    LiquidCrystal_I2C lcd ( I2C_ADDR 0x27 ,En_pin 2 ,Rw_pin 1 ,Rs_pin 0 ,D4_pin 4 ,D5_pin 5 ,D6_pin 6 ,D7_pin7 ) ;

    ^

    DHT11_LCD:24: error: expected ‘)’ before numeric constant

    LiquidCrystal_I2C lcd ( I2C_ADDR 0x27 ,En_pin 2 ,Rw_pin 1 ,Rs_pin 0 ,D4_pin 4 ,D5_pin 5 ,D6_pin 6 ,D7_pin7 ) ;

    ^

    DHT11_LCD:24: error: expected ‘)’ before numeric constant

    LiquidCrystal_I2C lcd ( I2C_ADDR 0x27 ,En_pin 2 ,Rw_pin 1 ,Rs_pin 0 ,D4_pin 4 ,D5_pin 5 ,D6_pin 6 ,D7_pin7 ) ;

    ^

    DHT11_LCD:24: error: expected ‘)’ before numeric constant

    LiquidCrystal_I2C lcd ( I2C_ADDR 0x27 ,En_pin 2 ,Rw_pin 1 ,Rs_pin 0 ,D4_pin 4 ,D5_pin 5 ,D6_pin 6 ,D7_pin7 ) ;

    ^

    DHT11_LCD:24: error: expected ‘)’ before numeric constant

    LiquidCrystal_I2C lcd ( I2C_ADDR 0x27 ,En_pin 2 ,Rw_pin 1 ,Rs_pin 0 ,D4_pin 4 ,D5_pin 5 ,D6_pin 6 ,D7_pin7 ) ;

    ^

    DHT11_LCD:24: error: expected ‘)’ before numeric constant

    LiquidCrystal_I2C lcd ( I2C_ADDR 0x27 ,En_pin 2 ,Rw_pin 1 ,Rs_pin 0 ,D4_pin 4 ,D5_pin 5 ,D6_pin 6 ,D7_pin7 ) ;

    ^

    DHT11_LCD:24: error: expected ‘)’ before numeric constant

    LiquidCrystal_I2C lcd ( I2C_ADDR 0x27 ,En_pin 2 ,Rw_pin 1 ,Rs_pin 0 ,D4_pin 4 ,D5_pin 5 ,D6_pin 6 ,D7_pin7 ) ;

    ^

    DHT11_LCD:24: error: ‘D7_pin7’ was not declared in this scope

    LiquidCrystal_I2C lcd ( I2C_ADDR 0x27 ,En_pin 2 ,Rw_pin 1 ,Rs_pin 0 ,D4_pin 4 ,D5_pin 5 ,D6_pin 6 ,D7_pin7 ) ;

    ^

    D:\DHT11_LCD\DHT11_LCD.ino: In function ‘void setup()’:

    DHT11_LCD:33: error: ‘class LiquidCrystal_I2C’ has no member named ‘setBacklightPin’

    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);

    ^

    DHT11_LCD:33: error: ‘POSITIVE’ was not declared in this scope

    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);

    ^

    Multiple libraries were found for “dht.h”
    Used: C:\Users\User\Documents\Arduino\libraries\DHT
    Not used: C:\Users\User\Documents\Arduino\libraries\DHTLib
    exit status 1
    expected ‘)’ before numeric constant

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

    • Hello, first please read that you have multiple DHT libraries !!! So use only one and delete the other

      Multiple libraries were found for “dht.h”
      Used: C:\Users\User\Documents\Arduino\libraries\DHT
      Not used: C:\Users\User\Documents\Arduino\libraries\DHTLib

  2. what the fuck is this why i have to use this web side just post the code no need to download the code
    i don’t trust you . sorry bud but it can be a virus

Leave a Reply

%d bloggers like this: