ArduBlog #4: Temperature and Humidity sensor with LCD Display

in #blog6 years ago (edited)

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.

ss


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.

U5dtDDNcD2DyTcVRZcGo59NjcNrxLkv_1680x8400.png

LCD Connection to arduino

  • VCC - 5V
  • GND - GND
  • SCL - A4
  • SDA - A5

U5drZVtXfGZzMQUW9cCTThjTHJS8joY_1680x8400.jpg


DHT11 connection to arduino

  • VCC - 3.3V
  • GND - GND
  • DAT - PIN 2 PWM

SOFTWARE and LIBRARIES


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.

U5dtxVrCUx1mfkCkDSbxffK3r8wLVX1_1680x8400.jpg


I hope you enjoy this actitvity, if you want to see my upcoming arduino DIY`s activity, you can follow me @pakganern. thank you.....

Sort:  

Done! :) Grabeh! Eto pala tinahak mo after bitcoins Jeh! Post mo it sa group later ha. Hindi sa chat.

uu sir @fycee yan plang laman ng utak ko hahaha

Haha Yung tags mo ayusin mo please! Ako din kagagaling ko Lang galaan!

Pa malimali ako ng tag hahaha

Congratulations This post has been upvoted by SteemMakers. We are a community-based project that aims to support makers and DIYers on the blockchain in every way possible.

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.

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.033
BTC 64386.10
ETH 3142.17
USDT 1.00
SBD 3.98