You are on page 1of 33

0

UNIVERSITY OF CALCUTTA

MCA – P3
IoT and Embedded System Laboratory Assignment Copy

Semester: III
Name: Pritam Sarkar
CU Registration Number: 544-1111-0587-19
CU Roll Number: C91/MCA/222013

Team Members
Akshay Kumar Das
Arijit Bose
Sarita Khatun Mollah
1

INDEX
S No. Practical Name Page no.

1. Basics Of IOT 2–7

2. Basics of Arduino Uno R3 board 8 – 12

Perform Temperature and humidity data acquisition using


3. 13 – 19
DHT 11 sensor

Perform Temperature and humidity data acquisition using


4. 20 – 26
DHT 22 sensor

Perform light intensity data acquisition using LDR (Light


5. 27 – 31
dependent resistor) sensor
2

Title: Basics of IOT


a) What is Internet of Things (IoT)?

The Internet of Things (IoT) refers to a network of physical objects, devices, and sensors that
are connected to the internet and can communicate with each other and exchange data. These
objects can include a wide range of everyday items, such as household appliances, vehicles,
wearable devices, industrial machinery, environmental sensors, and more.

The key idea behind IoT is to enable these objects to collect and share data, often in real-time,
without requiring direct human intervention. This data can then be analysed and processed to
provide insights, optimize operations, and create new services or applications.

b) Describe three tier IoT architecture using use case?

A three-tier IoT architecture is a common approach used to design and implement IoT
systems. It consists of three main layers or tiers: the Perception Layer, the Network Layer, and
the Application Layer. Each layer serves a specific purpose and contributes to the overall
functionality of the IoT system.

Let's explore this architecture using a smart agriculture use case:

 Perception Layer:
The Perception Layer is responsible for collecting data from various sensors and devices
deployed in the field. In the context of smart agriculture, this layer includes sensors that
monitor soil moisture, temperature, humidity, light levels, and other relevant environmental
factors. These sensors gather real-time data about the conditions in the agricultural field.

 Network Layer:
The Network Layer facilitates the communication between the devices in the Perception
Layer and the Application Layer. It includes networking technologies and protocols that
allow data to be transmitted efficiently and securely. In the smart agriculture use case, the
Network Layer would involve technologies such as Low-Power Wide-Area Networks
(LPWAN), cellular networks, or even satellite communication, depending on the location of
the agricultural field.

 Application Layer:
The Application Layer is where the data collected from the Perception Layer is processed,
analysed, and transformed into meaningful insights and actions.

c) Concept of IoT node with example.

An IoT node, also known as a "smart node" or simply a "node," refers to a physical device or
sensor that is part of an Internet of Things (IoT) network. These nodes are responsible for
collecting data from the environment, performing basic processing, and communicating with
other nodes or a central hub. They play a crucial role in the functioning of IoT systems by
gathering and transmitting data that can be used for analysis, control, and decision-making.
3

IoT Node Components:

Sensors: The IoT node would be equipped with multiple sensors:

Air Quality Sensor: Measures various pollutants like particulate matter (PM2.5 and PM10),
carbon monoxide (CO), nitrogen dioxide (NO2), etc.

Humidity and Temperature Sensor: Measures humidity and temperature levels.

Noise Sensor: Measures ambient noise levels.

Microcontroller: The node includes a microcontroller (such as Arduino, Raspberry Pi, or


specialized IoT chipsets) that processes data from sensors, manages communication, and
executes basic algorithms.

Connectivity: The IoT node needs a way to communicate data. It might include:

Wireless Module: Like Wi-Fi, Bluetooth, Zigbee, or LoRa to transmit data to a central server or
gateway.

Power Supply: Depending on the deployment location, the node might have a battery or be
connected to a power source.

d) Concept of fog node with example.

The concept of fog computing extends the capabilities of cloud computing by


decentralizing data processing and analysis closer to the data source, often referred to as the
"edge." In this paradigm, fog nodes, also known as edge nodes or fog devices, play a crucial role.
Fog nodes are devices that reside at the edge of the network and provide computational
resources for processing data locally, reducing latency and improving efficiency. They bridge the
gap between IoT devices generating data and centralized cloud servers. Let's explore this
concept with an example:

Example: Smart Manufacturing

e) Concept of Edge devices with example.

Edge devices, also known as edge computing devices, refer to hardware devices that are
located at the edge of a network, closer to where data is generated or consumed. These devices
perform data processing and analysis locally, reducing latency and improving real-time
responsiveness. The concept of edge computing is especially valuable in scenarios where quick
decision-making, low latency, and efficient use of bandwidth are critical. Here's an example to
help illustrate the concept of edge devices:

Example: Smart Surveillance System


4

f) Concept of static and mobile fog node.

Static and mobile fog nodes are two variations of fog computing devices that play
different roles within an edge computing architecture. Let's explore the concepts of both static
and mobile fog nodes:

Static Fog Node:

A static fog node refers to an edge computing device that remains fixed in a specific location
within the network infrastructure. It is designed to provide localized data processing, analysis,
and other edge computing capabilities to devices or sensors within its vicinity. Static fog nodes
are particularly useful in scenarios where there is a consistent need for processing at a specific
location or to serve devices with limited processing capabilities.

Characteristics and Use Cases of Static Fog Nodes:

Stability: Static fog nodes are stable and have a predictable location within the network
architecture.

Resource Allocation: These nodes can be equipped with substantial processing power,
memory, and storage since they are not constrained by mobility concerns.

Distributed Processing: They distribute the computational load away from the central cloud
and reduce latency for devices within their coverage area.

Mobile Fog Node:

