Room Temperature monitoring using Arduino
In this post, we will build a room temperature monitoring system using Arduino and DHT11 module, and display the temperature on an I2C 16x2 LCD Display. This project measures the ambient temperature and humidity and prints the data in the serial monitor and the LCD.
Introduction -
This is a standard beginner Arduino project. You will need Arduino IDE software to program your Arduino board, you can download the software from here. About the DHT11 module :
DHT11 : -
The DHT11 is a basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor for temperature measurement. The module is simple to use but requires careful timing to record the data. The only limitation of the sensor is that it takes about 2 seconds to produce a new data value. That's why we will be using a 2 seconds delay in this project.
Components Required -
1. Arduino Board
2. DHT11 Module
3. I2C 16x2 LCD Display
4. Connection Wires
Circuit Schematic :
Connection -
1. Vcc of the LCD to 5v, GND of LCD to GND.
2. Vcc of DHT11 to 5v, GND of DHT11 to GND.
3. A5 pin to SCL, A4 to SDA on the LCD.
4. Pin 2 to Data pin on DHT11.
Project Images -
Source Code -
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x3F, 20, 4);
void setup() {
Serial.begin(9600);
Serial.println(F("DHT11 Temperture Sensor"));
lcd.init();
lcd.backlight();
dht.begin();
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
lcd.setCursor(0, 0);
lcd.print("Temp : ");
lcd.setCursor(9, 0);
lcd.print(t);
lcd.setCursor(15, 0);
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Humid : ");
lcd.setCursor(9, 1);
lcd.print(h);
lcd.setCursor(15, 1);
lcd.print("%");
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.println(F("°C "));
}