0% found this document useful (0 votes)
26 views60 pages

INTERNET OF THINGS

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)
26 views60 pages

INTERNET OF THINGS

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/ 60

INTERNET OF THINGS (IOT)

UNIT – 1 : INTRODUCTION TO IOT


WHAT IS IOT?
IoT stands for Internet of Things. It refers to the interconnectedness of physical devices, such
as appliances and vehicles, that are embedded with software, sensors, and connectivity which
enables these objects to connect and exchange data. This technology allows for the collection
and sharing of data from a vast network of devices, creating opportunities for more efficient
and automated systems.
Internet of Things (IoT) is the networking of physical objects that contain electronics
embedded within their architecture in order to communicate and sense interactions amongst
each other or with respect to the external environment. In the upcoming years, IoT-based
technology will offer advanced levels of services and practically change the way people lead
their daily lives. Advancements in medicine, power, gene therapies, agriculture, smart cities,
and smart homes are just a few of the categorical examples where IoT is strongly
established.
IOT is a system of interrelated things, computing devices, mechanical and digital machines,
objects, animals, or people that are provided with unique identifiers. And the ability to
transfer the data over a network requiring human-to-human or human-to-computer
interaction.
History of IOT
• 1982 – Vending machine:
• 1990 – Toaster
• 1999 – IoT Coined (Kevin Ashton.
• 2000 – LG Smart Fridge.
• 2004 – Smart Watch.
• 2007 – Smart iPhone.
• 2009 – Car Testing.
• 2011 – Smart TV.
• 2013 – Google Lens.
• 2014 – Echo.
• 2015 – Tesla Autopilot.
Four Key Components of IOT
• Device or sensor
• Connectivity
• Data processing
• Interface
IoT is network of interconnected computing devices which are embedded in everyday
objects, enabling them to send and receive data.
Over 9 billion ‘Things’ (physical objects) are currently connected to the Internet, as of now.
In the near future, this number is expected to rise to a whopping 20 billion.
Main Components Used in IoT
• Low-power embedded systems: Less battery consumption, high performance are the
inverse factors that play a significant role during the design of electronic systems.
• Sensors: Sensors are the major part of any IoT application. It is a physical device that
measures and detects certain physical quantities and converts it into signal which can
be provided as an input to processing or control unit for analysis purpose.
Different types of Sensors
• Temperature Sensors
• Image Sensors
• Gyro Sensors
• Obstacle Sensors
• RF Sensor
• IR Sensor
• MQ-02/05 Gas Sensor
• LDR Sensor
• Ultrasonic Distance Sensor
Ways of Building IOT
There are two ways of building IoT:
• Form a separate internet work including only physical objects.
• Make the Internet ever more expansive, but this requires hard-core technologies such
as rigorous cloud computing and rapid big data storage (expensive).
In the near future, IoT will become broader and more complex in terms of scope. It will
change the world in terms of “anytime, anyplace, anything in connectivity.”
IoT Enablers
• RFIDs: uses radio waves in order to electronically track the tags attached to each
physical object.
• Sensors: devices that are able to detect changes in an environment (ex: motion
detectors).
• Nanotechnology: as the name suggests, these are tiny devices with dimensions
usually less than a hundred nanometers.
• Smart networks: (ex: mesh topology).
Working with IoT Devices
• Collect and Transmit Data : For this purpose sensors are widely used they are used
as per requirements in different application areas.
• Actuate device based on triggers produced by sensors or processing devices: If
certain conditions are satisfied or according to user’s requirements if certain trigger is
activated then which action to perform that is shown by Actuator devices.
• Receive Information: From network devices, users or devices can take certain
information also for their analysis and processing purposes.
• Communication Assistance: Communication assistance is the phenomenon of
communication between 2 networks or communication between 2 or more IoT
devices of same or different networks. This can be achieved by different
communication protocols like: MQTT, Constrained Application Protocol, ZigBee,
FTP, HTTP etc.
CHARACTERISTICS OF IOT
Characteristics of the Internet of Things
1. Connectivity
Connectivity is an important requirement of the IoT infrastructure. Things of IoT should be
connected to the IoT infrastructure. Anyone, anywhere, anytime can connect, this should be
guaranteed at all times. For example, the connection between people through Internet devices
like mobile phones, and other gadgets, also a connection between Internet devices such as
routers, gateways, sensors, etc.
2. Intelligence and Identity
The extraction of knowledge from the generated data is very important. For example, a sensor
generates data, but that data will only be useful if it is interpreted properly. Each IoT device
has a unique identity. This identification is helpful in tracking the equipment and at times for
querying its status.
3. Scalability
The number of elements connected to the IoT zone is increasing day by day. Hence, an IoT
setup should be capable of handling the massive expansion. The data generated as an
outcome is enormous, and it should be handled appropriately.
4. Dynamic and Self-Adapting (Complexity)
IoT devices should dynamically adapt themselves to changing contexts and
scenarios. Assume a camera meant for surveillance. It should be adaptable to work in
different conditions and different light situations (morning, afternoon, and night).
5. Architecture
IoT Architecture cannot be homogeneous in nature. It should be hybrid, supporting different
manufacturers ‘ products to function in the IoT network. IoT is not owned by anyone
engineering branch. IoT is a reality when multiple domains come together.
6. Safety
There is a danger of the sensitive personal details of the users getting compromised when all
his/her devices are connected to the internet. This can cause a loss to the user. Hence, data
security is the major challenge. Besides, the equipment involved is huge. IoT networks may
also be at risk. Therefore, equipment safety is also critical.
7. Self Configuring
This is one of the most important characteristics of IoT. IoT devices are able to upgrade their
software in accordance with requirements with a minimum of user participation. Additionally,
they can set up the network, allowing for the addition of new devices to an already-existing
network.
8. Interoperability
IoT devices use standardized protocols and technologies to ensure they can communicate
with each other and other systems. Interoperability is one of the key characteristics of the
Internet of Things (IoT). It refers to the ability of different IoT devices and systems to
communicate and exchange data with each other, regardless of the underlying technology or
manufacturer.
Interoperability is critical for the success of IoT, as it enables different devices and systems to
work together seamlessly and provides a seamless user experience. Without interoperability,
IoT systems would be limited to individual silos of data and devices, making it difficult to
share information and create new services and applications.
To achieve interoperability, IoT devices, and systems use standardized communication
protocols and data formats. These standards allow different devices to understand and process
data in a consistent and reliable manner, enabling data to be exchanged between devices and
systems regardless of the technology used.
Examples of standards used in IoT
MQTT (Message Queuing Telemetry Transport): MQTT (Message Queuing Telemetry
Transport) is a publish/subscribe communication protocol used for IoT device
communication.
CoAP (Constrained Application Protocol): CoAP (Constrained Application Protocol) is a
lightweight communication protocol for IoT devices with limited resources.
Bluetooth Low Energy (BLE): Bluetooth Low Energy is a wireless communication
technology used for IoT devices with low power consumption requirements.
Wi-Fi: A wireless communication technology used for IoT devices that require high data
transfer rates.
Zigbee: A low-power, low-cost wireless communication technology used for IoT devices.
9. Embedded Sensors and Actuators
Embedded sensors and actuators are critical components of the Internet of Things (IoT). They
allow IoT devices to interact with their environment and collect and transmit data.
Sensors are devices that can detect changes in the environment, such as temperature, light,
sound, or movement. In IoT systems, sensors are embedded into devices, allowing them to
collect data about the environment.
Actuators are devices that can interact with the environment, such as turning on lights,
opening or closing doors, or controlling the speed of a motor. In IoT systems, actuators are
embedded into devices, allowing them to perform actions based on data collected by sensors.
Together, sensors and actuators allow IoT devices to collect data about the environment,
process that data, and take action based on the results. This makes it possible to automate a
wide range of processes and tasks, such as home automation, energy management, and
predictive maintenance.
10. Autonomous operation
Autonomous operation refers to the ability of IoT devices and systems to operate
independently and make decisions without human intervention. This is a crucial characteristic
of the Internet of Things (IoT) and enables a wide range of new applications and services.
In IoT systems, devices and systems are equipped with sensors, actuators, and processing
power, allowing them to collect and process data about the environment, make decisions
based on that data, and take action accordingly.
11. Data-driven
Data-driven is a key characteristic of the Internet of Things (IoT). IoT devices and systems
collect vast amounts of data from sensors and other sources, which can be analyzed and used
to make data-driven decisions.
In IoT systems, data is collected from embedded sensors, actuators, and other sources, such
as cloud services, databases, and mobile devices. This data is used to gain insights into the
environment, improve operational efficiency, and make informed decisions.
For example, an IoT system might use data from sensors to monitor the temperature and
humidity levels in a building, and then use that data to optimize heating, cooling, and
ventilation systems. This can result in significant energy savings and improved indoor air
quality.
12. Security
Security is a critical concern for the Internet of Things (IoT), as IoT devices and systems
handle sensitive data and are connected to critical infrastructure. The increasing number of
connected devices and the amount of data being transmitted over the Internet make IoT
systems a prime target for cyberattacks.
To secure IoT systems, multiple layers of security are necessary, including physical
security, network security, and data security.
Physical security involves protecting the physical devices from unauthorized access or
tampering. This can be achieved through measures such as secure enclosures, access controls,
and tamper-proofing.
Network security involves protecting the communication networks that connect IoT devices,
including Wi-Fi networks, cellular networks, and wired networks. This can be achieved
through encryption, secure authentication, and firewalls.
Data security involves protecting the data collected and transmitted by IoT devices and
systems. This can be achieved through encryption, secure storage, and access controls.
13. Ubiquity
Ubiquity refers to the widespread and pervasive presence of the Internet of Things (IoT)
devices and systems in our daily lives. The goal of IoT is to create a seamless and
interconnected world where devices and systems can communicate and share data seamlessly
and transparently.
14. Context Awareness
Context awareness refers to the ability of Internet of Things (IoT) devices and systems to
understand and respond to the environment and context in which they are operating. This is
achieved through the use of sensors and other technologies that can detect and collect data
about the environment.
Context awareness is a critical aspect of IoT, as it enables IoT devices and systems to make
decisions and take actions based on the context in which they are operating.

PHYSICAL DESIGN OF IOT


The physical design of Internet of Things (IoT) devices plays a critical role in their overall
functionality, usability, and effectiveness within various applications. Here’s a detailed
breakdown of the key components and considerations involved in the physical design of IoT:
1. Device Hardware
• Sensors and Actuators:
o Sensors: These components gather real-time data from the environment, such
as temperature, humidity, light levels, or motion. For instance, a temperature
sensor in a smart thermostat measures room temperature to optimize heating
or cooling.
o Actuators: These devices perform physical actions based on the sensor data or
commands received. For example, a motorized valve in an irrigation system
can open or close to control water flow based on moisture sensor readings.
• Microcontrollers and Processors:
o These are the "brains" of the IoT device, processing input data from sensors
and executing commands for actuators. Popular choices include Arduino,
Raspberry Pi, and specialized IoT chips like ESP8266. The choice of
microcontroller depends on factors such as processing power, energy
efficiency, and cost.
2. Connectivity
• Communication Protocols:
o IoT devices communicate through various protocols tailored to specific
requirements. Common protocols include:
▪ Wi-Fi: Suitable for high data rates over short distances, ideal for home
automation.
▪ Bluetooth: Used for short-range connections, typically in wearable
devices.
▪ Zigbee: Low-power and low-data-rate protocol, often used in home
automation.
▪ Cellular Networks: Used for applications requiring wide coverage,
such as fleet tracking.
• Network Architecture:
o The design of the network affects how devices connect and communicate.
Common architectures include:
▪ Star Topology: All devices connect to a central hub, simplifying
management but creating a single point of failure.
▪ Mesh Topology: Devices communicate directly with each other,
enhancing reliability and coverage but increasing complexity.
3. Physical Enclosure
• Design and Material:
o The enclosure protects internal components from environmental factors like
dust, moisture, and temperature fluctuations. Materials such as plastics (for
lightweight and cost-effectiveness), metals (for durability), and composites
(for a balance of weight and strength) are used based on application needs.
o For outdoor applications, enclosures may need to be weather-resistant or
ruggedized to withstand harsh conditions.
• Size and Form Factor:
o Devices are designed to be compact and lightweight for easy integration into
various environments, including homes, offices, and industrial settings. For
example, a smart bulb is designed to fit standard sockets without requiring
extensive modifications.
4. User Interface
• Displays and Controls:
o Depending on the device's purpose, it may include various user interface
elements such as buttons, touch screens, or LED indicators. For instance, a
smart thermostat might have a touchscreen interface for user adjustments and
status displays.
o Many IoT devices are designed for remote operation, relying on mobile apps
or web interfaces that provide intuitive control and monitoring, enhancing user
experience.
5. Security Features
• Physical Security:
o Enclosures can include tamper-resistant designs, locking mechanisms, or
secure mounting options to prevent unauthorized access or theft.
o Physical design should also consider the placement of devices to minimize
exposure to potential tampering.
• Data Security:
o Integrating hardware security modules (HSMs) allows for secure key
management and encryption, safeguarding data during transmission and
storage.
o Implementing secure boot processes and regular firmware updates also
enhances device security against vulnerabilities.
6. Deployment Considerations
• Environmental Factors:
o Devices must be designed to operate effectively in various environmental
conditions, such as extreme temperatures, high humidity, or exposure to
chemicals. For example, outdoor sensors need to be water-resistant and UV-
stabilized.
o Considerations also include compliance with industry standards and
regulations for specific applications (e.g., medical, industrial).
• Maintenance and Accessibility:
o The design should facilitate easy access for maintenance, repairs, or battery
replacement, minimizing downtime. Devices with user-replaceable batteries or
easy-to-open enclosures are more user-friendly.
FUNCTIONAL BLOCKS OF IOT
The Internet of Things (IoT) is a rapidly growing industry, with more and more devices
becoming connected on a regular basis. The Internet of Things devices range from small
sensors to huge machines and systems, but they all have one thing in common: they generate
data. IoT systems use functional blocks to make sense of this data and extract value from it.
These blocks are distinct components of the IoT system that carry out specialized functions.
IoT Functional Blocks
IoT systems are composed of a number of building blocks, including sensors/actuators,
connectivity, security, services, etc. The functional blocks are responsible for sensing,
verification, actuation, management, and communication.
These functional blocks are made up of devices that handle interactions between a web server
and the client, enable controls and monitoring functions, manage data transfer, secure the IoT
system through authentication and various purposes, and offer an interface for monitoring
and managing various concepts. Let’s gather more information about the IoT Functional
Blocks.
Sensor/Actuator block
The sensor/actuator block serves as the data entry point in an IoT system. Sensors collect data
from their surroundings, whereas actuators drive physical processes. Sensors gather data on
temperature, humidity, light, motion, and other variables, whereas actuators turn on lights,
open doors, and control machines. These gadgets work together to collect data and operate in
the physical world.
Connectivity Block
Once the sensor/actuator block has collected data, it must be sent to the remainder of the
system. This is when the connection block enters the picture. The connectivity block is in
charge of creating and managing communication channels amongst IoT system devices. This
can be accomplished with the use of several technologies such as Wi-Fi, Bluetooth, ZigBee,
and cellular networks.
Data Processing Block
The obtained data is examined and processed in the data processing block. This block is in
charge of filtering out noise and irrelevant data, converting the data into an easily studied
format, and recognizing patterns and anomalies in the data. This block can also execute real-
time analysis, enabling speedy data-driven decisions.
Application Block
The application block is the component of the IoT system that gives value to the end user.
This block is in charge of utilizing the processed data to provide a specified function or
service. An application block, for example, could be used to provide insights into energy
usage in a building or to adjust the temperature in a greenhouse.
Security Block
The security block is in charge of assuring the IoT system's security and protection against
illegal access. This block is in charge of authentication and authorization, as well as data
encryption during transmission and storage. It also handles intrusion detection and response,
assisting in the prevention and mitigation of threats.
Management Block
The management block is in charge of overseeing the overall operation of the IoT system.
This block is capable of handling device configuration, firmware updates, and system
monitoring. It can also give analytics and reporting, allowing system administrators to
understand how the system is operating and find areas for improvement.
Advantages of IoT Functional Blocks
Scalability - IoT Scalability is built into Functional Blocks, allowing enterprises to add new
devices and services to their IoT system as needed. The capacity to scale assures that an IoT
system can grow and react to changing business needs and future technology.
Interoperability - IoT Functional Blocks is a standardized architecture for developing IoT
solutions. This standardization means that devices and services from various suppliers may
function seamlessly together, enhancing interoperability and lowering integration costs.
Modularity - Because IoT Functional Blocks are modular, they may be swapped, modified,
or added as needed. Because of this versatility, enterprises can select the optimal components
for their IoT system and easily swap out components as needed.
Flexibility - IoT Functional Blocks offer a variety of deployment choices. Depending on their
needs, businesses can implement an IoT system on-premises, in the cloud, or in a hybrid
approach.
SENSING AND ACTUATION

Sensor and actuators are basic elements in numerous electrical and mechanical structures. On
the same note, sensors are tasked with the responsibility of identifying changes within an
environment while actuators are tasked with the responsibility of performing certain actions
in response to these detections. It is important for anyone who is employed in certain
professions, to have clear distinctions between these two, should work within robotics,
automation, as well as control systems.
Sensor
Sensor is a device used for the conversion of physical events or characteristics into the
electrical signals. This is a hardware device that takes the input from environment and gives
to the system by converting it. For example, a thermometer takes the temperature as physical
characteristic and then converts it into electrical signals for the system.
Types of Sensors
• Temperature Sensors: Take temperatures.
• Light Sensors: Light intensity sensors: It has the function of detecting the intensity of
the light.
• Pressure Sensors: To use it to measure pressure in gases or liquids.
• Motion Sensors: Recognize motion in an established region.
Advantages of Sensors
• Offer timely and accurate information as this is a critical requirement by the high
release frequency.
• Support automation and management of systems.
• Improve safety by maintaining check on important parameters.
Disadvantages of Sensors
• Sometimes can be costly particularly the high precision sensors.
• It can sometimes need some adjustments and can also probably require maintenance
in the long run.
• Interference from the environment is easy in this process.

Actuator
Actuator is a device that converts the electrical signals into the physical events or
characteristics. It takes the input from the system and gives output to the environment. For
example, motors and heaters are some of the commonly used actuators.
Types of Actuators
• Linear Actuators: Utilize a linear motion to convert energy, Kinetic/pendulum.
• Rotary Actuators: This will affect the creation of rotational motion.
• Hydraulic Actuators: How does fluid power gives motion.
• Pneumatic Actuators: Function with use of compressed air.
Advantages of Actuators
• Assist in providing a fine level of control of mechanical installations.
• They should enable automation and therefore minimize the need for intervention of
human participants.
• Available in a range of variations and suitability in multiple operations ranging from
everyday uses to industrial use.
Disadvantages of Actuators
• May consume much power in its operation particularly when used in places that
involve much power such as in large industries.
• May be large and costly to both install and maintain.
• As a disadvantage there is a circumstance that, with time the component is liable to
mechanical wear and tear.
Difference between Sensor and Actuator

SENSOR ACTUATOR

It converts physical characteristics into It converts electrical signals into physical


electrical signals. characteristics.

It takes input from output conditioning


It takes input from environment.
unit of system.

It gives output to input conditioning unit of


It gives output to environment.
system.

Sensor generated electrical signals. Actuator generates heat or motion.

It is placed at input port of the system. It is placed at output port of the system.

It is used to measure the continuous and


It is used to measure the physical quantity.
discrete process parameters.

It gives information to the system about It accepts command to perform a


environment. function.

Example: Photo-voltaic cell which converts Example: Stepper motor where electrical
light energy into electrical energy. energy drives the motor.

BASICS OF NETWORKING
Networking is a fundamental aspect of the Internet of Things (IoT), enabling devices to
communicate, share data, and interact with each other and central systems. Here’s an
overview of the key concepts, components, and protocols involved in IoT networking.
1. IoT Architecture
Layers of IoT Architecture:
• Perception Layer: This layer consists of sensors and actuators that gather data from
the environment and perform actions based on commands.
• Network Layer: This layer facilitates communication between devices and the
central system, handling data transmission.
• Application Layer: This layer encompasses the software and services that process
data, providing meaningful insights and functionalities to users.
2. Connectivity Options
IoT devices connect to the internet through various methods, each suited to different
applications and requirements:
• Wired Connections:
o Ethernet: Reliable for stationary devices in a local area network (LAN) but
less flexible for mobile or remote applications.
• Wireless Connections:
o Wi-Fi: High-speed, suitable for devices that require substantial data transfer
(e.g., cameras, smart appliances) but has limited range and power
consumption.
o Bluetooth: Ideal for short-range communication (up to 100 meters),
commonly used in wearables and smart home devices.
o Zigbee: A low-power, low-data-rate protocol designed for home automation
and sensor networks, typically in a mesh topology.
o LoRaWAN: A long-range, low-power protocol designed for remote
applications, allowing devices to communicate over several kilometers.
o NB-IoT: A cellular technology optimized for IoT, providing extended
coverage and low power consumption.
3. Communication Protocols
Protocols are critical for data transmission between IoT devices and networks. Key protocols
include:
• MQTT (Message Queuing Telemetry Transport): A lightweight messaging protocol
designed for low-bandwidth, high-latency networks. It uses a publish-subscribe
model, making it efficient for many IoT applications.
• CoAP (Constrained Application Protocol): A specialized protocol for constrained
devices and networks, similar to HTTP but optimized for low-power and low-
bandwidth environments.
• HTTP/HTTPS: Standard protocols for web communication, often used in
applications where devices need to interact with cloud services or web interfaces.
• AMQP (Advanced Message Queuing Protocol): A messaging protocol that enables
message-oriented middleware, allowing reliable communication between devices.
4. Network Topologies
The arrangement of devices in a network affects communication efficiency and reliability.
Common topologies include:
• Star Topology: All devices connect to a central hub or gateway. This structure is easy
to manage but can become a single point of failure.
• Mesh Topology: Devices communicate directly with each other, creating multiple
pathways for data. This topology enhances reliability and coverage but adds
complexity.
• Tree Topology: A hybrid of star and bus topologies, organizing devices in a
hierarchical manner, suitable for larger networks.
5. Data Management and Processing
Once data is transmitted over the network, it must be managed effectively:
• Edge Computing: Data is processed near the source (on the device or local gateway)
to reduce latency and bandwidth usage. This is essential for time-sensitive
applications.
• Cloud Computing: Centralized processing and storage of data. Cloud platforms
enable scalability, data analytics, and long-term storage, facilitating complex
applications.
6. Security Considerations
Networking in IoT also involves critical security measures:
• Encryption: Ensures that data transmitted over the network is secure from
eavesdropping or tampering.
• Authentication: Validates devices and users to prevent unauthorized access to the
network.
• Network Segmentation: Isolates IoT devices from other network segments to limit
exposure and potential vulnerabilities.
COMMUNICATION PROTOCOLS
Message Queue Telemetry Transport (MQTT)
Designed to be lightweight, so it can work in very low bandwidth networks, MQTT allows
communication between nodes in both reliable and unreliable networks. MQTT follows a
publish/subscribe architecture, meaning that there are nodes (brokers) that make the
information available, while others (clients) can read the available information after
subscribing by accessing the corresponding URL.
A use case of MQTT is in a smart factory where there are temperature sensors installed along
with the production plant. The installed sensors will connect to the MQTT broker and will
publish the data within sensor topics, as follows:
sensors/temperature/assemblyLineInit
Afterward, the MQTT clients, which can be of several types and quantities, will subscribe to
the same topic in order to read the temperature data. An example of an MQTT architecture
can be seen in Figure 1.

Figure 1. MQTT's publish/subscribe architecture. Image used courtesy of MQTT

In addition, MQTT defines three levels of quality of service, depending upon the reliability,
from lowest to highest:
• Level 0: there is no guarantee of the message delivery.
• Level 1: the delivery is guaranteed, but it is possible to receive duplicate messages.
• Level 2: the delivery is guaranteed and there will be no duplicates.

HyperText Transfer Protocol (HTTP)


This protocol has been the origin of data communication for the World Wide Web (WWW),
so logically it is being used in the IoT world. However, it is not optimized for it because of
the following:
• The HTTP is made for two systems communicating to each other at a time, not more,
so it is time and energy-consuming to connect several sensors to get information.
• The HTTP is unidirectional, made for one system (client) to be sending one message
to another one (server). This makes it quite hard to escalate an IoT solution.
• Power consumption: HTTP relies on Transmission Control Protocol (TCP), which
requires a lot of computing resources, so it is not suitable for battery-powered
applications.
Constrained Application Protocol (CoAP)
CoAP is a web transfer protocol to be used with limited networks with low bandwidth and
low availability. It follows a client/server architecture and is built similarly to HTTP,
supporting the REST model: servers make resources available with an URL, and clients can
make requests of types GET, POST, PUT and DELETE.
The CoAP communication links are 1:1 and UDP-based, so the delivery is not guaranteed.
CoAP is made to work in highly congested networks, where nodes do not have a lot of
intelligence and are not always working.
Data Distribution Service (DDS)
Similar to MQTT, DDS follows a publish-subscribe methodology, with the main difference
being that there are no brokers. It means that all publishers (i.e., temperature sensors) and
subscribers (i.e., mobile phones) are all connected to the same network. This network is
known as Global Data Space (GDS) and it interconnects each node with all the other ones to
avoid bottlenecks. An example of the DDS GDS can be seen in Figure 2.

Figure 2. A DDS Global Data Space. Image used courtesy of the DDS Foundation

Furthermore, any node can leave or join the network, since they are dynamically discovered.
WebSocket
Linked to the HTTP protocol, the WebSocket technology establishes a TCP connection
between a browser and a server, and then both of them exchange information until the
connection is closed. Figure 3 shows a high-level comparison between HTTP and
WebSocket.

Figure 3. Comparison between HTTP and WebSocket. Image used courtesy of Scaleway
Although this protocol can be seen as an improvement of the HTTP connection, the
WebSocket is still very overloaded and heavy for IoT applications.
Advanced Message Queue Protocol (AMQP)
In the beginning, AMQP was not initially created for IoT applications, but for banking
environments. AMQP accepts publish/subscribe architectures, as well as request/response
types. It is TCP-based, so delivery is guaranteed, as well as acknowledgment, which makes
this protocol reliable, with the consequent overhead message reliability.
Compared to MQTT, AMQP offers two Quality of Service levels:
• At most once: the sender does not wait until having an acknowledgment from the
receiver to delete a message.
• At least once: for each message, the sender will receive an acknowledgment from the
receiver before deleting the message. In a case where the acknowledgment is lost, the
message is re-sent.
• Exactly once: the messages are sent only once. It requires special coordination
between the sender and the receiver.
SENSOR NETWORKS
Wireless Sensor Network (WSN), is an infrastructure-less wireless network that is deployed
in a large number of wireless sensors in an ad-hoc manner that is used to monitor the system,
physical, or environmental conditions.
Sensor nodes are used in WSN with the onboard processor that manages and monitors the
environment in a particular area. They are connected to the Base Station which acts as a
processing unit in the WSN System. The base Station in a WSN System is connected through
the Internet to share data. WSN can be used for processing, analysis, storage, and mining of
the data.

Wireless Sensor Network Architecture


A Wireless Sensor Network (WSN) architecture is structured into three main layers:
• Physical Layer: This layer connects sensor nodes to the base station using
technologies like radio waves, infrared, or Bluetooth. It ensures the physical
communication between nodes and the base station.
• Data Link Layer: Responsible for establishing a reliable connection between sensor
nodes and the base station. It uses protocols such as IEEE 802.15.4 to manage data
transmission and ensure efficient communication within the network.
• Application Layer: Enables sensor nodes to communicate specific data to the base
station. It uses protocols like ZigBee to define how data is formatted, transmitted, and
received, supporting various applications such as environmental monitoring or
industrial control.
These layers work together to facilitate the seamless operation and data flow within a
Wireless Sensor Network, enabling efficient monitoring and data collection across diverse
applications.
WSN Network Topologies
Wireless Sensor Networks (WSNs) can be organized into different network topologies based
on their application and network type. Here are the most common types:
• Bus Topology: In a Bus Topology, multiple nodes are connected to a single line or
bus. Data travels along this bus from one node to the next. It’s a simple layout often
used in smaller networks.
• StarTopology: Star Topology have a central node, called the master node, which
connects directly to multiple other nodes. Data flows from the master node to the
connected nodes. This topology is efficient for centralized control.
• Tree Topology: Tree Topology arrange nodes in a hierarchical structure resembling a
tree. Data is transmitted from one node to another along the branches of the tree
structure. It’s useful for expanding coverage in hierarchical deployments.
• Mesh Topology: Mesh Topology feature nodes interconnected with one another,
forming a mesh-like structure. Data can travel through multiple paths from one node
to another until it reaches its destination. This topology offers robust coverage and
redundancy.
Each topology has its advantages and is chosen based on factors such as coverage area,
scalability, and reliability requirements for the specific WSN application.
Types of Wireless Sensor Networks (WSN)
Terrestrial Wireless Sensor Networks
• Used for efficient communication between base stations.
• Consist of thousands of nodes placed in an ad hoc (random) or structured (planned)
manner.
• Nodes may use solar cells for energy efficiency.
• Focus on low energy use and optimal routing for efficiency.
Underground Wireless Sensor Networks
• Nodes are buried underground to monitor underground conditions.
• Require additional sink nodes above ground for data transmission.
• Face challenges like high installation and maintenance costs.
• Limited battery life and difficulty in recharging due to underground setup.
Underwater Wireless Sensor Networks
• Deployed in water environments using sensor nodes and autonomous underwater
vehicles.
• Face challenges like slow data transmission, bandwidth limitations, and signal
attenuation.
• Nodes have restricted and non-rechargeable power sources.
Multimedia Wireless Sensor Networks
• Used to monitor multimedia events such as video, audio, and images.
• Nodes equipped with microphones and cameras for data capture.
• Challenges include high power consumption, large bandwidth requirements, and
complex data processing.
• Designed for efficient wireless data compression and transmission.
Mobile Wireless Sensor Networks (MWSNs)
• Composed of mobile sensor nodes capable of independent movement.
• Offer advantages like increased coverage area, energy efficiency, and channel
capacity compared to static networks.
• Nodes can sense, compute, and communicate while moving in the environment.
Each type of Wireless Sensor Network is tailored to specific environmental conditions and
applications, utilizing different technologies and strategies to achieve efficient data collection
and communication.
Applications of WSN
• Internet of Things (IoT)
• Surveillance and Monitoring for security, threat detection
• Environmental temperature, humidity, and air pressure
• Noise Level of the surrounding
• Medical applications like patient monitoring
• Agriculture
• Landslide Detection
Challenges of WSN
• Quality of Service
• Security Issue
• Energy Efficiency
• Network Throughput
• Performance
• Ability to cope with node failure
• Cross layer optimisation
• Scalability to large scale of deployment
A modern Wireless Sensor Network (WSN) faces several challenges, including:
• Limited power and energy: WSNs are typically composed of battery-powered
sensors that have limited energy resources. This makes it challenging to ensure that
the network can function for long periods of time without the need for frequent
battery replacements.
• Limited processing and storage capabilities: Sensor nodes in a WSN are typically
small and have limited processing and storage capabilities. This makes it difficult to
perform complex tasks or store large amounts of data.
• Heterogeneity: WSNs often consist of a variety of different sensor types and nodes
with different capabilities. This makes it challenging to ensure that the network can
function effectively and efficiently.
• Security: WSNs are vulnerable to various types of attacks, such as eavesdropping,
jamming, and spoofing. Ensuring the security of the network and the data it collects is
a major challenge.
• Scalability: WSNs often need to be able to support a large number of sensor nodes
and handle large amounts of data. Ensuring that the network can scale to meet these
demands is a significant challenge.
• Interference: WSNs are often deployed in environments where there is a lot of
interference from other wireless devices. This can make it difficult to ensure reliable
communication between sensor nodes.
• Reliability: WSNs are often used in critical applications, such as monitoring the
environment or controlling industrial processes. Ensuring that the network is reliable
and able to function correctly in all conditions is a major challenge.
Components of WSN
• Sensors: Sensors in WSN are used to capture the environmental variables and which
is used for data acquisition. Sensor signals are converted into electrical signals.
• Radio Nodes: It is used to receive the data produced by the Sensors and sends it to
the WLAN access point. It consists of a microcontroller, transceiver, external
memory, and power source.
• WLAN Access Point: It receives the data which is sent by the Radio nodes
wirelessly, generally through the internet.
• Evaluation Software: The data received by the WLAN Access Point is processed by
a software called as Evaluation Software for presenting the report to the users for
further processing of the data which can be used for processing, analysis, storage, and
mining of the data.
Advantages
• Low cost: WSNs consist of small, low-cost sensors that are easy to deploy, making
them a cost-effective solution for many applications.
• Wireless communication: WSNs eliminate the need for wired connections, which
can be costly and difficult to install. Wireless communication also enables flexible
deployment and reconfiguration of the network.
• Energy efficiency: WSNs use low-power devices and protocols to conserve energy,
enabling long-term operation without the need for frequent battery replacements.
• Scalability: WSNs can be scaled up or down easily by adding or removing sensors,
making them suitable for a range of applications and environments.
• Real-time monitoring: WSNs enable real-time monitoring of physical phenomena in
the environment, providing timely information for decision making and control.
Disadvantages
• Limited range: The range of wireless communication in WSNs is limited, which can
be a challenge for large-scale deployments or in environments with obstacles that
obstruct radio signals.
• Limited processing power: WSNs use low-power devices, which may have limited
processing power and memory, making it difficult to perform complex computations
or support advanced applications.
• Data security: WSNs are vulnerable to security threats, such as eavesdropping,
tampering, and denial of service attacks, which can compromise the confidentiality,
integrity, and availability of data.
• Interference: Wireless communication in WSNs can be susceptible to interference
from other wireless devices or radio signals, which can degrade the quality of data
transmission.
• Deployment challenges: Deploying WSNs can be challenging due to the need for
proper sensor placement, power management, and network configuration, which can
require significant time and resources.
• while WSNs offer many benefits, they also have limitations and challenges that must
be considered when deploying and using them in real-world applications.

UNIT – 2 : MACHINE TO MACHINE COMMUNICATIONS


DIFFERENCE BETWEEN IOT AND M2M
1. Internet of Things : IOT is known as the Internet of Things where things are said to be the
communicating devices that can interact with each other using a communication media.
Usually every day some new devices are being integrated which uses IoT devices for its
function. These devices use various sensors and actuators for sending and receiving data over
the internet. It is an ecosystem where the devices share data through a communication media
known as the internet or Iot is an ecosystem of connected physical object that are accessible
through internet. Iot means anything which can be connected to internet and can be controlled
or monitored using internet from smart devices or PC.
2. Machine to Machine : This is commonly known as Machine to machine communication.
It is a concept where two or more than two machines communicate with each other without
human interaction using a wired or wireless mechanism. M2M is an technology that helps the
devices to connect between devices without using internet. M2M communications offer
several applications such as security, tracking and tracing, manufacturing and facility
management.
M2M is also named as Machine Type Communication (MTC) in 3GPP ( 3rd Generation
Partnership Project).
M2M is communication could carried over mobile networks, for ex- GSM-GPRS, CDMA
EVDO Networks .
In M2M communication, the role of mobile networks is largely confined to server as a
transport networks.
M2M is only subset of IoT .
Difference between IoT and M2M :

Basis of IoT M2M

Abbreviation Internet of Things Machine to Machine

Devices have objects that are Some degree of intelligence


Intelligence
responsible for decision making is observed in this.

The connection is via Network


Connection type The connection is a point to
and using various communication
used point
types.

Traditional protocols and


Communication Internet protocols are used such
communication technology
protocol used as HTTP, FTP, and Telnet.
techniques are used

Data is shared between other


Data is shared with only the
Data Sharing applications that are used to
communicating parties.
improve the end-user experience.

Internet connection is required for Devices are not dependent on


Internet
communication the Internet.

Type of It supports point-to-point


It supports cloud communication
Communication communication.
Basis of IoT M2M

Involves the usage of both Mostly hardware-based


Computer System
Hardware and Software. technology

A large number of devices yet


Scope Limited Scope for devices.
scope is large.

Business Type Business 2 Business(B2B) and


Business 2 Business (B2B)
used Business 2 Consumer(B2C)

There is no support for Open


Open API support Supports Open API integrations.
APIs

It requires Generic commodity devices. Specialized device solutions.

Communication and device


Centric Information and service centric
centric.

Vertical system solution


Approach used Horizontal enabler approach
approach .

Devices/sensors, connectivity, Device, area networks,


Components
data processing, user interface gateway, Application server.

Smart wearables, Big Data and Sensors, Data and


Examples
Cloud, etc. Information, etc.

INTEROPERABILITY IN IOT
Interoperability in the Internet of Things (IoT) refers to the ability of different IoT devices,
systems, and platforms to communicate, exchange data, and work together seamlessly. This
capability is crucial for creating cohesive and effective IoT ecosystems that enhance
functionality and user experience. Here’s a detailed overview of interoperability in IoT, its
importance, challenges, and potential solutions.
1. Importance of Interoperability
• Integration Across Devices: Interoperability allows devices from different
manufacturers and platforms to work together. This integration is essential for
creating smart environments, such as smart homes, where various devices
(thermostats, lights, security systems) need to communicate.
• Enhanced Functionality: By enabling devices to share data and commands,
interoperability enhances the overall functionality of IoT systems. For example, a
smart thermostat that communicates with weather data can optimize heating and
cooling based on real-time conditions.
• Scalability: Interoperable systems can easily incorporate new devices and
technologies, allowing for scalable solutions. This flexibility is vital as IoT
ecosystems grow and evolve.
• Improved User Experience: Seamless interaction between devices enhances the user
experience, allowing for centralized control and automation without the need for
complex setups.
2. Challenges to Interoperability
• Diverse Standards and Protocols: The IoT landscape includes a variety of
communication protocols (e.g., MQTT, CoAP, Zigbee) and data formats (e.g., JSON,
XML), making it difficult for devices to communicate across different systems.
• Vendor Lock-In: Many manufacturers develop proprietary solutions that limit
compatibility with devices from other vendors. This lock-in can hinder the adoption
of a broader range of products.
• Security and Privacy Concerns: Ensuring that interoperable systems maintain
security and privacy while exchanging data is a significant challenge, as
vulnerabilities can arise when different systems interact.
• Data Semantics: Differences in data representation and meaning can lead to
misunderstandings between devices. For example, temperature readings from one
sensor may be interpreted differently by another system if not standardized.
3. Potential Solutions for Interoperability
• Standardization: Developing and adopting universal standards for communication
protocols, data formats, and interfaces can significantly enhance interoperability.
Organizations like the Internet Engineering Task Force (IETF) and the Institute of
Electrical and Electronics Engineers (IEEE) work on establishing these standards.
• Middleware Solutions: Middleware can serve as an intermediary layer that translates
and facilitates communication between different IoT devices and platforms, enabling
interoperability without requiring changes to the underlying systems.
• APIs (Application Programming Interfaces): Well-defined APIs allow different
systems to interact by providing a set of protocols and tools for building software
applications. APIs can help unify communication among diverse devices and
platforms.
• Data Interoperability Frameworks: Implementing frameworks that ensure
consistent data representation and semantics can help devices understand each other’s
data formats and meanings.
• Edge Computing: By processing data closer to the source, edge computing can
facilitate interoperability by aggregating and translating data from various devices
before sending it to the cloud, thereby reducing reliance on centralized systems.
4. Future Trends in Interoperability
• Increased Use of Open Standards: As the IoT ecosystem matures, the adoption of
open standards and protocols is expected to grow, facilitating interoperability and
reducing vendor lock-in.
• AI and Machine Learning: These technologies can enhance interoperability by
enabling devices to learn from each other and adapt to different communication styles
and data formats.
• Decentralized Solutions: Blockchain and decentralized technologies may provide
new approaches to ensure secure, transparent interoperability among IoT devices
without relying on centralized control.
INTRODUCTION TO ARDUINO PROGRAMMING
Arduino is an open-source electronics platform based on easy-to-use hardware and software.
It has become a popular choice for Internet of Things (IoT) projects due to its simplicity,
flexibility, and extensive community support. This introduction covers the basics of Arduino
programming in the context of IoT, including its architecture, programming environment, and
how it can be used in various IoT applications.
1. What is Arduino?
• Hardware: Arduino boards come with microcontrollers that can be programmed to
perform various tasks. Popular models include Arduino Uno, Arduino Mega, and
Arduino Nano. Each board has input/output (I/O) pins, analog and digital interfaces,
and can connect to sensors and actuators.
• Software: The Arduino Integrated Development Environment (IDE) is a user-friendly
platform for writing, compiling, and uploading code to Arduino boards. The IDE
supports C/C++ programming languages, with a simplified syntax that makes it
accessible to beginners.
2. Arduino Architecture
Using the above image as a reference, the labeled components of the board respectively are-
1. USB: can be used for both power and communication with the IDE
2. Barrel Jack: used for power supply
3. Voltage Regulator: regulates and stabilizes the input and output voltages
4. Crystal Oscillator: keeps track of time and regulates processor frequency
5. Reset Pin: can be used to reset the Arduino Uno
6. 3.3V pin: can be used as a 3.3V output
7. 5V pin: can be used as a 5V output
8. GND pin: can be used to ground the circuit
9. Vin pin: can be used to supply power to the board
10. Analog pins(A0-A5): can be used to read analog signals to the board
11. Microcontroller(ATMega328): the processing and logical unit of the board
12. ICSP pin: a programming header on the board also called SPI
13. Power indicator LED: indicates the power status of the board
14. RX and TX LEDs: receive(RX) and transmit(TX) LEDs, blink when sending or
receiving serial data respectively
15. Digital I/O pins: 14 pins capable of reading and outputting digital signals; 6 of these
pins are also capable of PWM
16. AREF pins: can be used to set an external reference voltage as the upper limit for the
analog pins
17. Reset button: can be used to reset the board
Getting started with the Arduino IDE
Now that you’re familiar with the hardware, its time to learn about the development
environment using which you’re going to program your Uno. The Arduino IDE is the best
place to start your journey in programming your Uno. To get started, visit this page and
download the latest build of the Arduino IDE for your Mac or PC. Go ahead and install the
IDE on your PC or Mac and open it.

As you open the IDE, you’ll be greeted by a window similar to the one shown in the above
image. The text editor is where you’ll be writing your code; you’ll use the verify button to
compile and debug the written program, the save button to save the program and the upload
button to upload the program to the board. Before you click on the upload button, it is
necessary to select your board, Uno in this case, from the tools menu in the Menu Bar. After
you choose your appropriate board, make sure you specify the correct port on your PC or
Mac that you’ve connected your Uno to, in the IDE.

• Microcontroller: The core component that executes the code. It handles input from
sensors and controls outputs to actuators.
• I/O Pins: These pins are used to connect sensors (input) and actuators (output).
Digital pins can read or write binary signals, while analog pins can read varying
voltage levels.
• Power Supply: Arduino boards can be powered via USB or external power sources,
allowing for flexibility in deployment.
3. Getting Started with Arduino Programming
• Installation: Download and install the Arduino IDE from the official Arduino
website. The IDE is available for Windows, macOS, and Linux.
• Basic Programming Structure:
o Setup Function: This function runs once at the beginning and is used to
initialize settings (e.g., setting pin modes).
o Loop Function: This function runs repeatedly, allowing the program to
perform tasks continuously (e.g., reading sensor data, controlling outputs).
Example Code:
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Initialize the built-in LED pin as an output
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED on
delay(1000); // Wait for a second
digitalWrite(LED_BUILTIN, LOW); // Turn the LED off
delay(1000); // Wait for a second
}
4. Integrating Arduino with IoT
• Sensors and Actuators: Arduino can interface with various sensors (e.g.,
temperature, humidity, motion) and actuators (e.g., motors, relays). This capability
allows it to collect data from the environment and perform actions based on that data.
• Communication Modules: To connect Arduino to the internet, various
communication modules can be used:
o Wi-Fi (ESP8266, ESP32): Enables wireless connectivity for IoT applications.
o Ethernet Shield: Provides wired internet access.
o LoRa or Zigbee Modules: For low-power, long-range communication.
• Cloud Integration: Arduino can send data to cloud platforms (e.g., ThingSpeak,
Blynk, AWS IoT) for storage, analysis, and remote monitoring. This integration is
crucial for IoT applications, allowing users to access real-time data from anywhere.
5. Applications of Arduino in IoT
• Smart Home: Control appliances, lighting, and security systems remotely.
• Environmental Monitoring: Collect data on air quality, temperature, and humidity.
• Agriculture: Monitor soil moisture levels and automate irrigation systems.
• Wearable Devices: Track health metrics like heart rate and activity levels.
6. Resources for Learning Arduino Programming
• Official Documentation: The Arduino website provides extensive documentation,
tutorials, and examples.
• Community Forums: The Arduino community is active and helpful, making it a
great resource for troubleshooting and project ideas.
• Online Courses: Platforms like Coursera, Udemy, and YouTube offer courses
specifically focused on Arduino programming and IoT applications.