A mobile fog node refers to an edge computing device that is capable of mobility, allowing it
to move within the network environment. These devices can be vehicles, drones, robots, or any
other mobile platform equipped with processing capabilities. Mobile fog nodes are employed in
scenarios where the processing needs to follow the movement of data sources or where
dynamic data processing is required in various locations.

Characteristics and Use Cases of Mobile Fog Nodes:

Mobility: Mobile fog nodes can relocate to different areas as needed, providing processing
resources where they are most required.

Dynamic Deployment: These nodes can be dynamically deployed to areas of interest to


perform specific tasks, adapt to changing conditions, or follow data sources in motion.

Real-time Processing: Mobile fog nodes can offer real-time processing capabilities at the
edge, even for data sources on the move.

g) Examples of available cloud platforms in IoT.

There are several cloud platforms available that cater to IoT (Internet of Things) applications,
providing services for data storage, analysis, device management, and more. Here are some
examples of popular cloud platforms specifically designed for IoT:

AWS IoT Core (Amazon Web Services): AWS IoT Core offers a wide range of services for IoT
device management, data processing, and communication. It supports secure device
5

connectivity, message brokering, rules engine, and integration with other AWS services for data
storage and analytics.

Azure IoT Hub (Microsoft Azure): Azure IoT Hub provides scalable and secure bi-directional
communication between IoT applications and devices. It includes features like device identity
management, telemetry data ingestion, command and control, and integration with Azure
services like Azure Stream Analytics and Azure Functions.

Google Cloud IoT Core: This platform by Google Cloud offers tools to manage, connect, and
process data from IoT devices at scale. It includes device registration, secure communication,
and integration with Google Cloud's data processing and machine learning services.

IBM Watson IoT Platform: IBM's IoT platform allows organizations to connect devices, collect
data, and manage devices' lifecycle. It includes device management features, real-time data
visualization, and integration with AI and analytics tools through IBM Watson.

Particle Cloud: Particle Cloud is a platform tailored for IoT device connectivity, management, and
data collection. It provides tools for building and managing connected devices and enables
developers to create custom IoT solutions.

h) Difference between fog and cloud computing using case studies.

Fog computing and cloud computing are both paradigms that deal with processing and
managing data, but they have distinct characteristics and use cases. Let's compare them using
two case studies:

Case Study 1: Smart Manufacturing

Fog Computing:

o In a smart manufacturing scenario, fog computing can be employed to optimize


production processes. Various sensors in a factory monitor equipment health,
temperature, and other parameters.
o A fog node located within the factory processes sensor data in real time. It analyzes the
data to detect anomalies and optimize the production process based on the collected
insights. For example, if a machine's temperature exceeds a safe threshold, the fog node
can trigger immediate adjustments to prevent damage.

Benefits: Reduced latency, real-time optimization, quick response to localized events, improved
operational efficiency.

Cloud Computing:

o In the same smart manufacturing scenario, cloud computing comes into play for broader
analysis and long-term trends.
o Data processed by the fog nodes is periodically aggregated and sent to the cloud. Cloud-
based analytics platforms process the data from multiple factories to identify larger
patterns, correlations, and trends. For instance, it can identify systemic inefficiencies
across multiple production lines.

Benefits: Scalability, in-depth analysis, centralized data management, insights across multiple
facilities.
6

Case Study 2: Smart City Traffic Management

Fog Computing:

o In a smart city traffic management scenario, fog computing can enhance real-time
decision-making for traffic control.
o Fog nodes located at intersections process data from traffic cameras and sensors. They
analyse traffic flow, detect congestion, and adjust traffic signal timings in real time. This
helps to optimize traffic flow and reduce congestion at specific intersections.

Benefits: Reduced latency, immediate response to changing conditions, localized control.

Cloud Computing:

o For the broader smart city traffic management perspective.


o Data from multiple fog nodes across the city is sent to the cloud for comprehensive
analysis. Cloud-based applications can provide insights into overall traffic patterns,
identify trends, and optimize traffic management strategies on a city-wide scale.

Benefits: Centralized data analysis, long-term planning, and holistic view of traffic patterns.

Key Differences:

o Location: Fog computing emphasizes processing data closer to the data source, while cloud
computing centralizes data processing in remote data canters.
o Latency: Fog computing minimizes latency by processing data locally, while cloud computing
might introduce higher latency due to data transmission.
o Real-Time vs. Aggregated Analysis: Fog computing focuses on real-time, localized decision-
making, whereas cloud computing excels in aggregated analysis, historical trends, and large-
scale insights.
o Scalability: Cloud computing offers greater scalability for analysing massive data sets,
whereas fog computing is ideal for localized, real-time processing.
o Use Cases: Fog computing suits scenarios requiring immediate responses, while cloud
computing is better suited for broader analysis and long-term planning.

Both fog and cloud computing have their strengths, and the choice depends on the specific
requirements of the application and the balance between local processing and centralized
analysis.

i) Write down the main characteristics of a fog node.

A fog node, also known as an edge node or edge device, is a key component in fog
computing that processes and analyses data locally, closer to the data source, rather than
sending all data to a centralized cloud.

Here are the main characteristics of a fog node:

o Proximity to Data Source: A fog node is located in close proximity to where data is
generated, allowing for reduced latency in data processing and quicker decision-making.
o Local Processing: Fog nodes have computational capabilities that enable them to perform
data processing and analysis tasks locally, without needing to send data to a remote cloud
server.
7

o Real-Time Responsiveness: Fog nodes enable real-time or near-real-time processing of data,


which is crucial for applications requiring immediate actions or responses.
o Data Filtering and Aggregation: Fog nodes can filter, aggregate, or pre-process data before
sending it to a central cloud, reducing the amount of data transmitted over the network and
optimizing bandwidth usage.
o Heterogeneous Capabilities: Fog nodes can come in various forms, ranging from powerful
servers to small microcontrollers, depending on the application requirements.
o Connectivity: Fog nodes have connectivity options to interact with local devices, sensors,
and actuators. They can support various communication protocols such as Wi-Fi, Bluetooth,
ZigBee, and cellular networks.
o Data Security and Privacy: Fog nodes can enforce security measures locally, ensuring data is
processed securely before being transmitted to a central cloud. This can be particularly
important for applications with privacy concerns.
o Decentralized Decision-Making: Fog nodes enable localized decision-making by analysing
data at the edge, reducing the need to rely solely on centralized cloud processing.
o Offline Operation: Some fog nodes are capable of limited offline operation, processing data
even when disconnected from the central cloud. This can be essential for applications in
remote or intermittent connectivity scenarios.
o Scalability and Redundancy: Fog nodes can be deployed in distributed networks, providing
scalability and redundancy in data processing across different locations.
o Application-Specific: Fog nodes are designed to cater to specific application needs, making
them versatile tools for a wide range of use cases such as industrial automation, smart cities,
healthcare, and more.
o Data Prioritization: Fog nodes allow for prioritization of critical data or events, ensuring that
time-sensitive actions are taken promptly.
8

Title: Basics of Arduino Uno R3 board


Objective:
Discuss about the different parts and utility of Arduino Uno R3

Required components:
Arduino Uno R3 board

Details about the Board:


Arduino UNO is a microcontroller board based on the ATmega328P. It has 14 digital input/output
pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB
connection, a power jack, an ICSP header and a reset button.

The Arduino Uno R3 is a popular microcontroller board that serves as a versatile platform for
learning and prototyping. Here are the basics of its key components and features:

Components:
● Analog pins: (A0-A5)
○ The Arduino Uno features 6 analog input pins (A0-A5) that can read analog voltage
levels using the built-in Analog-to-Digital Converter (ADC). These pins are useful for
interfacing with sensors that provide analog output.
○ Positive power is analog cycle.

I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the Wire library
(documentation on the Wiring website).

● Digital pins: (0-13 with digital GND pin)


The Arduino Uno has 14 digital I/O pins (D0-D13) that can be configured as either inputs
or outputs. These pins can be used to interface with various digital components like buttons,
LEDs, and switches
The digital pins on an Arduino board can be used for general purpose input and output
via the pinMode(), digitalRead(), and digitalWrite() commands. The maximum current per pin is
40 mA.
○ Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL(Transistor-
Transistor Logic) serial data.
○ External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on
a low value, a rising or falling edge, or a change in value. See the attachInterrupt()
function for details.
○ SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication,
which, although provided by the underlying hardware, is not currently included in
the Arduino language.
○ LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH
value, the LED is on, when the pin is LOW, it's off.
9

● PWM (Pulse Width Modulation) Pins:


Some of the digital pins (D3, D5, D6, D9, D10, and D11) on the Arduino Uno are capable
of generating PWM signals. PWM is used for tasks like dimming LEDs or controlling motor
speed. Provide 8-bit PWM output with the analogWrite() function.

● ICSP (In-Circuit Serial Programming) pins:


○ The In-Circuit Serial Programming header allows for programming the
microcontroller using an external programmer.
○ These pins are used to code and boot an Arduino from an external source (called
serial communication which is used to communicate with other devices). These pins
allow inter-workings of two or more Arduino boards and also allow you to upload
your firmware.
○ ICSP header will allow you to use an external programmer to 'upload' sketch to your
MCU (microcontroller unit) without disconnecting.
10

● Crystal Oscillator (16 MHz):


○ With the help of a crystal oscillator the microcontroller is able to calculate the time
(clock speed). The time factor plays a vital role in receiving and sending signals to
peripheral and other physical devices. Based on the oscillator frequency, the
microcontroller is able to make speedy decisions.
○ The Atmega328P microcontroller on the board operates at a clock frequency of 16
MHz, which is provided by a crystal oscillator.

● Voltage Regulator:
○ The Arduino Uno has two voltage regulators. One voltage regulator is 5V and the
other one is a 3.3V regulator. Arduino can take power from multiple sources either it
can be USB or an external power supply (8 to 20 volts DC). The regulator reduces
this to the 5 volt DC level that the Arduino uses.

● Power pins:
○ VIN (sometimes labelled "9V"): The input voltage to the Arduino board when it's
using an external power source (as opposed to 5 volts from the USB connection or
other regulated power source). You can supply voltage through this pin, or, if
supplying voltage via the power jack, access it through this pin.
○ Power OUT (5V and 3.3V pins): The board regulated 5V and 3.3V output for
powering external components.
11

○ GND: Ground pins.


12

● ATmega328P microcontroller:
The heart of the Arduino Uno R3 is the Atmega328P microcontroller, which has 32KB of
flash memory for program storage, 2KB of SRAM for data storage, and 1KB of EEPROM for
non-volatile storage.

○ Digital I/O Pins: 14 (of which 6 provide PWM output)


○ Analog Input Pins: 6 (DIP) or 8 (SMD)
○ DC Current per I/O Pin: 40 mA
○ Flash Memory (non-volatile): 32 KB
■ Store the actual sketch (operating code).
○ SRAM (volatile): 2 KB
■ Store computing variables.
○ EEPROM (non-volatile): 1 KB
■ Store configuration variable / Initial variables.

● Serial Communication (RX/TX Pins):


The Arduino Uno has built-in hardware UART (Universal Asynchronous Receiver-
Transmitter) for serial communication. Pins D0 (RX) and D1 (TX) are used for serial
communication with other devices.

● AREF (Analog Reference) Pin:


The AREF pin can be used to set the analogReference() voltage used by the ADC.

● Power Adapter Port:


The Arduino Uno can be powered through an external power adapter using the DC
power jack.

● Memory Specifications:
○ Flash Memory: 32KB
○ SRAM: 2KB
○ EEPROM: 1KB

● USB Connector:
The most common and easiest way we can power an Arduino board is by using its
onboard USB B connector. The USB connector provides a regulated 5V line to power the board's
electronics. However, 5V from the USB connector can also power external components through
the 5V pin that can be found in Arduino boards.

● USB interface Chip:


13

It is an integrated circuit designed specifically for connecting the microcontroller


system to a USB interface.

● Power Port:
It is a 2.1mm DC power jack. Arduino Uno accepts 7-12V DC through this port and
the onboard voltage regulator regulates it down to the required 5 and 3.3V.

● Reset Switch:
Pressing it has the same effect as disconnecting and reconnecting the power supply: The
board will wait briefly for a new sketch to upload, then it will start executing any instructions in
the sketch from the beginning. Powering down the board clears RAM memory, so values that
were previously assigned to variables are not kept.

● Built-in LED (Pin 13):


The Arduino Uno includes a built-in LED on digital pin 13. It's often used as a simple
indicator for testing and debugging.

● Power Pins:
The board has a 5V pin and a 3.3V pin for supplying power to external components. It
also has multiple Ground (GND) pins.

Application and use cases using this sensor:


Arduino UNO is a low-cost, flexible, and easy-to-use programmable open-source microcontroller
board that can be integrated into a variety of electronic projects. This board can be interfaced with
other Arduino boards, Arduino shields, and Raspberry Pi boards and can control relays, LEDs, servos,
and motors as an output.
14

Title: Perform Temperature and humidity data


acquisition using DHT 11 sensor
Objective:
The objective of performing temperature and humidity data acquisition using the DHT11 sensor
involves capturing and recording real-time temperature and humidity values from the environment.
The DHT11 sensor is a basic digital sensor capable of providing accurate temperature and humidity
measurements. The primary goals of this objective include:

1. Data Collection: The DHT11 sensor is used to gather temperature and humidity data from
the surrounding environment. This data can be used for various purposes, such as
monitoring environmental conditions in a room, greenhouse, or any other space where
temperature and humidity play a significant role.

2. Environmental Monitoring: By continuously monitoring temperature and humidity levels,


you can gain insights into the conditions of a particular environment. This is particularly
useful in applications like agriculture, where specific crops require certain temperature and
humidity ranges to thrive.

3. Automation and Control: The acquired data can be integrated into automation systems to
control devices such as heaters, fans, or humidifiers, based on predefined thresholds. For
example, if the temperature rises above a certain level, a cooling system can be activated
automatically.

4. Alerts and Notifications: If the temperature or humidity goes beyond acceptable limits, the
acquired data can trigger alerts or notifications. This is important for scenarios where
maintaining a specific environment is critical, such as in server rooms or museum storage.

5. Data Analysis: The collected data can be analyzed over time to identify trends, patterns, and
correlations between temperature and humidity. This information can aid in making
informed decisions for improving environmental conditions.

6. Research and Experimentation: Temperature and humidity data acquisition is essential for
various scientific research and experimentation projects. It helps researchers study the
effects of environmental conditions on different phenomena.

7. Education: This objective can also serve as a hands-on educational project to teach students
or hobbyists about sensor interfacing, data acquisition, and basic programming concepts.

Required components:
15

To perform temperature and humidity data acquisition using the DHT11 sensor, you will need a
few components to set up the hardware and software for data collection. Here's a list of the
required components:

1. DHT11 Sensor: The DHT11 is a digital temperature and humidity sensor that provides
accurate readings. It's a compact and relatively inexpensive sensor commonly used for
environmental monitoring projects.

2. Microcontroller or Development Board: You'll need a microcontroller or development


board to interface with the DHT11 sensor and process the data. Some popular choices
include Arduino boards (like Arduino Uno, Arduino Nano) or Raspberry Pi.

3. Breadboard and Jumper Wires: A breadboard and jumper wires are essential for creating
connections between the DHT11 sensor and the microcontroller pins. Jumper wires help
establish a secure and flexible connection.

4. Resistor (10k Ohm): A 10k Ohm resistor is required to provide a pull-up on the data line of
the DHT11 sensor.

5. Power Source: Depending on your chosen microcontroller or development board, you'll


need a suitable power source to provide power to the circuit. This could be a USB
connection, battery, or external power supply.

6. Computer or Device: You'll need a computer or device to program the microcontroller and
receive the temperature and humidity data. This could be your PC, laptop, or even a
Raspberry Pi.

7. Programming Environment: Depending on your chosen microcontroller, you'll need the


appropriate programming environment or IDE. For Arduino boards, you'll need the Arduino
IDE. For Raspberry Pi, you can use Python with libraries like Adafruit_DHT.

8. Software Libraries: You'll need the appropriate software libraries to communicate with the
DHT11 sensor and retrieve temperature and humidity data. For Arduino, you can use the
"DHT sensor library." For Raspberry Pi, you can use the "Adafruit DHT Library."

9. Optional Display or Output Device: If you want to display the temperature and humidity
readings, you might need an optional display device such as an LED display, LCD screen, or
OLED screen.

Details about sensor:


Components of DHT11 Sensor:

1. Sensing Element: The heart of the DHT11 sensor is its sensing element, which is a composite
material made of polymers that changes its electrical properties with variations in
temperature and humidity. This element allows the sensor to measure both temperature
and humidity.

