Devices & Components
16x2 LCD display with I²C interface
Arduino Uno Rev3
DHT11 Temperature & Humidity Sensor (3 pins)
Hardware & Tools
Premium Male/Male Jumper Wires, 40 x 3" (75mm)
Premium Female/Male Extension Jumper Wires, 40 x 6" (150mm)
Breadboard, 170 Pin
Software & Tools
Arduino Web Editor
Project description
Code
Temperature and Humidity sensing with LCD 1602 I2C display
c_cpp
We are using the LCD display using the I2C module to display the temperature and humidity with the DHT 11 sensor.
1//by Druhi Chakraborty 2#include "DHT.h" 3#define DHTPIN 4// you 4 can use 5#define DHTTYPE DHT11//#define DHTTYPE DHT21 6 //#define 7 DHTTYPE DHT22 8DHT dht(DHTPIN, DHTTYPE);//you can also use pins 3, 4, 5, 12, 13 9 or 14 10 // Pin 15 can work but DHT must be disconnected during program upload 11#include 12 <LiquidCrystal_I2C.h> 13LiquidCrystal_I2C lcd(0x27, 16, 2); 14void setup() { 15 16 dht.begin();// initialize the sensor 17 lcd.backlight();// turn on lcd backlight 18 19 lcd.init();// initialize lcd 20} 21void loop() { 22 lcd.clear(); 23 lcd.setCursor(0,0);// 24 set the cursor on the first row and column 25 lcd.print("Humidity="); 26 lcd.print((float)dht.readHumidity());//print 27 the humidity 28 lcd.print("%"); 29 lcd.setCursor(0,1);//set the cursor on 30 the second row and first column 31 lcd.print("Temp="); 32 lcd.print((float)dht.readTemperature());//print 33 the temperature 34 lcd.print("Celsius"); 35 delay(2000); 36 lcd.clear(); 37}
Temperature and Humidity sensing with LCD 1602 I2C display
c_cpp
We are using the LCD display using the I2C module to display the temperature and humidity with the DHT 11 sensor.
1//by Druhi Chakraborty 2#include "DHT.h" 3#define DHTPIN 4// you can use 4#define DHTTYPE DHT11//#define DHTTYPE DHT21 5 //#define DHTTYPE DHT22 6DHT dht(DHTPIN, DHTTYPE);//you can also use pins 3, 4, 5, 12, 13 or 14 7 // Pin 15 can work but DHT must be disconnected during program upload 8#include <LiquidCrystal_I2C.h> 9LiquidCrystal_I2C lcd(0x27, 16, 2); 10void setup() { 11 dht.begin();// initialize the sensor 12 lcd.backlight();// turn on lcd backlight 13 lcd.init();// initialize lcd 14} 15void loop() { 16 lcd.clear(); 17 lcd.setCursor(0,0);// set the cursor on the first row and column 18 lcd.print("Humidity="); 19 lcd.print((float)dht.readHumidity());//print the humidity 20 lcd.print("%"); 21 lcd.setCursor(0,1);//set the cursor on the second row and first column 22 lcd.print("Temp="); 23 lcd.print((float)dht.readTemperature());//print the temperature 24 lcd.print("Celsius"); 25 delay(2000); 26 lcd.clear(); 27}
Downloadable files
Temperature and Humidity sensing with LCD 1602 I2C display
Please download it if required
Temperature and Humidity sensing with LCD 1602 I2C display
Comments
Only logged in users can leave comments