DHT11 Temperature Sensor XH2.54 terminal 1602 I2C LCD with Arduino

What you need:
1 X DHT11 Temperature Sensor XH2.54mm terminal
1 X 1602 I2C LCD Display module
1 X Arduino UNOR3
1 X 7P Female to Male Jump Wire
1 X USB Cable

Materials for DHT11 Temperature Humidity Measurement and display

Connection:
DHT11 to UNOR3:
S to D2
+ to 3V3
– to GND

1602 I2C LCD to UNOR3:
GND to GND
VCC to 5V
SDA to A4
SCL to A5

DHT11 sensor 1602 I2C LCD wiring with Arduino

Download below two libraries on your Arduino IDE:
DHT sensor library
LiquidCrystal I2C

 

Code:
#include <LiquidCrystal_I2C.h>
#include “DHT.h”
#define DHTPIN 2
#define DHTTYPE DHT11

LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x3F, 16 column and 2 rows
DHT dht(DHTPIN, DHTTYPE);

void setup()
{
dht.begin(); // initialize the sensor
lcd.init(); // initialize the lcd
lcd.backlight(); // open the backlight
}

void loop()
{
delay(2000); // wait a few seconds between measurements

float humi = dht.readHumidity(); // read humidity
float tempC = dht.readTemperature(); // read temperature

lcd.clear();
// check if any reads failed
if (isnan(humi) || isnan(tempC)) {
lcd.setCursor(0, 0);
lcd.print(“Failed”);
} else {
lcd.setCursor(0, 0); // start to print at the first row
lcd.print(“Temp: “);
lcd.print(tempC); // print the temperature
lcd.print((char)223); // print ° character
lcd.print(“C”);

lcd.setCursor(0, 1); // start to print at the second row
lcd.print(“Humi: “);
lcd.print(humi); // print the humidity
lcd.print(“%”);
}
}

After upload the code, the measurement of the temperature and humidity results displayed in 1602 LCD like below picture:

Note: if the lcd displays not properly after powered on, pls adjust the blue potentiometer on the IIC Adapter board which is installed in the backside of the lcd module.

 

Purchase link:

https://www.diymalls.com/DHT11-Temperature-Sensor-XH2.54-3P-Terminal-with-1602-I2C-LCD-Display-Module

***********************************************************************************

***********************************************************************************

Leave a Reply

Your email address will not be published. Required fields are marked *