INTEGRATION OF SENSORS AND ACTUATORS WITH ARDUINO


Integrating sensors and actuators with an Arduino is central to creating interactive, automated
systems. Arduino’s microcontroller allows you to read data from various sensors, process that
data, and trigger actuators in response. Here’s an in-depth look at how to connect and control
different types of sensors and actuators with Arduino.
1. Setting up Arduino for Sensor and Actuator Integration
• Digital and Analog Pins: Arduino boards (like the Uno) have digital pins (for reading
digital sensors and controlling digital actuators) and analog pins (for reading analog
sensors).
• Power Supply: Most sensors and actuators operate within the 3.3V-5V range, which
the Arduino can supply. High-power actuators (e.g., motors) may require an external
power supply.
• Libraries: Many sensors and actuators have dedicated libraries that simplify code,
making it easy to initialize and read/write data to/from the device.
2. Integrating Sensors with Arduino
Sensors measure physical properties like temperature, light, motion, distance, etc., and
convert them into electrical signals for the Arduino to interpret.
Examples of Common Sensors:
1. Temperature and Humidity Sensors (e.g., DHT11, DHT22)
o Wiring: Connect the VCC and GND to the 5V and GND pins, respectively,
and connect the DATA pin to a digital input.
o Function: DHT sensors provide temperature and humidity data that can be
useful for environment monitoring or climate control.
o Code:
#include <DHT.h>
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT11 or DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
float temp = dht.readTemperature();
float humidity = dht.readHumidity();
Serial.print("Temperature: "); Serial.print(temp); Serial.print("°C ");
Serial.print("Humidity: "); Serial.print(humidity); Serial.println("%");
delay(2000);
}
2. Ultrasonic Distance Sensor (e.g., HC-SR04)
o Wiring: Connect the VCC and GND to 5V and GND, the Trig pin to a digital
output pin, and the Echo pin to a digital input pin.
o Function: Measures the time it takes for an ultrasonic pulse to travel to an
object and bounce back, helping detect distances for applications like obstacle
avoidance in robots.
o Code:
#define TRIG 9
#define ECHO 10
void setup() {
Serial.begin(9600);
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
}
void loop() {
digitalWrite(TRIG, LOW);
delayMicroseconds(2);
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);
long duration = pulseIn(ECHO, HIGH);
float distance = (duration * 0.0343) / 2;
Serial.print("Distance: "); Serial.print(distance); Serial.println(" cm");
delay(500);
}
3. Light Sensor (e.g., LDR or Light Dependent Resistor)
o Wiring: Connect the LDR in series with a resistor between VCC and GND.
The midpoint (between the LDR and resistor) connects to an analog input pin.
o Function: Measures light levels and is used in applications like automatic
lighting systems.
o Code:
const int lightPin = A0;
void setup() {
Serial.begin(9600);
}

void loop() {
int lightLevel = analogRead(lightPin);
Serial.print("Light Level: "); Serial.println(lightLevel);
delay(500);
}
3. Integrating Actuators with Arduino
Actuators enable Arduino to take action based on sensor readings, such as moving parts,
turning on lights, or making sounds.
Examples of Common Actuators:
1. LEDs (Light Emitting Diodes)
o Wiring: Connect the anode to a digital output pin through a resistor (e.g., 220
ohms), and the cathode to GND.
o Function: LEDs are often used for visual feedback, indicating statuses like
system power, alert, or active states.
o Code:
const int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
2. Servo Motors
o Wiring: Connect the servo signal wire to a PWM-enabled digital output pin,
and power the servo through 5V and GND (consider using an external power
supply for larger servos).
o Function: Provides precise rotational movement, making it ideal for robotics,
automated arms, and control surfaces.
o Code:
#include <Servo.h>
Servo myservo;
void setup() {
myservo.attach(9);
}
void loop() {
myservo.write(90); // Move to 90 degrees
delay(1000);
myservo.write(0); // Move to 0 degrees
delay(1000);
myservo.write(180); // Move to 180 degrees
delay(1000);
}
3. Relays for High-Power Devices
o Wiring: Connect the control side of the relay module to a digital output pin,
and connect the device you want to control (e.g., lamp) to the relay’s load side.
o Function: Allows Arduino to control high-power devices like fans or lights,
which would draw too much current to connect directly.
o Code:
const int relayPin = 7;
void setup() {
pinMode(relayPin, OUTPUT);
}
void loop() {
digitalWrite(relayPin, HIGH); // Turn on the device
delay(2000);
digitalWrite(relayPin, LOW); // Turn off the device
delay(2000);
}
4. Combining Sensors and Actuators for Smart Systems
Using sensors and actuators together allows for creating "smart" systems that can sense the
environment and react accordingly. Here are a few examples:
• Smart Lighting System: Combine an LDR and LED. When light levels are low
(evening), the LED turns on automatically. This can be extended with a relay to
control home lighting.
• Temperature-Controlled Fan: With a temperature sensor (e.g., DHT11) and a relay,
the Arduino can turn on a fan if the temperature exceeds a threshold.
• Obstacle-Avoidance Robot: Using an ultrasonic sensor to detect obstacles and a
servo motor to steer, you can build a simple obstacle-avoiding robot that changes
direction when it detects objects in its path.
5. Communication and Data Logging
• Data Logging: Sensor data can be stored on an SD card connected to the Arduino or
transmitted to a computer via Serial or Bluetooth for monitoring and analysis.
• IoT Integration: Combine the Arduino with a Wi-Fi or Bluetooth module (e.g.,
ESP8266 or HC-05) to send sensor data to cloud platforms, enabling remote
monitoring and control.
UNIT – 3 : INTRODUCTION TO PYTHON PROGRAMMING
PYTHON PROGRAM WITH RASPBERRY PI WITH FOCUS OF INTERFACING
EXTERNAL GADGETS
Raspberry Pi is a versatile platform that allows you to interface with various external gadgets,
such as sensors, actuators, and other devices. This guide will walk you through setting up a
simple Python program to interface with an external gadget. We’ll use a DHT11 temperature
and humidity sensor and control an LED based on the temperature readings.
1. Hardware Required
• Raspberry Pi (any model with GPIO pins)
• DHT11 Temperature and Humidity Sensor
• LED
• 220Ω Resistor (for the LED)
• Breadboard and Jumper Wires
2. Wiring Diagram
1. DHT11 Sensor:
o VCC to Raspberry Pi 5V (Pin 2)
o GND to Raspberry Pi GND (Pin 6)
o Data pin to a GPIO pin (e.g., GPIO17 / Pin 11)
2. LED:
o Anode (long leg) to GPIO18 (Pin 12) through a 220Ω resistor
o Cathode (short leg) to GND (Pin 6)
3. Setting Up Raspberry Pi
Before you start coding, ensure that your Raspberry Pi is set up and has Python installed. You
will also need to install the necessary libraries.
Install Required Libraries:
sudo apt-get update
sudo apt-get install python3-pip
pip3 install Adafruit_DHT
4. Python Code Example
Here’s a simple Python program that reads temperature and humidity from the DHT11 sensor
and turns an LED on or off based on the temperature threshold.
import Adafruit_DHT
import RPi.GPIO as GPIO
import time
# GPIO setup
DHT_SENSOR = Adafruit_DHT.DHT11
DHT_PIN = 17 # GPIO pin for DHT11
LED_PIN = 18 # GPIO pin for LED
GPIO.setmode(GPIO.BCM) # Use BCM pin numbering
GPIO.setup(LED_PIN, GPIO.OUT) # Set LED pin as output
try:
while True:
# Read humidity and temperature from DHT11
humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
if temperature is not None:
print(f'Temperature: {temperature}°C')
print(f'Humidity: {humidity}%')
# Control the LED based on temperature
if temperature > 25: # Temperature threshold
GPIO.output(LED_PIN, GPIO.HIGH) # Turn LED on
print("LED is ON")
else:
GPIO.output(LED_PIN, GPIO.LOW) # Turn LED off
print("LED is OFF")
else:
print("Failed to retrieve data from the sensor")
time.sleep(2) # Wait before the next reading
except KeyboardInterrupt:
print("Program terminated.")
finally:
GPIO.cleanup() # Clean up GPIO on exit
5. Running the Program
1. Save the code in a file named dht11_led.py.
2. Open a terminal on your Raspberry Pi.
3. Navigate to the directory where the file is saved.
4. Run the program:
python3 dht11_led.py
6. Understanding the Code
• Library Imports:
o Adafruit_DHT for reading data from the DHT11 sensor.
o RPi.GPIO for controlling the GPIO pins.
• Setup:
o Configure the GPIO pins for the DHT11 sensor and LED.
• Main Loop:
o Continuously read the temperature and humidity from the sensor.
o Print the readings to the console.
o Control the LED based on the temperature (turning it on if the temperature
exceeds 25°C).
• Cleanup:
o Ensure GPIO pins are cleaned up upon exiting the program.
7. Conclusion
This example demonstrates how to interface a temperature and humidity sensor with a
Raspberry Pi using Python. You can extend this setup by adding more sensors, actuators, or
even integrating it with IoT platforms for remote monitoring. Raspberry Pi’s flexibility and
Python’s ease of use make it an excellent choice for a wide range of projects involving
external gadgets.
CONTROLLING OUTPUT
In an IoT (Internet of Things) system, controlling output involves managing actuators or
devices (like LEDs, motors, or relays) based on data gathered by sensors or instructions
received remotely via the internet. This capability enables smart responses to real-world
conditions, such as turning on lights in a smart home, controlling appliances, adjusting
temperature, or managing other devices remotely.
Here’s a closer look at how controlling output in IoT works and the key components
involved.
Key Components of IoT Output Control
1. Sensors: These gather data from the environment, such as temperature, light levels, or
motion. The input data from sensors is processed and often triggers actions on
actuators.
2. Actuators: Devices that perform physical actions in response to commands.
Examples include:
o LEDs and Lighting: Turn on/off or change color/intensity based on
instructions.
o Motors: Control movement or rotation in machines, such as fans or robotic
arms.
o Relays: Allow for control of high-voltage devices (e.g., lights, fans, and other
appliances) using a low-voltage trigger.
3. Microcontroller or Microprocessor: This could be an Arduino, Raspberry Pi,
ESP8266, or ESP32, which acts as the local control hub. It processes data from
sensors, makes decisions based on programmed rules, and controls actuators.
4. Connectivity Module: Devices like the ESP8266, ESP32, or GSM modules enable
the microcontroller to communicate with the internet. This allows for remote control
and data logging on cloud platforms.
5. IoT Platforms and Cloud Services: Platforms like ThingSpeak, AWS IoT, Google
Cloud IoT, or custom MQTT brokers help in remotely managing devices, monitoring
data, and sending control signals.
Common Methods for Controlling Outputs in IoT
There are a few popular methods used to control IoT devices remotely and trigger outputs:
1. HTTP REST API: REST (Representational State Transfer) APIs allow a device to
receive commands by making HTTP requests to a web server.
o Example: A light control system where a Raspberry Pi listens for HTTP
requests to turn an LED on or off.
o Process: The user sends a request (e.g., http://<device_ip>/led/on), and the
microcontroller executes the command.
2. MQTT (Message Queuing Telemetry Transport): MQTT is a lightweight
messaging protocol, commonly used in IoT for remote control. Devices publish or
subscribe to topics, and messages sent on these topics control outputs.
o Example: A motor control system where a motor is activated or deactivated
based on the message received on a specific topic (home/garden/waterpump).
o Process: A mobile app sends an “ON” message to the MQTT broker on
home/garden/waterpump, and any subscriber (e.g., ESP8266 controlling the
motor) will turn the motor on.
3. WebSocket Protocol: WebSockets provide full-duplex communication between a
server and clients, which can be used to send real-time control commands to IoT
devices.
o Example: A WebSocket server that allows a user to turn on a series of lights in
real-time from a web interface.
o Process: When a user clicks a button on the web app, a WebSocket message is
sent to the microcontroller to adjust lighting.
4. Bluetooth Low Energy (BLE): For nearby control, BLE allows a smartphone to
connect directly to IoT devices.
o Example: Controlling a fan speed using a mobile app connected via BLE.
o Process: The user changes the fan speed on the app, which sends the
command to the microcontroller, adjusting the motor’s speed.
Example Applications of IoT Output Control
1. Smart Lighting System
o Setup: LEDs or light bulbs are connected to a Wi-Fi-enabled microcontroller
(like ESP8266).
o Control Method: The user can toggle lights on and off remotely using an
MQTT client app or by accessing an HTTP URL.
o Cloud Control: Messages sent to the cloud are forwarded to the device,
enabling remote control.
2. Home Automation
o Setup: Appliances are connected via relays to an IoT-enabled microcontroller.
o Control Method: Using an app or voice commands, the user can control
appliances remotely. For example, “Turn on air conditioner.”
o Feedback: The system can also return the appliance’s current status.
3. Industrial Equipment Monitoring
o Setup: Motors and actuators in machinery are connected to a central control
system.
o Control Method: Remote management systems trigger machine actions via
MQTT or HTTP based on sensor feedback, controlling aspects like pressure or
speed.
o Safety Monitoring: Automatically shuts down equipment if sensor readings
exceed safe thresholds.
4. Agricultural IoT System
o Setup: Soil moisture sensors monitor plant needs, and a pump controlled by a
relay activates irrigation.
o Control Method: The user can remotely activate the pump when necessary or
schedule it based on soil moisture readings.
o Automation: Can be programmed to activate the pump automatically when
moisture levels are low.
Sample Python Code for Remote Control Using MQTT
Here’s an example of using Python and the MQTT protocol to control an LED on a
Raspberry Pi from an external device:
import RPi.GPIO as GPIO
import paho.mqtt.client as mqtt
# Define the pin for the LED
LED_PIN = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)
# Define the MQTT broker details
BROKER = "broker.hivemq.com"
TOPIC = "home/light"
# Callback function for MQTT messages
def on_message(client, userdata, msg):
message = msg.payload.decode()
if message == "ON":
GPIO.output(LED_PIN, GPIO.HIGH)
print("LED is ON")
elif message == "OFF":
GPIO.output(LED_PIN, GPIO.LOW)
print("LED is OFF")
# Setup MQTT client
client = mqtt.Client()
client.on_message = on_message
client.connect(BROKER)
# Subscribe to the topic and start loop
client.subscribe(TOPIC)
client.loop_start()
try:
while True:
pass # Keep the program running
except KeyboardInterrupt:
client.loop_stop()
GPIO.cleanup()
In this example:
• When a message is published to the home/light topic, the on_message function is
triggered.
• Depending on whether the message is "ON" or "OFF," the LED is turned on or off.
Challenges in IoT Output Control
1. Latency: Remote systems may have delays depending on network conditions,
impacting real-time control.
2. Security: IoT systems are vulnerable to hacking. Implementing encryption, like TLS
for MQTT, is essential.
3. Scalability: As the number of devices grows, managing control commands efficiently
and ensuring connectivity across devices becomes challenging.

