Lab Report 2
Lab Report 2
Lab Report-02
Course Code: IRE 216
Course Title: Sensor Technology Sessional.
SUBMITTED BY
Name-Srabonee Paul Tuli
Koushik Biswas
Kishor Kumar Bormon
ID:2101015
2101029
2101045
Department of IRE,BDU
Session :2021-2022
SUBMITTED TO
Sadia Enam
Lecturer
Department of IRE
Bangabandhu Sheikh Mujibur Rahman Digital
University, Bangladesh.
Objectives:
This experimental study's goal is to use the DHT21 sensor to measure and evaluate the temperature and
humidity in a given space. The purpose of the experiment is to assess the DHT21 sensor's response time,
accuracy, and dependability in recording environmental conditions. This study also aims to show how DHT21
sensor data can be gathered, analyzed, and displayed for real-world uses like IoT devices and climate control
systems.
Theory:
• Humidity Sensing: The DHT21 uses a capacitive sensor element that detects moisture by measuring
changes in capacitance. This data is then converted to a humidity percentage.
• Temperature Sensing: The DHT21 uses a thermistor to measure temperature. The thermistor's resistance
varies with temperature, which is converted into a temperature reading.
Software Requirement:
• Arduino IDE
Working Procedure:
• Circuit Setup:
• Red cable to Arduino 3.3V or 5V pin
• Black cable to Arduino GND pin
• Yellow cable to Arduino 2 digital pin
#include <DHT.h>;
#define DHTPIN 2
float hum;
float temp;
void setup()
Serial.begin(9600);
dht.begin();
void loop()
hum = dht.readHumidity();
temp= dht.readTemperature();
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(temp);
Serial.println(" Celsius");
}
Diagram:
Sketch:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
void setup() {
// Initialize the LCD
lcd.init();
lcd.backlight(); // Turn on the LCD backlight
void loop() {
// Read temperature and humidity from DHT21
float humidity = dht.readHumidity();
float temperature = dht.readTemperature(); // default is Celsius
// Check if any reads failed and exit early (to try again)
if (isnan(humidity) || isnan(temperature)) {
lcd.setCursor(0, 0);
lcd.print("Failed to read");
lcd.setCursor(0, 1);
lcd.print("sensor data");
return;
}
Diagram:
Result and Output: