Arduino Temp/Humidity Sensor Using DHT11 and I2C LCD One Day Project

39,279

42

12

Introduction: Arduino Temp/Humidity Sensor Using DHT11 and I2C LCD One Day Project

About: Moroccan, husband, and father. I love technology, traveling, and reading. I've been to many places, and the more I saw the more I realized that what you may think is not always what is right.

I have purchased an Arduino Mega 2560 set which came with some sensors and of course, and Arduino Mega.

In this instructable, I will share with you the steps I took to make an Arduino based temperature and humidity display.

Items required:

  • Arduino Mega 2560
  • LCD1602 IIC I2C

  • DHT11 Temperature/Humidity sensor
  • Breadboard
  • Jumper wires
  • 10K

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: IDE Libraries Required

DHT11 Library is available on https://github.com/adafruit/DHT-sensor-library. You can download the ZIP file and include the library in your IDE.

The I2C LCD was a bit tricky. I took hours to figure out how to get it to work, and I then found F Malpartida's New LiquidCrystal library which was brilliant. This can be downloaded from https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads and added to the IDE.

Step 2: Wiring the LCD, Sensor, and Arduino

Wiring is rather simple. I wired the sensor on a breadboard as per the diagram above. DHT11 needs 3.3 volts and the LCD needs 5 v.

Arduino, LCD, and sesnor Pin Assignments:

  • PIN 12: DHT Data
  • SDA: LCD SDA
  • SCL: LCD SCL
  • 3V3: DHT Power
  • 5V: LCD VCC
  • GND: LCD and DHT Gnd

Step 3: Code

DHT library has a sample code that allows to test the way the sensor to work and display the results in the serial monitor of the IDE.

I2C addresses must be defined in the code to display the results correctly.

The sketch is attached here.

Step 4: You Are Done!

Upload the sketch to your board and you are done!

This code will work with the sensor and screen that I have gotten from AliExpress.com

The LCD code especially was done based on the code provided by turbiny as a comment on this instructable

The end result is as shown in the picture.

4 People Made This Project!

Recommendations

  • Tiny Speed Challenge

    Tiny Speed Challenge
  • Clocks Contest

    Clocks Contest
  • PCB Design Challenge

    PCB Design Challenge

12 Discussions

0
JumaP1
JumaP1

6 months ago

Kindly help i got this error trying to verify the codes

FJ8M1QLIMGLJZAO:14:53: error: 'POSITIVE' was not declared in this scope
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
^
Multiple libraries were found for "LiquidCrystal_I2C.h"
Used: C:\Users\Juma\Documents\Arduino\libraries\LiquidCrystal_I2C-1.1.2
Not used: C:\Users\Juma\Documents\Arduino\libraries\LiquidCrystal
Not used: C:\Users\Juma\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master
Multiple libraries were found for "DHT.h"
Used: C:\Users\Juma\Documents\Arduino\libraries\DHT_sensor_library
Not used: C:\Program Files (x86)\Arduino\libraries\DHT-sensor-library-master
Multiple libraries were found for "Wire.h"
Used: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Not used: C:\Users\Juma\Documents\Arduino\libraries\Wire
exit status 1
'POSITIVE' was not declared in this scope
Invalid library found in C:\Users\Juma\Documents\Arduino\libraries\Blink: no headers files (.h) found in C:\Users\Juma\Documents\Arduino\libraries\Blink
Invalid library found in C:\Users\Juma\Documents\Arduino\libraries\DHTtester: no headers files (.h) found in C:\Users\Juma\Documents\Arduino\libraries\DHTtester
Invalid library found in C:\Users\Juma\Documents\Arduino\libraries\__MACOSX: no headers files (.h) found in C:\Users\Juma\Documents\Arduino\libraries\__MACOSX
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

0
abhinav03m
abhinav03m

7 months ago on Step 3

Guys help me, when I verify the sketch an error message is showing
"expected unqualified-id before numeric constant"
#define DHTPIN 12 gets hilighted b a red color

0
melvinf9
melvinf9

Question 1 year ago on Step 4

i need your help guys.. i will make dht 11 sensor with lcd. and buzzer that can be set the alarm through wifi app..

like.. if the temo is 40 the buzzer sound and i can change the min or max when that buzzer sound like change 40 to. 45. using a button and an app on phone

2
MattiV
MattiV

1 year ago

this library come error alltime positive WAS NOT DECLARE THIS SCOPE. or if delete positive come other int error alltime, not working

0
MarinS11
MarinS11

2 years ago

Thanks for sharing! Works on my Uno, passed my school project with it!

0
sziklazuzo
sziklazuzo

2 years ago

It is necessary to install adafruit sensor library also without you can't compile the sketch and it is a small screw on back front of LCD display. With this small screw can you the display initialise. If the screw isn't in good direction, you will nothing see on display, only the blue background light!

0
BreechC
BreechC

2 years ago

Thanks :) I added a 5 volts dc fan to it, when the temperature rises to a certain temperature then the dc fan will spin until the temperature goes back to normal again.

0
Toxin1
Toxin1

2 years ago

Can i do this on leornardo?

0
Noras20
Noras20

3 years ago

can i have the instructables by email? Thank You.

0
wold630
wold630

3 years ago

Thanks for sharing this project!