2. Microcontroller and Signal Processing Circuitry: The DHT11 sensor includes a


microcontroller and signal processing circuitry to convert the analog measurements from
the sensing element into digital data that can be easily read and processed by a
microcontroller or development board.
16

3. Data Pin: The DHT11 sensor communicates with external devices (such as microcontrollers)
using a single-wire digital communication protocol. The data pin is used to both transmit and
receive data.

4. Power and Ground Pins: The sensor requires a power supply (typically 3.3V or 5V) and a
ground connection to operate.

Working Principle:

The DHT11 sensor operates based on the capacitive sensing principle, which involves measuring
changes in the electrical capacitance of the sensing element due to changes in temperature and
humidity. Here's how it works:

1. Initialization: When the microcontroller initiates a request for data, it sends a start signal to
the DHT11 sensor.

2. Measurement: The sensor measures the initial capacitance of the sensing element, which is
affected by the ambient temperature and humidity.

3. Heating and Cooling: The sensor briefly applies heat to the sensing element, causing it to
reach a known temperature. Then, it measures the capacitance of the element as it cools
down. The rate of cooling is influenced by the ambient humidity.

4. Digital Conversion: The sensor's signal processing circuitry analyzes the differences in
capacitance during the heating and cooling cycles. It then converts these differences into
digital temperature and humidity values.

5. Data Transmission: The converted temperature and humidity values are sent back to the
microcontroller using a single-wire digital protocol. The data is transmitted bit by bit, with
specific timing patterns indicating whether a bit is 0 or 1.

6. Checksum: The DHT11 sensor also calculates a checksum value based on the transmitted
data. The checksum is used to verify the integrity of the received data and ensure accurate
measurements.

7. Data Interpretation: The microcontroller receives the data from the DHT11 sensor and
interprets it according to the sensor's specifications. It then uses this data for display,
recording, or other intended purposes.

Pinout and functionality of each pin

The DHT11 sensor has four pins, each serving a specific purpose in the sensor's operation. Here's
the pinout and functionality of each pin:

1. VCC (Power Supply Pin):

 Function: This pin is used to provide power to the DHT11 sensor.


 Voltage: Typically operates at either 3.3V or 5V, depending on the sensor variant.
 Connection: Connect this pin to a power supply (3.3V or 5V) on your microcontroller
or development board.
2. Data Pin:
17

 Function: This pin is used for bidirectional digital communication between the
sensor and the microcontroller.
 Connection: Connect this pin to a digital I/O pin on your microcontroller. This is the
pin where data is sent and received.

3. NC (No Connection Pin):

 Function: This pin does not have any functional purpose and is not used in the
DHT11 sensor's operation.
 Connection: This pin is not connected to anything and can be left unconnected.
4. GND (Ground Pin):

 Function: This pin is used to establish the ground connection for the DHT11 sensor.
 Connection: Connect this pin to the ground (GND) pin on your microcontroller or
development board.
Functionality of Data Pin:

The data pin of the DHT11 sensor serves a critical role in communication between the sensor
and the microcontroller. It uses a single-wire digital communication protocol to transmit
temperature and humidity data to the microcontroller. The communication involves the following
steps:

1. Initialization: The microcontroller sends a start signal to the sensor by setting the data line
low for a brief period. This indicates to the sensor that the microcontroller is ready to
receive data.

2. Response: The sensor responds by pulling the data line low for a short duration, followed by
a high signal for a fixed period. This response confirms that the sensor is ready to transmit
data.

3. Data Transmission: The sensor transmits data bit by bit. Each bit is encoded by the duration
of time that the data line is held low (bit value 0) or high (bit value 1).

4. Checksum: After transmitting the temperature and humidity data, the sensor calculates a
checksum value and transmits it. The microcontroller uses this checksum to verify the
integrity of the received data.

5. Data Interpretation: The microcontroller receives the data from the sensor, decodes it
based on the timing information, and then uses the data to determine the temperature and
humidity values.

Interfacing with various microcontroller:


Interfacing with Arduino (Circuit diagram) :
18

Coding :

#include <DHT.h>

#define DHTPIN 8

#define DHTTYPE DHT11

DHT dht(DHTPIN,DHTTYPE);

void setup()

Serial.begin(9600);

dht.begin();

void loop()

//Temperature Data Acquisition


19

float temp = dht.readTemperature();

//Humidity Data Acquisition

float humid = dht.readHumidity();

//Data Printing in Serial Monitor

Serial.print("temperature: ");

Serial.print(temp);

Serial.print("humidity: ");

Serial.print(humid);

Serial.println("");

delay(1000);

Output :

Application and use cases using this sensor:


The DHT11 sensor, despite its simplicity, finds applications in various fields due to its ability to
provide basic temperature and humidity measurements. Here are some common application and
use cases for the DHT11 sensor:

1. Home Automation:

 Control HVAC systems: Use temperature and humidity data to automate heating,
cooling, and ventilation systems in homes or offices.
20

 Dehumidifiers and humidifiers: Maintain optimal indoor air quality by controlling


devices based on humidity levels.

2. Greenhouses and Agriculture:

 Optimal plant growth: Monitor temperature and humidity to create the right
environment for plants in greenhouses.

 Prevent diseases: Detect conditions that could lead to mold or plant diseases due to
excessive humidity.

3. Weather Stations:

 Personal weather monitoring: Collect temperature and humidity data for local
weather observations and predictions.

4. Indoor Environmental Monitoring:

 Comfort control: Ensure a comfortable indoor environment by maintaining suitable


temperature and humidity levels.

 Mold prevention: Detect and prevent conditions conducive to mold growth, which
can be harmful to health.

