0% found this document useful (0 votes)
9 views

Lab Report 2

Uploaded by

biswaskoushik567
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Lab Report 2

Uploaded by

biswaskoushik567
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

শিক্ষা শিয়ে গড়য় ো দেি তথ্য-প্রযুশির োাংলোয়েি

Bangabandhu Sheikh Mujibur Rahman Digital University, Bangladesh

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.

Date of Submission: 18 September,2024


Experiment No.: 02

Experiment Name: Experimental study on Humidity and Temperature Sensing using


DHT21 sensor.

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.

Key Features of DHT21

• Humidity Range: 0% to 100% RH with ±2% accuracy.


• Temperature Range: -40°C to 80°C (-40°F to 176°F) with ±0.5°C accuracy.
• Operating Voltage: 3.3V to 5.5V, making it compatible with most microcontrollers.
• Response Time: Typically, 2 seconds.

Hardware Requirement with Quantity:


• Arduino Uno (1x)
• DHT21 Sensor.
• Jumper Wires (as required)
• USB Cable for Arduino (1x)

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

• Upload the code to Arduino IDE.


• Testing and Observation:

▪ Run the circuit and observe the display.


Sketch:

#include <DHT.h>;

#define DHTPIN 2

#define DHTTYPE DHT21

DHT dht(DHTPIN, DHTTYPE);

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("%, Temperature: ");

Serial.print(temp);

Serial.println(" Celsius");

delay(2000); //Delay 2 sec.

}
Diagram:

Result and Output:


TASK-2: Humidity and Temperature Sensing using DHT21 sensor and displaying the
values using LCD.

Sketch:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>

// Define LCD parameters


LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column, 2 row LCD

// Define DHT sensor


#define DHTPIN 2 // Pin connected to the DHT21 sensor
#define DHTTYPE DHT21 // DHT21 (AM2301)

// Initialize DHT sensor


DHT dht(DHTPIN, DHTTYPE);

void setup() {
// Initialize the LCD
lcd.init();
lcd.backlight(); // Turn on the LCD backlight

// Initialize the DHT sensor


dht.begin();

// Print welcome message


lcd.setCursor(0, 0);
lcd.print("Temp & Humidity");
lcd.setCursor(0, 1);
lcd.print("Initializing...");
delay(2000); // Wait 2 seconds
}

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;
}

// Display temperature on the LCD


lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print(" C");

// Display humidity on the LCD


lcd.setCursor(0, 1);
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print(" %");

// Wait a few seconds between readings


delay(2000);
}

Diagram:
Result and Output:

You might also like