Hello Dear Makers, In this tutorial we will learn how to use the DHT11 sensor for measuring temperature and humidity and either heat Index. And we will see the value output of the DHT sensors on both the serial monitor and the LCD screen. we are going to use The LCD screen componen with this tutorial you can also print on a serial monitor on the Desktop IDE. Code and circuit diagram are compatible within both sensors.
Requirements
We need these couples of components in this tutorial,
- DHT11 Sensor Module
- I2C LCD Display 2x16
- Arduino board
- Breadboard
- Jumper wires
- Type b usb cable
Were going to use the I2C LCD to display the Temperature and Humidity that the DHT11 has captured, I used an Arduino UNO 5V pin to support the DHT11 and the I2C display. DHT22 humidity sensor can be used in place of DHT11 for more accuracy and higher resolution. i made a Circuit diagram on fritzing for you to easily follow the wirings.
LCD Connection to arduino
- VCC - 5V
- GND - GND
- SCL - A4
- SDA - A5
DHT11 connection to arduino
- VCC - 3.3V
- GND - GND
- DAT - PIN 2 PWM
SOFTWARE and LIBRARIES
Get started to set up and make a code for this. we are going to use the arduino ide, to set the sketch for this, if you dont have make sure to download the Arduino IDE for your specific operating system. I’ll leave a link to where you can download this software: https://www.arduino.cc/en/Main/Software
After the installation we need to download the DHT11 library for the sensor module Library or you can directly Installed from the Library Manager in Arduino IDE or download on github; https://github.com/adafruit/DHT-sensor-library
We need to download the i2c library To get the i2c 2x16 LCD library download it here: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/ just download the latest one.
PROGRAMMING
when making a code we need to include all the libraries that we have recently downloaded. #include <DHT.h> for DHT
sensor library and #include <LiquidCrystal_I2C.h>
for the i2c 2x16 LCD DISPLAY.
#define DHTPIN 2
Define DHT pin this the pin where the sensor pin of the DHT is connected to the digital pin 2 on the arduino board.
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
Input the i2c address that we recently make.
DHT dht;
define the uppercase DHT to dht in lowercase to recognized that the lower case is the same as upper case on the same state.
setup() method is ran once at the just after the Arduino is powered up and the loop() method is ran continuously afterwards.
setup() is where you want to do any initialisation steps, and in loop() you want to run the code you want to run over and over again.
lcd.begin(16,2);
initializes the LCD 2X16 and specifies the dimensions
lcd.print
the iput text word that appears on the serial monitor or lcd display.
delay(2000);
1000 is equals to 1 second timeframe.
COPY SOURCE CODE HERE
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#define DHTPin 2 //define DHT pin
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
DHT dht;
void setup() {
dht.setup(DHTPin);
lcd.begin(16,2); //initializes the LCD and specifies the dimensions
}
void loop() {
float temp = dht.getTemperature();
float humi = dht.getHumidity();
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(temp);
lcd.print(" C");
lcd.setCursor(0,1);
lcd.print("Humi: ");
lcd.print(humi);
lcd.print(" %");
delay(2000);
}
The end result is as shown in the picture.
I hope you enjoy this actitvity, if you want to see my upcoming arduino DIY`s activity, you can follow me @pakganern. thank you.....
Done! :) Grabeh! Eto pala tinahak mo after bitcoins Jeh! Post mo it sa group later ha. Hindi sa chat.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
uu sir @fycee yan plang laman ng utak ko hahaha
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Haha Yung tags mo ayusin mo please! Ako din kagagaling ko Lang galaan!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Pa malimali ako ng tag hahaha
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Join our Discord Channel to connect with us and nominate your own or somebody else's posts in our review channel.
Help us to reward you for making it ! Join our voting trail or delegate steem power to the community account.
Your post is also presented on the community website www.steemmakers.com where you can find other selected content.
If you like our work, please consider upvoting this comment to support the growth of our community. Thank you.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thank you
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit