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.
You will need the following:
- Arduino Uno
- Breadboard
- LCD module
- DHT11
- Potentiometer
- 220 ohm resistor
- 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:
- Arduino GND to breadboard negative power rail
- Arduino 5v to breadboard positive power rail
- DHT11 positive pin to breadboard positive power rail
- DHT11 negative pin to breadboard negative power rail
- DHT11 S pin to Arduino Analog A0 // this feeds data from DHT11 to Arduino
- LCD 1 to breadboard negative power rail
- LCD 2 to breadboard positive power rail
- LCD 3 to potentiometer centre pin // this helps to change the LCD brightness
- LCD 4 to Arduino Digital Pin 12 // Arduino sends LCD data (LCD character coordinates)
- LCD 5 to breadboard negative power rail
- LCD 6 to Arduino Digital Pin 11 // Arduino sends LCD data (LCD initiate command)
- LCD 11 to Arduino Digital Pin 5 // Arduino sends LCD data
- LCD 12 to Arduino Digital Pin 4 // Arduino sends LCD data
- LCD 13 to Arduino Digital Pin 3 // Arduino sends LCD data
- LCD 14 to Arduino Digital Pin 2 // Arduino sends LCD data
- LCD 15 to 220 ohm resistor and then the same 220 ohm resistor to breadboard positive power rail
- LCD 16 to breadboard negative power rail
- Potentiometer positive pin to breadboard positive power rail
- Potentiometer negative pin to breadboard negative power rail
The 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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#include <LiquidCrystal.h> #include <dht.h> 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); } |
You should see the LCD displaying temperature and humidity data now.
Pingback: Guide: Arduino + DHT11 output to LCD - VISUALS+CODE
would love to see this with multi dht11 and a button to toggle between them.
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
The compiler can’t find the dht.h library. You’ll need to check that the necessary files are present in your Arduino/libraries folder. You should see dht.cpp and dht.h in that folder.
delete dht_u
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
}
why there are only include commands with no libraries
it does not work.
It works for me at once! Thanks a lot.
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()
{
Why don’t shows tempereture under 0 degres?
The DHT11 only senses values of temperature within the range of 0-50 degrees celcius
Try a different DHT….like the 22,for negative readings.
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.
You can get the files from here: https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib — dht.cpp and dht.h are the important ones.
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.
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.
Use a 10k for the contrast
uso da poco arduino, non so come si scarica la libreria, qualcuno può aiutarmi?
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
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
Hellow I connected dht eleven with arduino and display -999 for temperature and humidity
Please use something like fritzing to make your schematics.
There were too many errors with the Arduino compiler/verify even with 2 of the included dht libraries
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);
}
#include wrong
#include correct
dht sensor; wrong
dht11 sensor correct
sensor.read11(greenPin); wrong
sensor.read(greenPin); correct this is important
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.
try changing
from/home/brucez/Arduino/libraries/DHT_sensor_library/DHT_U.h:2
To
#include dht11();
Keith
#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
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
How can i solve the compile error for arduino………………………..