READING INPUT FROM PINS


In the context of IoT (Internet of Things), reading input from pins typically refers to
gathering data from sensors or other input devices connected to a microcontroller or a single-
board computer (like an Arduino or Raspberry Pi). This data, which is collected in real time,
can then be processed, stored, visualized, or transmitted over a network to be used in smart
applications. Here's a breakdown of the process and principles behind reading inputs from
pins in IoT.
1. Overview of Input Pins in IoT Devices
In IoT devices, input pins are used to:
• Read Digital Signals: Digital pins can detect simple HIGH (1) or LOW (0) states,
which correspond to binary input (on/off or true/false). This is common with motion
sensors, switches, and buttons.
• Read Analog Signals: Analog pins can read a range of values (usually from 0 to
1023), which allows for more nuanced readings from sensors that measure light,
temperature, humidity, etc.
2. Reading Digital Input from Pins
Digital sensors send binary data to the IoT device, typically a HIGH (3.3V or 5V) or LOW
(0V) signal. For example:
• Button: A button press changes the state of the pin it’s connected to, allowing the
device to detect when it’s pressed.
• Motion Sensor (e.g., PIR): Outputs a HIGH signal when motion is detected and
LOW when there is none.
Example (Arduino): Reading from a digital pin connected to a button
const int buttonPin = 2; // Pin connected to the button
int buttonState = 0;
void setup() {
pinMode(buttonPin, INPUT); // Set pin as input
Serial.begin(9600); // Initialize serial communication
}
void loop() {
buttonState = digitalRead(buttonPin); // Read state
if (buttonState == HIGH) {
Serial.println("Button pressed");
} else {
Serial.println("Button not pressed");
}
delay(100);
}
3. Reading Analog Input from Pins
Analog input pins allow IoT devices to read a range of values. These are useful for sensors
like:
• Temperature Sensors: Convert temperature into a variable voltage.
• Photoresistors (LDR): Change resistance based on light intensity, allowing the
microcontroller to detect light levels.
• Potentiometers: Change resistance based on the knob position, providing variable
input.
Example (Arduino): Reading from an analog pin connected to an LDR
const int ldrPin = A0; // Pin connected to the LDR
void setup() {
Serial.begin(9600); // Initialize serial communication
}
void loop() {
int lightLevel = analogRead(ldrPin); // Read analog value (0-1023)
Serial.print("Light Level: ");
Serial.println(lightLevel);
delay(500);
}
4. Types of Sensors Commonly Used in IoT for Reading Inputs
• Temperature and Humidity Sensors (e.g., DHT11, DHT22): Provide data on
ambient temperature and humidity.
• Gas and Air Quality Sensors (e.g., MQ2, MQ7): Detect gases like CO2 or smoke.
• Ultrasonic Sensors: Measure distance using sound waves.
• Accelerometers and Gyroscopes: Track motion and orientation.
These sensors either provide digital or analog signals, which can be processed by the IoT
device to monitor various environmental factors.
5. Using Python on Raspberry Pi to Read GPIO Inputs
Python is often used on Raspberry Pi for GPIO (General Purpose Input/Output) operations
due to its simplicity and readability.
Example (Python on Raspberry Pi): Reading input from a button
python
Copy code
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
button_pin = 18
GPIO.setup(button_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Configure pin as input
with pull-up resistor
try:
while True:
if GPIO.input(button_pin) == GPIO.LOW: # Button pressed
print("Button pressed")
else:
print("Button not pressed")
time.sleep(0.1)
except KeyboardInterrupt:
GPIO.cleanup()
6. Processing and Transmitting Input Data
The data collected from sensors through GPIO pins can be processed and transmitted to other
devices or cloud platforms, where it can be stored and analyzed.
• Edge Processing: Processing raw sensor data on the device itself, reducing data sent
to the cloud (e.g., only sending alerts for significant changes).
• Data Transmission: Using Wi-Fi, Bluetooth, or LoRa modules, processed data is sent
to cloud servers for remote monitoring and storage.
• Cloud Storage and Analytics: Services like AWS IoT, Google Cloud IoT, or
Thingspeak allow for long-term data storage and advanced analytics.
Example (Python): Sending data from Raspberry Pi to a cloud service using HTTP (e.g.,
ThingSpeak)
import requests
def send_data(temperature, humidity):
api_key = 'YOUR_API_KEY'
url = f'https://api.thingspeak.com/update?api_key={api_key}'
response = requests.get(url + f"&field1={temperature}&field2={humidity}")
if response.status_code == 200:
print("Data sent successfully")

# Assume you have data from a temperature sensor


temp = 24.5
humidity = 55
send_data(temp, humidity)
7. Practical IoT Applications with GPIO Inputs
• Smart Home Monitoring: Monitor temperature, light, and motion to automate home
systems like lighting and HVAC.
• Health Monitoring Systems: Track environmental conditions (e.g., air quality) to
improve safety in healthcare settings.
• Agricultural Monitoring: Use sensors to measure soil moisture and temperature for
optimized watering systems.
• Security Systems: Motion sensors and cameras activated by GPIO input can detect
and respond to intrusions.

UNIT – 4 : INTRODUCTION TO RASPBERRY PI


The Raspberry Pi is a compact, affordable single-board computer that was developed by the
Raspberry Pi Foundation in the UK. It was initially designed to promote computer science
education in schools, but its versatility and low cost have made it popular for a wide range of
applications, from learning programming to powering IoT projects and even being used as a
home media center.
Key Features of a Raspberry Pi:
1. Processor and RAM: It has a processor and RAM integrated onto a single board,
similar to a regular computer but scaled down in power and size.
2. Operating System: Runs Linux-based OSes, typically Raspberry Pi OS (formerly
called Raspbian), and can also support other operating systems like Ubuntu and even
lightweight versions of Windows.
3. GPIO (General Purpose Input/Output): GPIO pins allow for interaction with
various electronics components like LEDs, sensors, motors, and more, making it ideal
for projects requiring physical computing.
4. Connectivity: Models come with options for Ethernet, Wi-Fi, and Bluetooth
connectivity, USB ports for peripherals, HDMI ports for monitors, and microSD
storage.
5. Various Models: There are different models (e.g., Raspberry Pi 3, 4, and Raspberry
Pi Zero) with varying processing power and features to fit different needs.
Common Uses:
• Education: Coding, electronics, and robotics projects.
• IoT Projects: Building smart home devices, security systems, and sensors.
• Media Center: Running media applications (e.g., Kodi) to play videos and music.
• Retro Gaming: Emulating old video game systems.
The Raspberry Pi has sparked a community of makers, engineers, and hobbyists worldwide,
providing a powerful tool for learning, prototyping, and creative projects.
INTERFACING RASPBERRY PI WITH BASIC PERIPHERALS
Interfacing a Raspberry Pi with basic peripherals is straightforward, thanks to its GPIO
(General Purpose Input/Output) pins and support for various communication protocols.
Here’s a guide on how to connect and program basic peripherals like LEDs, buttons, sensors,
and displays with a Raspberry Pi.
Certainly! Interfacing peripherals with a Raspberry Pi can help automate processes, build
interactive systems, or even make home gadgets smarter. Here’s a look at some context and
practical uses for connecting various peripherals beyond the code itself.
1. LEDs for Visual Feedback
• Purpose: LEDs are one of the simplest peripherals and can be used to provide visual
feedback in projects. For instance, a blinking LED could indicate system status,
whether a device is running correctly, or alert you to a problem.
• Common Use Cases: Notifications (like email alerts), status indicators in robotics,
visual feedback for sensor readings (e.g., green for safe, red for warning).
2. Buttons for User Input
• Purpose: Buttons are essential for user interaction with a device. They can trigger
actions in your programs, such as turning an LED on/off, starting/stopping a process,
or even navigating a simple interface.
• Common Use Cases: Manual control for devices (like an emergency stop button in
machinery), interactive games, and projects where user input is required, such as
selecting between options on an LCD.
3. Temperature and Humidity Sensors (e.g., DHT11, DHT22)
• Purpose: Environmental sensors like temperature and humidity sensors allow the
Raspberry Pi to monitor environmental conditions. This data is essential for
automation, especially in agriculture, HVAC systems, and weather monitoring
applications.
• Common Use Cases: Smart greenhouse systems, weather stations, home climate
monitoring, and smart thermostats. For example, if humidity falls below a threshold in
a greenhouse, a water pump could be activated automatically.
4. LCD Displays for Information Display
• Purpose: Displays like a 16x2 LCD provide a simple way to show information
directly from the Raspberry Pi. This can be helpful for displaying status messages,
sensor readings, or even simple menu options for users to interact with.
• Common Use Cases: Displays in embedded systems, such as home appliances,
sensor monitoring stations, or clocks. It’s especially useful for projects where you
want immediate feedback without needing a full monitor or remote device.
5. Servo Motors for Motion Control
• Purpose: Servos are essential for projects requiring precise movement control, like
turning dials, opening/closing mechanisms, or adjusting angles. Unlike regular
motors, servos allow for specific positioning, which is crucial in robotics.
• Common Use Cases: Robotics (controlling arms or grippers), home automation (like
opening blinds), model planes/cars (for steering), and camera gimbals (for stabilizing
or panning).
6. Ultrasonic Sensors for Distance Measurement
• Purpose: Ultrasonic sensors measure distance by emitting a sound wave and
calculating the time taken for the echo to return. This is ideal for applications needing
spatial awareness or range detection, such as autonomous robots or security systems.
• Common Use Cases: Distance sensors in robots (to avoid obstacles), security systems
(detecting movement within a specified range), and parking assist systems (like those
in cars).
Practical Tips for Interfacing Peripherals
1. GPIO Setup: Raspberry Pi’s GPIO pins are versatile and support various modes.
Most pins handle digital I/O, while others can manage specific protocols like I2C,
SPI, and UART, simplifying the integration of complex peripherals.
2. Power Considerations: Some components may require more current or voltage than
the Raspberry Pi’s GPIO pins can provide directly, necessitating external power or
transistors. For instance, relays or motors often need external power sources to avoid
damaging the Raspberry Pi.
3. Pull-Up and Pull-Down Resistors: For buttons and other input devices, pull-up/pull-
down resistors help stabilize the input signal and avoid false readings. The Raspberry
Pi’s GPIO library allows software pull-up/pull-down resistors, which can simplify
wiring.
4. Libraries and Drivers: Many peripherals have dedicated Python libraries (e.g.,
Adafruit_DHT for DHT sensors), which simplify communication with the device,
abstracting the low-level details. For I2C and SPI devices, using libraries like smbus
or spidev can speed up development.
5. Prototyping with a Breadboard: When building circuits, breadboards allow you to
experiment with component placement and wiring without soldering. They’re ideal
for testing before making permanent connections on a soldered board.
Real-World Applications
• Smart Home: Using a Raspberry Pi, you can create a home automation system where
a temperature sensor and LCD display monitor the room’s temperature, while a servo
adjusts a vent to maintain a comfortable environment.
• Educational Robotics: In a robot, an ultrasonic sensor helps it avoid obstacles, a
servo allows movement control, and LEDs indicate its status.
• Weather Station: A Raspberry Pi can run a small weather station by connecting
temperature, humidity, and air pressure sensors, which feed data to a display, a web
dashboard, or cloud storage.
IMPLEMENTATION OF IOT WITH RASPBERRY PI

The Raspberry Pi is widely used for IoT (Internet of Things) projects because of its
affordability, flexibility, and capability to run various IoT protocols. Implementing IoT with a
Raspberry Pi involves connecting the Pi to sensors, processing or storing data locally, and
then sending the data to the cloud or interacting with other devices over the internet. Here’s a
guide on how to set up an IoT system using a Raspberry Pi.
Step-by-Step Implementation of IoT with Raspberry Pi
1. Setting up the Raspberry Pi
• Operating System: Install the Raspberry Pi OS (previously Raspbian) or any
lightweight OS capable of handling IoT processes. Raspberry Pi OS has native
support for popular programming languages like Python, which is ideal for IoT.
• Network Configuration: Connect the Raspberry Pi to Wi-Fi or Ethernet for internet
connectivity. This allows the Pi to communicate with cloud servers or IoT platforms.
• Dependencies and Libraries: Install necessary software and libraries (e.g., paho-
mqtt for MQTT messaging, requests for HTTP REST APIs, or specific sensor libraries
like Adafruit_DHT for temperature sensors).
2. Interfacing Sensors and Actuators
• Sensors: Attach sensors like temperature, humidity, or motion sensors to the
Raspberry Pi’s GPIO pins. Each sensor can be configured to read data and then send it
to the Pi for processing.
• Actuators: Connect actuators, such as LEDs, relays, or motors, which can be
controlled by the Raspberry Pi based on the sensor data. For example, a relay can
control a fan based on temperature readings.
Example: Use a DHT11 or DHT22 sensor to read temperature and humidity, and control a
fan with a relay based on the readings.
3. Data Processing and Analysis on the Edge
• Edge Computing: Process data locally on the Raspberry Pi before sending it to the
cloud. This approach, called edge computing, reduces latency and the amount of data
sent over the network.
• Data Filtering and Aggregation: For instance, if measuring temperature, you could
average the readings every minute before sending them to avoid overloading the
network.
4. Data Communication and Protocols
The Raspberry Pi can use various protocols to send data to other devices or cloud services.
Here are some commonly used IoT protocols:
• MQTT (Message Queuing Telemetry Transport):
o Purpose: A lightweight messaging protocol, ideal for devices with limited
bandwidth.
o Implementation: Install the paho-mqtt library to publish sensor data and
subscribe to actuator control commands.
o Example: The Pi publishes temperature readings to an MQTT broker, and it
subscribes to commands to turn on/off a fan based on temperature thresholds.
• HTTP/HTTPS (RESTful APIs):
o Purpose: Allows the Pi to communicate with web servers or cloud services
through standard HTTP requests.
o Implementation: Use Python’s requests library to send data as HTTP POST
requests.
o Example: Send sensor data to a REST API endpoint of an IoT platform like
ThingSpeak or Google Firebase.
• WebSocket:
o Purpose: Enables two-way communication with low latency, suitable for real-
time applications.
o Example: Use WebSocket to control a Raspberry Pi’s GPIO pins in real-time
from a web dashboard.
5. Storing Data in the Cloud
• Cloud Storage: IoT platforms like AWS IoT, Google Cloud IoT, Microsoft Azure IoT,
or open-source platforms like ThingsBoard provide data storage, analytics, and
dashboards.
• Data Logging: Platforms like ThingSpeak or Adafruit IO allow the Pi to log data,
generate graphs, and set up triggers for specific conditions (like alerts).
Example: Send data to AWS IoT Core using MQTT, where it’s stored in Amazon
DynamoDB and analyzed using AWS Lambda functions.
6. Visualizing Data
• Web Dashboard: Platforms like ThingsBoard, Node-RED, or Grafana can be used to
create real-time dashboards that visualize sensor data.
• Local Visualization: If internet is not available, use libraries like matplotlib to create
local visualizations on the Pi’s screen.
Example: Using Node-RED, create a flow where data is displayed in real-time on a
dashboard, with visual elements like gauges, charts, and alert notifications.
7. Controlling Devices Remotely
• Smartphone App: Use an app like Blynk or IoT Central to control the Raspberry Pi
remotely. Blynk, for instance, provides a mobile app interface where you can
visualize data and control devices.
• Voice Assistant Integration: Integrate with Amazon Alexa or Google Assistant to
control IoT devices through voice commands.
Example: Say, “Alexa, turn on the fan,” which sends a command to the Raspberry Pi to
activate a fan via a relay.
Practical Applications of IoT with Raspberry Pi
1. Smart Home Automation: Build a home automation system with sensors for motion,
temperature, humidity, and light, controlling lights, fans, or thermostats based on
sensor readings.
2. Weather Station: Create a weather station that logs data from temperature, humidity,
and air quality sensors, then sends it to a cloud dashboard.
3. Security Systems: Use motion and door sensors to detect intrusions, send alerts to a
phone, and capture images with a connected camera.
4. Agriculture: Monitor soil moisture, temperature, and humidity levels in real-time to
maintain optimal conditions for crops, and automate irrigation.
5. Industrial IoT (IIoT): Monitor machinery for parameters like vibration, temperature,
and motor speed, enabling predictive maintenance and reducing downtime.
Challenges and Tips for IoT with Raspberry Pi
1. Network Reliability: IoT systems depend on stable network connections. Consider
Wi-Fi range extenders or Ethernet for areas with weak Wi-Fi.
2. Data Security: Ensure secure data transfer by using HTTPS or MQTT with TLS
encryption to protect against cyber threats.
3. Power Management: If running on battery or in remote areas, use power-efficient
code and consider sleep modes.
4. Scalability: For larger IoT networks, cloud IoT solutions provide scalability and
advanced features like AI-based analytics and machine learning

UNIT – 5 : INTRODUCTION TO SOFTWARE DEFINED


NETWORK (SDN)
SDN FOR IoT
Software−defined Networking in the Internet of Things (IoT) presents a formidable
architecture that enhances the adaptability and flexibility of networks. By seamlessly
abstracting multiple network layers, SDN revolutionizes network control, empowering
enterprises and service providers to swiftly adapt to evolving business demands. This
cutting−edge approach seeks to optimize network management and empower organizations
with the agility needed to thrive in an ever−changing digital landscape.
SDN's inherent ability to provide abstractions empowers network administrators to exert
holistic control over the network, utilizing high−level policies without having to concern
themselves with the intricacies of low−level configurations. Consequently, leveraging SDN
proves advantageous in addressing the heterogeneous nature of IoT and catering to its unique
application−specific demands.
In our research, we delve into the examination of softwarization's application and impact on
IoT networks. Our investigation encompasses multiple perspectives, including access
networks, edge networks, and wide area networks. Furthermore, we undertake the
development and analysis of models aimed at characterizing the performance of software
networks.
Different Verities of Software Defined Networking
Discover the diverse realms of Software−Defined Networking (SDN) within the realm of IoT,
each presenting its unique advantages:
• Open SDN: Experience the power of open protocols as they orchestrate and govern
both virtual and physical devices, seamlessly directing the flow of data packets.
• API SDN: Unleash the potential of programming interfaces, known as southbound
APIs, to regulate the intricate exchange of data between devices, ensuring efficient
data flow management.
• Overlay Model SDN: Embark on a virtual networking journey that transcends
physical limitations. Overlay Model SDN constructs a virtual network layer above
existing hardware infrastructure, encompassing data tunnels and channels to data
centers. This innovative model skillfully allocates bandwidth within each channel and
effectively assigns devices to their designated channels.
• Hybrid Model SDN: Embrace the best of both worlds with the Hybrid Model SDN.
By seamlessly blending the realms of SDN and traditional networking, this versatile
approach enables the optimal selection of protocols for various traffic types. Harness
the power of Hybrid SDN as a phased implementation strategy for a smooth transition
into the world of SDN.
Unlock the potential of Software−Defined Networking as you navigate through these
captivating alternatives tailored for the Internet of Things (IoT).

Significance of Software Defined Networking in IoT


Software−Defined Networking (SDN) in the Internet of Things (IoT) signifies a considerable
improvement over traditional networking, delivering a range of essential benefits:
• Enhanced Control with Unparalleled Speed and Flexibility: SDN eliminates the
need for manual configuration of various hardware devices from different vendors.
Instead, developers can exert control over network traffic by programming a software
based controller adhering to open standards. This approach empowers networking
managers with the freedom to select networking equipment and communicates with
multiple hardware devices using a single protocol via a centralized controller,
resulting in remarkable speed and flexibility.
• Customizable Network Infrastructure: With SDN, administrators can centrally
design network services and swiftly allocate virtual resources to modify the network
infrastructure. This capability allows network administrators to prioritize applications
that demand increased availability and optimize the flow of data across the network
according to specific requirements.
• Robust Security: SDN in IoT offers comprehensive visibility across the entire
network, presenting a holistic view of potential security threats. As the number of
intelligent devices connecting to the Internet continues to proliferate, SDN surpasses
traditional networking in terms of security advantages. Operators can create distinct
zones for devices requiring different security levels or promptly isolate compromised
devices to prevent the spread of infections throughout the network.
By embracing Software−Defined Networking in IoT, organizations can unlock the potential
for greater control, customization, and security within their networks, paving the way for
optimized performance and improved management of IoT deployments.
INDUSTRIAL IoT
Industrial IoT (IIoT) is the application of Internet of Things technology to industrial settings,
such as manufacturing, energy, transportation, and supply chain management. It involves
connecting machinery, sensors, and devices to the internet, allowing real-time data collection,
analysis, and automation. IIoT aims to improve efficiency, safety, and decision-making
processes, helping businesses optimize their operations and reduce costs.
Key Components of Industrial IoT
1. Sensors and Actuators: Sensors gather real-time data on temperature, pressure,
humidity, speed, vibration, and more. Actuators then perform actions in response to
sensor data, such as adjusting machinery settings or triggering alarms.
2. Edge Devices and Gateways: Edge devices, such as embedded computers or
microcontrollers, process data locally. Gateways manage communication between
devices and central systems, reducing data transmission to only necessary information
and lowering network loads.
3. Connectivity: IIoT relies on a variety of communication technologies to connect
devices, including:
o Ethernet and Wi-Fi for local connectivity.
o Cellular networks (4G, 5G) for remote or distributed systems.
o LPWAN (Low Power Wide Area Network) technologies like LoRaWAN for
long-range, low-power data transmission in sensor networks.
4. Cloud Platforms: Centralized cloud services provide data storage, processing, and
analytics, enabling large-scale data handling and complex processing tasks. Common
platforms include AWS IoT, Azure IoT, and Google Cloud IoT.
5. Analytics and Machine Learning: Industrial IoT generates vast amounts of data that
can be analyzed for trends, predictive maintenance, anomaly detection, and process
optimization. Machine learning models are frequently applied to IIoT data to identify
patterns and make automated decisions.
6. User Interface (UI) and Dashboard: Industrial operators need UIs to monitor and
control their systems. Dashboards provide real-time visualization, historical data
analysis, and alert management for efficient operational oversight.
Key Applications of Industrial IoT
1. Predictive Maintenance:
o Overview: IIoT sensors monitor equipment health by tracking indicators like
vibration, temperature, and pressure. Predictive algorithms analyze this data to
identify maintenance needs before a breakdown occurs.
o Benefits: Reduces downtime, minimizes repair costs, and extends equipment
life by scheduling maintenance based on actual conditions rather than fixed
intervals.
2. Quality Control and Assurance:
o Overview: Sensors in production lines monitor quality parameters (like size,
weight, and color) to ensure product standards. Automated quality control
identifies and removes defective items in real-time.
o Benefits: Reduces waste, improves product quality, and enables quick
response to production issues.
3. Asset Tracking and Supply Chain Optimization:
o Overview: IoT devices can track the location and status of assets, including
raw materials, in-transit products, and finished goods. RFID, GPS, and sensor
technologies monitor assets throughout the supply chain.
o Benefits: Enhances inventory management, reduces losses, and enables better
supply chain visibility, allowing companies to make real-time decisions.
4. Energy Management:
o Overview: IIoT enables real-time energy monitoring and optimization by
tracking equipment power usage and environmental conditions. Automated
systems can adjust energy consumption based on needs.
o Benefits: Helps reduce energy costs, improve environmental sustainability,
and comply with regulations.
5. Remote Monitoring and Control:
o Overview: Remote systems monitor operations from a distance, such as in oil
and gas facilities, wind farms, or other dispersed locations. These systems
allow remote diagnostics, configuration, and control of machinery.
o Benefits: Reduces travel costs, improves safety, and provides operational
insights for remote or dangerous environments.
6. Worker Safety and Environment Monitoring:
o Overview: Sensors detect hazards, such as toxic gas levels, and monitor
worker location and health data. Alerts can notify workers and management of
potential risks.
o Benefits: Enhances workplace safety, reduces accident risks, and complies
with occupational safety standards.
Benefits of Industrial IoT
1. Increased Efficiency: Automation and real-time monitoring reduce manual tasks,
lower errors, and increase productivity.
2. Reduced Downtime: Predictive maintenance and remote diagnostics decrease
unplanned downtimes and production disruptions.
3. Cost Savings: Optimized resource use, energy savings, and predictive maintenance
cut operational costs.
4. Enhanced Safety: Automated monitoring of environmental and operational hazards
improves worker safety.
5. Data-Driven Decision Making: IIoT provides actionable insights from data, enabling
faster and more informed decisions.

Challenges in Industrial IoT


1. Data Security and Privacy: IIoT involves connecting legacy industrial systems to
the internet, increasing the risk of cyberattacks. Securing data and devices is critical to
prevent operational disruptions and protect sensitive information.
2. Interoperability: Industrial environments often use diverse systems and protocols.
Integrating old and new technologies while ensuring they communicate effectively
can be challenging.
3. Data Management: IIoT generates massive data volumes. Storing, processing, and
managing this data efficiently is a complex task that requires advanced cloud storage
and analytics solutions.
4. Scalability: Scaling IIoT systems across multiple facilities or locations requires
robust infrastructure and well-designed architecture to handle data and device
management.
5. Reliability: In industrial settings, device failures can be costly. Ensuring reliability
and resilience in IIoT systems is essential, as equipment breakdowns or network
failures could disrupt operations.
IIoT Protocols and Standards
Several communication protocols are tailored to the needs of industrial IoT applications:
1. MQTT (Message Queuing Telemetry Transport): A lightweight messaging protocol
for resource-constrained devices, ideal for remote monitoring and control.
2. OPC-UA (Open Platform Communications - Unified Architecture): Provides
secure and reliable data exchange, specifically designed for interoperability in
industrial automation.
3. Modbus and PROFIBUS: Widely used in industrial settings for reliable data
transmission, especially with legacy devices.
4. LoRaWAN (Long Range Wide Area Network): Suitable for low-power, long-
distance communication in applications like asset tracking and remote monitoring.
5. Ethernet/IP and Profinet: Ethernet-based protocols supporting real-time data
exchange, commonly used for industrial automation.
Example of an Industrial IoT Setup
Consider a manufacturing plant that implements IIoT to monitor and control production
machinery.
1. Sensors are attached to machinery to collect data on temperature, vibration, and
power consumption.
2. Edge Devices process sensor data locally to make quick decisions, such as adjusting
settings to prevent overheating.
3. Connectivity: Machines communicate with a central cloud platform over Wi-Fi or
cellular networks to report real-time operational status.
4. Analytics Platform: The cloud processes data from multiple machines, identifying
potential issues, optimizing workflows, and providing reports on energy use and
productivity.
5. Maintenance Alerts: Predictive algorithms trigger maintenance alerts, allowing
technicians to address problems before they lead to breakdowns.
6. Operator Dashboard: The operators view real-time data on a dashboard, with alerts
for abnormal values and performance insights to improve productivity.
The Future of Industrial IoT
The future of IIoT includes the integration of AI and machine learning for advanced
predictive analytics, enabling self-optimizing systems where machines can learn from past
data and adjust their operation autonomously. 5G connectivity will further expand IIoT
applications, as its high-speed, low-latency capabilities enable more reliable and responsive
control of industrial devices, even in remote areas. Additionally, digital twins—virtual
replicas of physical assets—are expected to become more prevalent, allowing for real-time
simulation and analysis of industrial processes, leading to smarter and more efficient
operations.
Industrial IoT is revolutionizing industries by automating operations, reducing costs,
improving safety, and unlocking new levels of efficiency. By leveraging advanced
connectivity, data analytics, and machine intelligence, IIoT brings a new level of adaptability
and insight to traditional industrial environments.
CASE STUDY: AGRICULTURE, HEALTHCARE, AND ACTIVITY
MONITORING
IoT (Internet of Things) technology is transforming multiple sectors by enabling remote
monitoring, data collection, and automation. Here’s a look at how IoT is applied in
agriculture, healthcare, and activity monitoring through real-world case studies, highlighting
the technology, implementation, and outcomes.
1. IoT in Agriculture: Smart Farming
Case Study: Precision Agriculture with IoT in Vineyard Management
Overview: In vineyards, managing water usage, monitoring soil quality, and predicting
optimal harvest times are crucial for maximizing crop quality and yield. A smart farming IoT
solution was implemented in a vineyard to provide real-time monitoring and automated
irrigation, improving grape production and minimizing resource waste.
Technology Used:
• Sensors: Soil moisture sensors, temperature sensors, and weather sensors were
deployed to measure water levels, ambient temperature, and environmental
conditions.
• Connectivity: LoRaWAN (Low-Power Wide Area Network) was used for long-range
communication between sensors and a central control system.
• Edge Computing: Edge devices processed sensor data locally, making quick
decisions for irrigation needs based on soil moisture.
• Cloud Platform: A cloud platform aggregated data, providing historical insights and
alerts, and offering predictive analytics for harvest optimization.
Implementation:
• The vineyard was equipped with IoT sensors at strategic locations to monitor water
levels, soil pH, and temperature.
• Data from sensors was transmitted to the cloud platform via LoRaWAN, where it was
analyzed in real time.
• Based on soil moisture readings, the system automated irrigation only when
necessary, saving water and ensuring optimal hydration.
Outcomes:
• Resource Optimization: Water usage was reduced by over 30%, minimizing waste
and cost.
• Yield Improvement: The vineyard saw a 20% increase in yield by maintaining ideal
soil conditions.
• Labor Efficiency: Automation reduced the need for manual soil and crop checks,
enabling workers to focus on other tasks.
2. IoT in Healthcare: Remote Patient Monitoring
Case Study: Remote Health Monitoring in Chronic Disease Management
Overview: Managing chronic conditions, such as heart disease and diabetes, requires
consistent monitoring of patients’ vitals to prevent complications. An IoT-based remote
patient monitoring system was deployed to track key health metrics and improve patient
outcomes through early intervention.
Technology Used:
• Wearable Devices: IoT-enabled wearable devices were used to monitor heart rate,
blood pressure, glucose levels, and oxygen saturation.
• Connectivity: Cellular and Wi-Fi networks connected wearables to a centralized
database, allowing for real-time data transmission.
• Data Analytics: Machine learning models analyzed historical and real-time data to
predict potential health risks and alert caregivers.
• Mobile Application: A patient-facing mobile app enabled users to track their health
metrics and communicate with healthcare providers.
Implementation:
• Patients wore IoT-enabled devices that automatically tracked vital signs and
transmitted data to the cloud.
• Healthcare providers could access data through a web portal and receive alerts if
abnormal values were detected.
• Patients received personalized insights and reminders for medication adherence
through the mobile app.
Outcomes:
• Improved Health Outcomes: The real-time tracking system helped prevent 20% of
hospital admissions due to timely intervention for abnormal vitals.
• Enhanced Patient Engagement: Patients reported higher satisfaction due to
continuous feedback and communication with healthcare providers.
• Cost Reduction: Fewer hospital visits and reduced complications lowered healthcare
costs for both patients and providers.
3. IoT in Activity Monitoring: Smart Workplace Safety
Case Study: Employee Safety and Activity Monitoring in Hazardous Industries
Overview: In industries like mining, construction, and oil and gas, employee safety is
critical. A smart IoT system was implemented to monitor workers' physical activities,
environmental conditions, and potential hazards in real time, improving safety compliance
and reducing accidents.
Technology Used:
• Wearable Devices: Smart wearables equipped with accelerometers, gyroscopes, and
GPS tracked physical activity, location, and posture.
• Environmental Sensors: Temperature, humidity, gas, and noise sensors monitored
workplace conditions.
• Communication: Bluetooth and Zigbee protocols enabled wearables to communicate
with nearby devices and relay data to a gateway.
• Real-Time Alert System: A safety dashboard provided alerts and analytics, notifying
supervisors in case of unsafe conditions or activities.
Implementation:
• Employees in hazardous areas wore smart wearables that recorded data on physical
activities, heart rate, and posture.
• Environmental sensors installed throughout the site monitored gas leaks, temperature,
and noise levels.
• An AI-powered system analyzed real-time data to detect unsafe conditions, alerting
workers and supervisors if intervention was needed.
Outcomes:
• Reduced Accidents: With early detection of potential hazards, the accident rate
decreased by 25%.
• Compliance and Reporting: Automated data collection facilitated compliance with
safety regulations and reporting standards.
• Enhanced Productivity: The monitoring system optimized work processes by
identifying bottlenecks and ensuring a safer environment for employees.

You might also like