Devices & Components
Arduino Uno Rev3
Male to male wires
DHT11 Temperature & Humidity Sensor (4 pins)
I2C LCD
Breadboard (generic)
Software & Tools
Arduino IDE
Project description
Code
This is the code to print DHT sensor value on the LCD screen
c_cpp
This is same code but difference is that we will print DHT sensor value on the I2C LCD.
1#include <dht.h> 2#include <LiquidCrystal_I2C.h> 3 4LiquidCrystal_I2C lcd = liquidCrystal_I2C(0x27, 20, 4) 5 6dht DHT; 7 8#define DHT11_PIN 7 9 10void setup(){ 11 lcd.init(); // initialise I2C LCD 12 lcd.backlight(); // Turn On the backlight of the I2C LCD 13} 14 15void loop(){ 16 int chk = DHT.read11(DHT11_PIN); 17 lcd.setCursor(0,0); 18 lcd.print("Temp: "); 19 lcd.print(DHT.temperature); 20 lcd.print((char)223); 21 lcd.print("C"); 22 lcd.setCursor(0,1); 23 lcd.print("Humidity: "); 24 lcd.print(DHT.humidity); 25 lcd.print("%"); 26 delay(1000); 27}
Connecting DHT11 to Arduino with serial monitor.
c_cpp
In this code we are using serial monitor to print temperature and humidity sensor.
1#include <dht.h> // You have to download this liibrary. NAME: dht library 2 3dht DHT; 4 5#define DHT11_PIN 7 // define DHT pin 6 7void setup(){ 8 Serial.begin(9600); // Start serial communication 9} 10 11void loop(){ 12 int chk = DHT.read11(DHT11_PIN); // check the data coming from the DHT pin 13 Serial.print("Temperature = "); // print temperature on the serial monitor 14 Serial.println(DHT.temperature); 15 Serial.print("Humidity = ");// Print humidity on the serial monitor 16 Serial.println(DHT.humidity); 17 delay(1000); // delay of 1 second 18} 19 20 21 /*Here are the connections 22 23 Take a DHT11 sensor. 24 there, in the DHT11 sensor, there are 3 or 4 pins. 25 There, on the DHT11 sensor, there is writen S, +, - 26 connect "S" on the digital pin 7. 27 connect "+" on the 5V pin on Arduino. 28 connect "-" on the GND pin on Arduino. 29 30 Thank you 31 Meet you in the next project. 32 */ 33 34
Connecting DHT11 to Arduino with serial monitor.
c_cpp
In this code we are using serial monitor to print temperature and humidity sensor.
1#include <dht.h> // You have to download this liibrary. NAME: dht library 2 3dht 4 DHT; 5 6#define DHT11_PIN 7 // define DHT pin 7 8void setup(){ 9 Serial.begin(9600); 10 // Start serial communication 11} 12 13void loop(){ 14 int chk = DHT.read11(DHT11_PIN); 15 // check the data coming from the DHT pin 16 Serial.print("Temperature = "); 17 // print temperature on the serial monitor 18 Serial.println(DHT.temperature); 19 20 Serial.print("Humidity = ");// Print humidity on the serial monitor 21 Serial.println(DHT.humidity); 22 23 delay(1000); // delay of 1 second 24} 25 26 27 /*Here are the connections 28 29 30 Take a DHT11 sensor. 31 there, in the DHT11 sensor, there 32 are 3 or 4 pins. 33 There, on the DHT11 sensor, there is writen S, +, - 34 35 connect "S" on the digital pin 7. 36 connect "+" on the 5V pin on 37 Arduino. 38 connect "-" on the GND pin on Arduino. 39 40 Thank 41 you 42 Meet you in the next project. 43 */ 44 45
Downloadable files
This is the connection of DHT11 sensor with Arduino UNO
Connect DHT11 sensor with Arduino using this diagram but this only for reference. You have to make connection as commented in the code.
This is the connection of DHT11 sensor with Arduino UNO

This is the connection of DHT11 sensor with Arduino UNO
Connect DHT11 sensor with Arduino using this diagram but this only for reference. You have to make connection as commented in the code.
This is the connection of DHT11 sensor with Arduino UNO

Comments
Only logged in users can leave comments