5. Data Logging and Analysis:

 Long-term monitoring: Record temperature and humidity data over time for
analysis, trends, and research purposes.

 Energy efficiency: Analyse temperature and humidity patterns to optimize energy


consumption in buildings.
21

Title: Perform Temperature and humidity data


acquisition using DHT 22 sensor
Objective:
The objective of performing temperature and humidity data acquisition using the DHT22 sensor
is similar to that of using the DHT11 sensor, but with the added benefits of improved accuracy and a
wider operating range. The DHT22 sensor, also known as the AM2302, is a more advanced version of
the DHT11 and offers higher precision and reliability. The main objectives of using the DHT22 sensor
for temperature and humidity data acquisition include:

1. High Accuracy Measurements: The DHT22 sensor provides more accurate temperature and
humidity readings compared to the DHT11 sensor. This improved accuracy makes it suitable
for applications where precise data is required.

2. Wider Operating Range: The DHT22 sensor can operate over a wider temperature and
humidity range, making it suitable for environments that experience more extreme
conditions.

3. Environmental Monitoring: Accurate temperature and humidity data collection is essential


for monitoring and maintaining optimal conditions in various environments, such as
greenhouses, server rooms, and manufacturing facilities.

4. Research and Analysis: Researchers can use the DHT22 sensor to gather accurate data for
analysing environmental trends, studying the effects of temperature and humidity on
various processes, and conducting scientific experiments.

5. Automation and Control: The acquired data from the DHT22 sensor can be used in
automation systems to control devices like heaters, coolers, and humidifiers to maintain
specific environmental conditions.

6. Health and Comfort: The DHT22 sensor can be employed in applications such as home
automation to ensure a comfortable living environment, as well as in medical settings to
monitor temperature and humidity in patient rooms.

7. Data Logging and Analysis: Data collected from the DHT22 sensor can be logged over time
and analysed to identify patterns, trends, and correlations between temperature and
humidity changes.
22

Required components:
To perform temperature and humidity data acquisition using a DHT22 sensor, you'll need several
components and tools. The DHT22 sensor is a digital sensor that can measure temperature and
humidity with reasonable accuracy.

Here's a list of the required components:

1. DHT22 Sensor: This is the main sensor that measures temperature and humidity.

2. Microcontroller or Development Board: You'll need a microcontroller or a development


board to interface with the DHT22 sensor, process the data, and possibly display or store it.
Popular choices include Arduino boards (like Arduino Uno, Arduino Nano) or Raspberry Pi.

3. Jumper Wires: These are used to connect the DHT22 sensor to the microcontroller.

4. Resistor (10k ohms): A pull-up resistor is often required for stable communication between
the sensor and the microcontroller.

5. Power Supply: Make sure you have a stable power supply for both the microcontroller and
the DHT22 sensor. This could be a USB cable, battery pack, or another suitable power
source.

6. Computer: You'll need a computer for programming the microcontroller and for processing
the acquired data.

7. Programming Environment: Depending on the microcontroller you're using, you'll need the
appropriate programming environment. For example, the Arduino IDE for Arduino boards.

Details about sensor:


The DHT22 sensor, also known as the AM2302 sensor, is a more advanced version of the
DHT11 sensor and is used for accurate temperature and humidity measurements. It features
improved accuracy, a wider operating range, and better overall performance. Here's an overview of
the components and working principle of the DHT22 sensor:

Components of DHT22 Sensor:

1. Sensing Element: The heart of the DHT22 sensor is its sensing element, which includes a
capacitive humidity sensor and a digital temperature sensor. These components work
together to measure temperature and humidity accurately.

2. Microcontroller and Signal Processing Circuitry: Similar to the DHT11 sensor, the DHT22
sensor also includes a microcontroller and signal processing circuitry. This microcontroller is
responsible for converting the analog signals from the sensing elements into digital data that
can be read and processed by external devices.

3. Data Pins: The DHT22 sensor communicates with external devices using a single-wire digital
communication protocol. It has a single data pin that is used for both transmitting and
receiving data.
23

4. Power Supply and Ground Pins: The sensor requires a power supply (typically 3.3V or 5V)
and a ground connection for its operation.

Working Principle:

The DHT22 sensor operates based on the capacitive sensing principle, similar to the DHT11
sensor. However, the DHT22's design and components result in improved accuracy and
performance. Here's how it works:

1. Initialization: When the microcontroller initiates a data request, it sends a start signal to the
DHT22 sensor.

2. Response: The sensor responds by pulling the data line low for a brief period, followed by a
high signal for a fixed period. This response indicates that the sensor is ready to transmit
data.

3. Data Transmission: The DHT22 sensor transmits data bit by bit using a single-wire digital
communication protocol. Each bit is represented by the duration of time that the data line is
held low (bit value 0) or high (bit value 1).

4. Checksum: After transmitting the temperature and humidity data, the sensor calculates a
checksum value based on the transmitted data. The checksum is used by the receiving
device to verify the integrity of the received data.

5. Data Interpretation: The microcontroller receives the transmitted data from the sensor,
decodes it based on the timing information, and then converts the data into temperature
and humidity values.

6. Temperature Compensation: The DHT22 sensor incorporates a temperature sensor


alongside the humidity sensor. This allows the sensor to compensate for temperature
changes when calculating humidity values, resulting in improved accuracy.

7. Digital Conversion: The analog signals from the humidity and temperature sensors are
converted into digital values using the sensor's internal analog-to-digital converters.

Pinout and functionality of each pin

The DHT22 sensor, also known as the AM2302, has four pins, each serving a specific purpose in
the sensor's operation. Here's the pinout and functionality of each pin:

1. VCC (Power Supply Pin):


 Function: This pin is used to provide power to the DHT22 sensor.
 Voltage: Typically operates at either 3.3V or 5V, depending on the sensor variant.
 Connection: Connect this pin to a power supply (3.3V or 5V) on your microcontroller
or development board.
2. DATA (Data Pin):
 Function: This pin is used for bidirectional digital communication between the
sensor and the microcontroller.
 Connection: Connect this pin to a digital I/O pin on your microcontroller. This is the
pin where data is sent and received.
3. NC (No Connection Pin):
24

 Function: This pin does not have any functional purpose and is not used in the
DHT22 sensor's operation.
 Connection: This pin is not connected to anything and can be left unconnected.
4. GND (Ground Pin):
 Function: This pin is used to establish the ground connection for the DHT22 sensor.
 Connection: Connect this pin to the ground (GND) pin on your microcontroller or
development board.

Functionality of Data Pin:

The data pin of the DHT22 sensor is used for communication between the sensor and an
external microcontroller. The sensor uses a single-wire digital communication protocol to transmit
temperature and humidity data to the microcontroller. The communication involves the following
steps:

1. Initialization: The microcontroller sends a start signal to the sensor by pulling the data line
low for a brief period. This indicates to the sensor that the microcontroller is ready to
receive data.

2. Response: The sensor responds by pulling the data line low for a specific duration, followed
by a high signal for a fixed period. This response confirms that the sensor is ready to transmit
data.

3. Data Transmission: The sensor transmits data bit by bit using specific timing patterns. Each
bit is encoded by the duration of time that the data line is held low (bit value 0) or high (bit
value 1).

4. Checksum: After transmitting the temperature and humidity data, the sensor calculates a
checksum value and sends it to the microcontroller. The microcontroller uses this checksum
to verify the integrity of the received data.

5. Data Interpretation: The microcontroller receives the data from the sensor, decodes it
based on the timing information, and then converts the data into temperature and humidity
values.

Interfacing with various microcontroller:


Interfacing with Arduino (Circuit diagram) :
25

Coding:

#include <DHT.h>

#define DHTPIN 8

#define DHTTYPE DHT22

DHT dht(DHTPIN,DHTTYPE);

void setup()

Serial.begin(9600);

dht.begin();

void loop()

//Temperature Data Acquisition

float temp = dht.readTemperature();

//Humidity Data Acquisition

float humid = dht.readHumidity();

//Data Printing in Serial Monitor

Serial.print("Temperature: ");

Serial.print(temp);

Serial.println("°C");
26

Serial.print("Humidity: ");

Serial.print(humid);

Serial.println("%");

delay(1000);

Output:

Application and use cases using this sensor:


The DHT22 sensor, also known as the AM2302, offers improved accuracy and a wider operating
range compared to its predecessor, the DHT11 sensor. This makes it suitable for more demanding
applications where accurate temperature and humidity measurements are crucial. Here are some
common applications and use cases for the DHT22 sensor:

1. Environmental Monitoring:

 Precision climate control: Maintain specific temperature and humidity conditions in


greenhouses, laboratories, and cleanrooms.

 Server rooms: Monitor and control temperature and humidity levels in data centres
to prevent overheating and equipment failure.

2. Weather Stations and Meteorology:

 Accurate weather data: Use the DHT22 sensor in personal weather stations or small-
scale meteorological setups to gather precise temperature and humidity
information.

3. Home Automation and HVAC Systems:


27

 Smart thermostats: Incorporate the DHT22 sensor into home automation systems to
create energy-efficient heating, cooling, and ventilation schedules.

 Humidification and dehumidification: Control humidity levels in residential spaces to


enhance comfort and prevent Mold growth.

4. Agriculture and Farming:

 Optimal crop conditions: Use the DHT22 sensor to ensure the right temperature and
humidity levels for various crops in indoor and outdoor settings.

5. Medical and Healthcare:

 Lab conditions: Monitor temperature and humidity in medical laboratories and


storage rooms to preserve the integrity of sensitive materials and equipment.

 Pharmaceutical storage: Maintain proper storage conditions for medications and


vaccines.
28

Title: Perform light intensity data acquisition using LDR


(Light dependent resistor) sensor
Objective:
The objective of performing light intensity data acquisition using an LDR (Light Dependent
Resistor) sensor involves capturing and recording real-time light levels from the surrounding
environment. LDRs are passive electronic components whose resistance changes in response to the
amount of light falling on them. The primary goals of this objective include:

1. Data Collection: The LDR sensor is used to collect light intensity data, which can be utilized
for various purposes such as monitoring changes in ambient lighting conditions.

2. Environmental Monitoring: By continuously tracking light levels, you can gain insights into
how natural light changes throughout the day or how artificial lighting affects different
spaces.

3. Energy Efficiency: Use light intensity data to optimize the use of artificial lighting in indoor
spaces, saving energy by only activating lights when necessary.

4. Security and Safety: Light intensity data can be used to trigger security systems or lighting
automation in response to changes in ambient lighting conditions.

5. Research and Analysis: Collect light intensity data over time to analyse trends and patterns
in lighting conditions, which can be useful for various research purposes.

6. Agriculture and Plant Growth: Monitor light levels in agricultural settings to ensure that
plants receive the appropriate amount of light for healthy growth.

7. Photography and Videography: Use light intensity data to control camera settings, such as
adjusting exposure, based on ambient lighting conditions.

Required components:
To perform light intensity data acquisition using an LDR (Light Dependent Resistor) sensor, you'll
need a few components and tools. An LDR is a variable resistor whose resistance changes based on
the intensity of light falling on it. Here's a list of the required components:

1. LDR (Light Dependent Resistor): This is the primary sensor that will change its resistance
based on light intensity.

2. Microcontroller or Development Board: You'll need a microcontroller or development


board to interface with the LDR sensor, read its resistance, and possibly process, display, or
store the data. Common options include Arduino boards, Raspberry Pi, or other
microcontrollers.

3. Jumper Wires: These wires will be used to connect the LDR sensor to the microcontroller.

4. Resistor (optional): Depending on your circuit design and the LDR used, you might need a
fixed resistor to create a voltage divider circuit for more accurate measurements.
29

5. Power Supply: Ensure you have a stable power supply for both the microcontroller and the
LDR sensor. This could be a USB cable, battery pack, or another suitable power source.

6. Computer: You'll need a computer for programming the microcontroller and for processing
the acquired data.

7. Programming Environment: Depending on the microcontroller you're using, you'll need the
appropriate programming environment. For example, the Arduino IDE for Arduino boards.

Details about sensor:


Components of an LDR:

1. Semi-Conductive Material: The core of an LDR is a semiconductor material with properties


that change as light intensity changes. This material has a high resistance in the dark and a
lower resistance in the presence of light.

2. Encapsulation: The semi conductive material is typically encased in a protective package to


shield it from environmental factors like dust and moisture.

Working Principle:

The operation of an LDR is based on the principle of the photoconductive effect, which is a
property of certain materials to conduct electricity better when exposed to light. Here's how it
works:

1. Dark Conditions (Low Light Intensity):

 In the absence of light or under low light conditions, the semiconductor material in
the LDR has a high resistance. This means it restricts the flow of electric current.

2. Light Conditions (High Light Intensity):


 When exposed to light, photons from the light interact with the semiconductor
material, causing the material's atoms to release electrons.
 These released electrons increase the material's conductivity, resulting in a lower
resistance.
 As a result, the LDR allows more electric current to flow through it under high light
conditions.
3. Variation in Resistance:
 The resistance of the LDR is inversely proportional to the light intensity. Higher light
intensity corresponds to lower resistance, and vice versa.
 This variation in resistance can be used to measure and quantify the intensity of light
in the environment.
4. Voltage Divider Circuit:
 LDRs are often used in voltage divider circuits. In this circuit, the LDR is connected in
series with a fixed resistor (e.g., a regular resistor) to create a voltage divider.
 The voltage across the LDR is measured, which changes based on the LDR's
resistance and the intensity of light.
30

5. Output Signal:
 The output signal from the voltage divider circuit can be processed using analog-to-
digital converters (ADCs) in microcontrollers or other electronics.
 By analysing the output voltage, the microcontroller or circuit can determine the
light intensity.
Pinout and functionality of each pin

An LDR (Light Dependent Resistor) is a passive component with two pins. The pinout and
functionality of each pin are quite straightforward:

1. Two Pins:

 An LDR has two leads or pins: one lead is connected to one side of the photoresistor,
and the other lead is connected to the other side.

2. No Specific Polarity:

 Unlike some active components (such as diodes or transistors), LDRs do not have a
specific polarity. This means that you can connect either pin to the positive voltage
and the other to the negative voltage (ground) without any concerns about
reversing the connection.

3. Functionality of the LDR:

 The primary function of an LDR is to vary its resistance based on the intensity of light
falling on it. This variation in resistance is used to sense and measure light levels in
various applications.

Interfacing with various microcontroller:


Interfacing with Arduino (Circuit diagram):
31

Coding:
int ldrPin = A0; // Analog pin for LDR sensor
void setup() {
Serial.begin(9600); // Initialize serial communication
}
void loop() {
// Read analog value from LDR sensor
int ldrValue = analogRead(ldrPin);
// Convert analog value to voltage (0 to 5V)
float voltage = ldrValue * (5.0 / 1023.0);
// Convert voltage to light intensity (adjust this based on your sensor's characteristics)
// You might need to calibrate this based on your specific LDR sensor
float lightIntensity = map(voltage, 0.0, 5.0, 0.0, 100.0);
Serial.print("LDR Value: ");
Serial.print(ldrValue);
Serial.print("\tVoltage: ");
Serial.print(voltage, 2);
Serial.print("V\tLight Intensity: ");
Serial.print(lightIntensity, 2);
Serial.println("%");
delay(1000); // Wait for 1 second
}

Output:
32

Application and use cases using this sensor:


LDRs (Light Dependent Resistors) are versatile sensors commonly used for light sensing and
control in various applications. Their simplicity, cost-effectiveness, and wide range of applications
make them popular choices for both hobbyist projects and professional applications. Here are some
common application and use cases for LDRs:

1. Outdoor Lighting Control:


 Streetlights: Automatically control streetlights to turn on at dusk and off at dawn.
 Garden Lights: Illuminate outdoor spaces such as gardens and pathways based on
ambient light conditions.
2. Indoor Lighting Control:
 Ambient Lighting: Adjust indoor lighting levels based on the available natural light to
save energy.
 Nightlights: Automatically turn on nightlights when the room gets dark.
3. Photography and Videography:
 Light Meters: Use LDRs to measure ambient light and assist in setting camera
exposure.
 Light Sensing Triggers: Trigger photography equipment based on changes in light
conditions.
4. Security Systems:
 Motion-Activated Lights: Illuminate areas when motion is detected, increasing
security and safety.
 Light-Based Alarms: Trigger alarms or notifications based on sudden changes in light
levels.
5. Energy Saving:
 Sunlight Harvesting: Use LDRs to regulate artificial lighting in buildings by
incorporating natural light.
 Energy-Efficient Buildings: Control blinds, curtains, and lighting systems to optimize
energy usage.

You might also like