Iot 7-8
Iot 7-8
-7
AIM: Write a program to sense the humidity & temperature of the room using DHT – 11
sensor & display the output on the serial monitor.
THEORY:
DHT11 Module features a temperature & humidity sensor complex with a calibrated digital
signal output. The exclusive digital-signal-acquisition technique and temperature &
humidity sensing technology ensure high reliability and excellent long-term stability. This
sensor includes an NTC for temperature measurement and a resistive-type humidity
measurement component for humidity measurement. These are connected to a high-
performance 8-bit microcontroller, offering excellent quality, fast response, anti-
interference ability, and cost- effectiveness.
The DHT11 module has a total of 3 pins. In which two are for power and one is
forcommunication. The pinout of a DHT11 Sensor module is as follows:
COMPONENTS REQUIRED:
HARDWARE REQUIREMENTS:
1. Arduino Board: Choose an appropriate Arduino board based on your project
requirements. Popular options include Arduino Uno, Arduino Nano, or Arduino Mega.
The Arduino board will serve as the control unit for the relay.
2. DHT11 sensor: For sensing the changes in temperature & humidity of
surroundings.
3. Resistor: A current-limiting resistor for the LED to prevent excessive current flow.
4. Breadboard: Optional but recommended for prototyping and connecting the
components.
5. Jumper Wires: Use jumper wires to establish connections between the Arduino board,
relay module, and LED. Ensure that you have a variety of male-to-male, male-to-
female, and female-to-female jumper wires to make the necessary connections.
SOFTWARE REQUIREMENTS:
Arduino IDE: The open-source Arduino Software (IDE) makes it easy to write code and
upload it to the board. This software can be used with any Arduino board.
HANUMANT SINGH NEGI(01015007722) 23
SCHEMATIC DIAGRAM:
CIRCUIT DIAGRAM:
#include "DHT.h"
#define DHTPIN 6
#define DHTTYPE DHT11
DHT dht(DHTPIN,
DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println("DHT
test!");dht.begin();
}
void loop()
{
delay(200
0);
float h =
dht.readHumidity(); float t =
dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT
sensor!");return;
}
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h,
false);Serial.print ("Humidity: ");
Serial.print (h);
Serial.print (" %\t");
Serial.print ("Temperature:
");Serial.print (t);
Serial.print (" *C ");
Serial.print (f);
Serial.print (" *F\t");
Serial.print ("Heat index:
");Serial.print (hic);
Serial.print (" *C ");
Serial.print (hif);
Serial.println (" *F");
}
SERIAL MONITOR:
THEORY:
IR sensor is an electronic device, that emits the light in order to sense some object of the
surroundings. An IR sensor can measure the heat of an object as well as detects the motion.
Usually, in the infrared spectrum, all the objects radiate some form of thermal radiation.
These types of radiations are invisible to
our eyes, but infrared sensor can detect
these radiations. The emitter is simply an
IR LED (Light Emitting Diode) and the
detector is simply an IR photodiode .
Photodiode is sensitive to IR light of the
same wavelength which is emitted by the
IR LED. When IR light falls on the
photodiode, the resistances and the
output voltages will change in proportion
to the magnitude of the IR light received.
There are five basic elements used in a
typical infrared detection system: an infrared source, a transmission medium, optical
component, infrared detectors or receivers and signal processing. Infrared lasers and
Infrared LED’s of specific wavelength used as infrared sources.
COMPONENTS REQUIRED:
HARDWARE REQUIREMENTS:
1. IR sensor: For sensing the changes in surroundings. Resistor: A current-limiting resistor
for the LED to prevent excessive current flow.
2. Arduino Board: Choose an appropriate Arduino board based on your project
requirements. Popular options include Arduino Uno, Arduino Nano, or Arduino Mega.
The Arduino board will serve as the control unit for the relay.
3. Resistor: A current-limiting resistor for the LED to prevent excessive current flow.
4. Breadboard: Optional but recommended for prototyping and connecting the components.
5. Jumper Wires: Use jumper wires to establish connections between the Arduino board,
relay module, and LED. Ensure that you have a variety of male-to-male, male-to-female,
and female-to-female jumper wires to make the necessary connections.
SOFTWARE REQUIREMENTS:
Arduino IDE: The open-source Arduino Software (IDE) makes it easy to write code and
upload it to the board. This software can be used with any Arduino board.
CIRCUIT DIAGRAM:
CODE:
1. int ir = 2;
2. int PinLed = 10;
3. int val=0;
4. void setup()
5. {
6. pinMode(ir, INPUT);
7. pinMode(PinLed, OUTPUT);
8. }
9. void loop()
10. {
11. if(digitalRead(ir) == LOW) }
12. digitalWrite(PinLed, HIGH);
13. else { digitalWrite(PinLed, LOW); } }
HANUMANT SINGH NEGI(01015007722) 28
OUTPUT:
SERIAL MONITOR: