ASSIGNMENT
Q1.a.Write principle and application of any one sensor.
Infrared (IR) Sensor:
Principle of Operation:
Infrared sensors work on the principle of detecting infrared radiation emitted or
reflected by objects. They operate within the infrared spectrum (700 nm – 1 mm).
The sensor consists of two main components:
Emitter: Generates infrared light (usually an LED).
Receiver: Detects the reflected IR light or changes in IR radiation.
Working Process:
The emitter sends out infrared light.
When this light hits an object, it either gets absorbed or reflected.
The receiver detects the reflected light or measures the variation in infrared
radiation.
Based on the intensity and time delay, the sensor determines object
presence, distance, or movement.
Applications:
1. Industrial Applications:
Object detection on conveyor belts
Temperature measurement in non-contact thermometers
Flame detection in furnaces
2. Automotive:
Night vision systems
Automatic braking systems
Traffic signal sensing
3. Robotics:
Obstacle detection and avoidance
Line-following robots
Heat detection for search and rescue
4. Security Systems:
Motion sensing in burglar alarms
IR cameras for surveillance
Perimeter intrusion detection
5. Medical:
IR thermometers for fever detection
Pulse oximeters for oxygen level monitoring
Infrared imaging for diagnostics
Advantages:
Non-contact measurement
Works in any lighting condition
Cost-effective
Reliable in dusty environments
Simple to implement
Limitations:
Can be affected by temperature and humidity
May have interference from sound-absorbing materials
Limited angular coverage
Not suitable for very small objects
Performance can be affected by air currents
Numerical Questions for 5-Layer Architecture Model
1. Perception Layer (Sensor Data Conversion)
Question:
A temperature sensor in the perception layer records data in analog form. The
sensor converts temperature into voltage using the formula:
V = 0.01 × T + 0.5
where T is the temperature in °C and V is the voltage output. If the sensor reads a
voltage of 1.2V, calculate the temperature.
Solution:
1.2 = 0.01 × T + 0.5
T = (1.2 - 0.5) / 0.01
T = 0.7 / 0.01
T = 70°C
2. Network Layer (Data Transmission Speed)
Question:
A network transmits 500 MB of data in 10 seconds. What is the data transfer rate
in Mbps (Megabits per second)?
Solution:
Convert MB to Mb (megabits):
500 MB = 500 × 8 = 4000 Mb
Now, calculate the transfer rate:
Transfer rate = 4000 Mb / 10 sec
Transfer rate = 400 Mbps
3. Middleware Layer (Message Queue Processing)
Question:
A middleware message queue processes 500 requests per second. If the queue
size is 2000 messages, how long will it take to process the entire queue?
Solution:
Time = Total Messages / Processing Rate
Time = 2000 / 500
Time = 4 seconds
4. Application Layer (Response Time Calculation)
Question:
A cloud-based application takes 150ms for database access, 100ms for API
processing, and 50ms for UI rendering. What is the total response time?
Solution:
Total Response Time = 150 + 100 + 50
Total Response Time = 300 ms
5. Business Layer (Cost Analysis)
Question:
A company uses a cloud-based system where the business logic layer processes
10,000 transactions per day. If each transaction costs $0.005, calculate the total
daily and monthly cost.
Solution:
Daily Cost = 10,000 × 0.005
Daily Cost = 50 USD
Monthly Cost = 50 × 30
Monthly Cost = 1500 USD
Q.1.b.Explain the 5-Layer Model of IoT.
Ans.
Five-Layer IoT Model
1. Perception Layer (Sensing Layer)
Function: This is the foundational layer of IoT, responsible for sensing
physical parameters using devices like sensors, RFID tags, cameras, and GPS
modules. It collects real-world data for further processing.
Example: In precision agriculture, soil moisture sensors detect humidity
levels and transmit data for automated irrigation control.
2. Transport Layer (Network Layer)
Function: Facilitates the transmission of data from the Perception Layer to
the Processing Layer using various communication technologies such as Wi-
Fi, Bluetooth, Zigbee, 5G, and LPWAN.
Example: A connected car sends real-time GPS and engine diagnostics data
to cloud servers via 5G networks for monitoring and analysis.
3. Processing Layer (Edge/Cloud Layer)
Function: Processes, stores, and analyzes incoming data from the Transport
Layer using cloud computing, edge computing, or fog computing
technologies. It ensures efficient decision-making and data management.
Example: In smart manufacturing, edge devices analyze vibration sensor
data from machines to detect anomalies and prevent equipment failures
through predictive maintenance.
4. Application Layer
Function: Provides user-facing interfaces and services through applications,
dashboards, or APIs, enabling interaction with IoT systems.
Example: A smart energy monitoring system allows users to track electricity
consumption and control appliances remotely via a mobile app.
5. Business Layer
Function: Manages the overall IoT ecosystem, defining business strategies,
security policies, and monetization models. It ensures system reliability and
efficiency.
Example: An e-commerce company leverages IoT-enabled supply chain
management to optimize warehouse operations and reduce delivery time.
Applications of the Five-Layer IoT Model
1. Smart Homes: IoT-powered devices regulate lighting, security, and
temperature control for enhanced convenience.
2. Healthcare: Wearable health monitors track patient vitals and notify
caregivers in case of anomalies.
3. Industrial IoT (IIoT): Predictive maintenance minimizes downtime in
manufacturing plants.
4. Smart Cities: IoT solutions optimize traffic flow, waste management, and
air quality monitoring.
5. Agriculture: Automated irrigation systems adjust water supply based on
real-time soil conditions.
Pros and Cons of the Five-Layer IoT Model
Pros:
Modularity & Scalability: Well-defined layers support system expansion and
updates.
Optimized Data Handling: Streamlines data collection, transmission, and
processing.
Enhanced Security & Management: The Business Layer enforces security
measures and strategic policies.
Interoperability: Compatible with multiple communication technologies,
ensuring seamless connectivity.
Cons:
Complexity: Managing different layers requires specialized expertise and ongoing
maintenance.
Latency Issues: Cloud-based processing may introduce delays in real-time
applications.
Security Vulnerabilities: Each layer is susceptible to cyber threats like hacking,
malware, and data breaches.
High Deployment Cost: Implementing large-scale IoT infrastructure can be
expensive.
Q.1.c.Explain the code to connect: Device to the computer ,edge to the
computer ,fog to the computer and cloud to the computer.
Ans.1. Edge Device to Computer (Using MQTT)
Edge devices typically send data to a computer using lightweight protocols like
MQTT.
Code:import paho.mqtt.client as mqtt
broker = "localhost" # Replace with broker IP
topic = "edge/data"
client = mqtt.Client()
client.connect(broker, 1883, 60)
client.publish(topic, "Edge device data")
client.disconnect()
Explanation:
Uses MQTT, a lightweight messaging protocol.
Publishes data from an edge device to a computer.
The computer acts as an MQTT broker.
2. Fog Device to Computer (Using HTTP REST API)
Fog devices often use RESTful APIs to communicate.
Code:import requests
url = "http://localhost:5000/fog-data" # Computer as server
data = {"temperature": 25.5, "humidity": 60}
response = requests.post(url, json=data)
print(response.text)
Explanation:
Sends sensor data to a computer running an HTTP server.
Uses POST request to send data from the fog device.
3. Cloud to Computer (Using WebSocket)
Cloud services often push data to a computer using WebSockets for real-time
communication.
Code:import websocket
def on_message(ws, message):
print("Cloud Data:", message)
ws = websocket.WebSocketApp("ws://cloudserver.com",
on_message=on_message)
ws.run_forever()
Explanation:
Listens to real-time data updates from the cloud.
Uses WebSocket for persistent connection.
4. Signal Processing to Computer (Using Serial Communication)
Signals from sensors (e.g., Arduino) are transmitted using Serial communication
(UART/USB).
Code:import serial
ser = serial.Serial('COM3', 9600) # Adjust port and baud rate
while True:
data = ser.readline().decode().strip()
print("Received Signal:", data)
Explanation:
Reads signals from a sensor/microcontroller via a serial port.
Uses UART/USB communication to receive the signal.