0% found this document useful (0 votes)
68 views64 pages

Notes - IOT

Uploaded by

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

Notes - IOT

Uploaded by

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

UNIT I FUNDAMENTALS OF IOT 9

Definition and Characteristics of IoT, Sensors, Actuators, Physical Design of IoT – IoT
Protocols, IoT communication models, IoT Communication APIs, IoT enabled Technologies –
Wireless Sensor Networks, Cloud Computing, Embedded Systems, IoT Levels and Templates,
Domain Specific IoTs – Home, City, Environment, Energy, Agriculture and Industry.

UNIT I - FUNDAMENTALS OF IOT

1.1 Definition and Characteristics of IoT:


Introduction
Internet of Things (IoT) comprises things that have unique identities and are connected to
the internet. Existing devices, such as networked computers or 4G enabled mobile phones
already have some form of unique identities and are also connected to the internet, the focus on
IoT in the configuration, control and networking via the internet of devices or things , that are
traditionally not associated with the Internet. These include devices such as thermostats, utility
meters, a blue tooth- connected headset, irrigation pumps and sensor or control circuits for an
electric car’s engine
Experts forecast that by the year 2020 there will be a total of 50 billion devices/ things
connected to the internet. The scope of IoT is not limited to just connected things(Devices,
appliance, machines) to the Internet.
Applications on IoT networks extract and create information from lower level data by
filtering, processing , categorizing, condensing and contextualizing the data. The information
obtained is then organized and structured to infer knowledge about the system and or its user, its
environment and its operations and progress towards its objectives, allowing a smarter
performance.

Definition of IoT:
A dynamic global network infrastructure with self-configuring capabilities based on
standard and interoperable communication protocols where physical and virtual "things" have
identities, physical attributes, and virtual personalities and use intelligent interfaces, and are
seamlessly integrated into the information network, often communicate data associated with
users and their environments.

Characteristics of IoT:
• Dynamic & Self-Adapting
• Self-Configuring
• Interoperable Communication Protocols
• Unique Identity
• Integrated into Information Network

Dynamic and self-Adapting:


IoT devices and systems may have the capability to dynamically adapt with the changing
contexts and take actions based on their operating condition. Ex: Surveillance cameras can adapt
their modes based on whether it is day or night.
Self – Configuring:
IoT devices may have self-Configuring capability allowing a large number of devices to
work together to provide certain functionality.
Interoperable communication protocols:
IoT Devices may support a number of interoperable communication protocols and can
communicate with other devices and also with the infrastructure.
Unique Identity:
Each IoT devices has a unique identity and a unique identifier. IPaddress, URI). IoT
systems may have intelligent interfaces which adapt based on the context, allow communication
with users and the environment contexts.
Integrated into information network:
IoT devices are usually integrated into the information network that allows them to
communicate and exchange data with other devices and systems.

1.2 Sensors, Actuators:


Sensors
A sensor does exactly as its name indicates: It senses. More specifically, a sensor
measures some physical quantity and converts that measurement reading into a digital
representation. That digital representation is typically passed to another device for transformation
into useful data that can be consumed by intelligent devices or humans.
Naturally, a parallel can be drawn with humans and the use of their five senses to learn
about their surroundings. Human senses do not operate independently in silos. Instead, they
complement each other and compute together, empowering the human brain to make intelligent
decisions. The brain is the ultimate decision maker, and it often uses several sources of sensory
input to validate an event and compensate for “incomplete” information.
Sensors are not limited to human-like sensory data. They can measure anything worth
measuring. In fact, they are able to provide an extremely wide spectrum of rich and diverse
measurement data with far greater precision than human senses; sensors provide superhuman
sensory capabilities. This additional dimension of data makes the physical world an incredibly
valuable source of information.
Sensors can be readily embedded in any physical objects that are easily connected to the
Internet by wired or wireless networks. Because these connected host physical objects with
multidimensional sensing capabilities communicate with each other and external systems, they
can interpret their environment and make intelligent decisions. Connecting sensing devices in
this way has ushered in the world of IoT and a whole new paradigm of business intelligence.
There are myriad different sensors available to measure virtually everything in the
physical world. There are a number of ways to group and cluster sensors into different
categories, including the following:

1. Active or passive: Sensors can be categorized based on whether they produce an energy
output and typically require an external power supply (active) or whether they simply
receive energy and typically require no external power supply (passive).
2. Invasive or non-invasive: Sensors can be categorized based on whether a sensor is part
of the environment it is measuring (invasive) or external to it (non-invasive).
Contact or no-contact: Sensors can be categorized based on whether they require physical
contact with what they are measuring (contact) or not (no-contact).

3. Absolute or relative: Sensors can be categorized based on whether they measure on an


absolute scale (absolute) or based on a difference with a fixed or variable reference value
(relative).

4. Area of application: Sensors can be categorized based on the specific industry or


vertical where they are being used.

5. How sensors measure: Sensors can be categorized based on the physical mechanism
used to measure sensory input (for example, thermoelectric, electrochemical,
piezoresistive, optic, electric, fluid mechanic, photoelastic).
6. What sensors measure: Sensors can be categorized based on their applications or what
physical variables they measure.

Note that this is by no means an exhaustive list, and there are many other classification
and taxonomic schemes for sensors, including those based on material, cost, design, and other
factors. The most useful classification scheme for the pragmatic application of sensors in an IoT
network, as described in this book, is to simply classify based on what physical phenomenon a
sensor is measuring.
Table : Sensor Types
Sensors come in all shapes and sizes and can measure all types of physical conditions. A
fascinating use case to highlight the power of sensors and IoT is in the area of precision
agriculture (sometimes referred to as smart farming), which uses a variety of technical advances
to improve the efficiency, sustainability, and profitability of traditional farming practices. This
includes the use of GPS and satellite aerial imagery for determining field viability; robots for
high-precision planting, harvesting, irrigation, and so on; and real-time analytics and artificial
intelligence to predict optimal crop yield, weather impacts, and soil quality.
Among the most significant impacts of precision agriculture are those dealing with sensor
measurement of a variety of soil characteristics. These include real-time measurement of soil
quality, pH levels, salinity, toxicity levels, moisture levels for irrigation planning, nutrient levels
for fertilization planning, and so on. All this detailed sensor data can be analyzed to provide
highly valuable and actionable insight to boost productivity and crop yield. Figure shows
biodegradable, passive micro sensors to measure soil and crop and conditions. These sensors,
developed at North Dakota State University (NDSU), can be planted directly in the soil and left
in the ground to biodegrade without any harm to soil quality.
Figure: Biodegradable Sensors Developed by NDSU for Smart Farming

IoT and, by extension, networked sensors have been repeatedly named among a small
number of emerging revolutionary technologies that will change the global economy and shape
the future. The staggering proliferation of sensors is the principal driver of this phenomenon. The
astounding volume of sensors is in large part due to their smaller size, their form factor, and their
decreasing cost. These factors make possible the economic and technical feasibility of having an
increased density of sensors in objects of all types. Perhaps the most significant accelerator for
sensor deployments is mobile phones. More than a billion smart phones are sold each year, and
each one has well over a dozen sensors inside it (see Figure 3-2), and that number continues to
grow each year. Imagine the exponential effect of extending sensors to practically every
technology, industry, and vertical. For example, there are smart homes with potentially hundreds
of sensors, intelligent vehicles with 100+ sensors each, connected cities with thousands upon
thousands of connected sensors, and the list goes on and on.

Figure: Sensors in a Smart Phone

Actuators:
Actuators are natural complements to sensors. Figure demonstrates the symmetry and
complementary nature of these two types of devices. As discussed in the previous section,
sensors are designed to sense and measure practically any measurable variable in the physical
world. They convert their measurements (typically analog) into electric signals or digital
representations that can be consumed by an intelligent agent (a device or a human). Actuators, on
the others hand, receive some type of control signal (commonly an electric signal or digital
command) that triggers a physical effect, usually some type of motion, force, and so on.
Figure: How Sensors and Actuators Interact with the Physical World

The previous section draws a parallel between sensors and the human senses. This
parallel can be extended to include actuators, as shown in Figure. Humans use their five senses to
sense and measure their environment. The sensory organs convert this sensory information into
electrical impulses that the nervous system sends to the brain for processing. Likewise, IoT
sensors are devices that sense and measure the physical world and (typically) signal their
measurements as electric signals sent to some type of microprocessor or microcontroller for
additional processing. The human brain signals motor function and movement, and the nervous
system carries that information to the appropriate part of the muscular system.
Correspondingly, a processor can send an electric signal to an actuator that translates the
signal into some type of movement (linear, rotational, and so on) or useful work that changes or
has a measurable impact on the physical world. This interaction between sensors, actuators, and
processors and the similar functionality in biological systems is the basis for various technical
fields, including robotics and biometrics.
Much like sensors, actuators also vary greatly in function, size, design, and so on. Some
common ways that they can be classified include the following:
1. Type of motion: Actuators can be classified based on the type of motion they produce
(for example, linear, rotary, one/two/three-axes).
2. Power: Actuators can be classified based on their power output (for example, high
power, low power, micro power)
3. Binary or continuous: Actuators can be classified based on the number of stable-state
outputs.
4. Area of application: Actuators can be classified based on the specific industry or
vertical where they are used.
5. Type of energy: Actuators can be classified based on their energy type.
Categorizing actuators is quite complex, given their variety, so this is by no means an
exhaustive list of classification schemes. The most commonly used classification is based on
energy type. Table shows actuators classified by energy type and some examples for each type.
Again, this is not a complete list, but it does provide a reasonably comprehensive overview that
highlights the diversity of function and design of actuators.
1.3 Physical Design of IoT:
The "Things" in IoT usually refers to IoT devices which have unique identities and can perform
remote sensing, actuating and monitoring capabilities. IoT devices can:
 Exchange data with other connected devices and applications (directly or
indirectly), or
 Collect data from other devices and process the data locally or
 Send the data to centralized servers or cloud-based application back-ends for
processing the data, or
 Perform some tasks locally and other tasks within the IoT infrastructure, based on
temporal and space constraints
Figure : Generic block diagram of an IoT Device

An IoT device may consist of several interfaces for connections to other devices, both
wired and wireless.
• I/O interfaces for sensors
• Interfaces for Internet connectivity
• Memory and storage interfaces
• Audio/video interfaces.
An IoT Device can collect various types of data from the the onboard or attached sensors,
such as temperature e , humidity, light intensity. IoT devices can also be varied types, for
instance, wearable sensors, smart watches, LED light automobiles and industrial machines.
Almost all I would advise generate data in Some form or the other which when processed by
Data Analytics systems leads to Useful information to guide further actions locally or remotely.

1.4 IoT Protocols

Link Layer:
Link Layer protocols determine how the data is physically sent over the networks
physical layer or medium(example copper wire, electrical cable, or radio wave). The Scope of
The Link Layer is the Last Local Network connections to which host is attached. Host on the
same link exchange data packets over the link layer using the link layer protocol. Link layer
determines how the packets are coded and signaled by the hardware device over the medium to
which the host is attached.

802.3 Ethernet:
802.3 is a collections of wired Ethernet standards for the link layer. For example 802.3
10BASE5 Ethernet that uses coaxial cable as a shared medium, 802.3.i is standard for 10 BASET
Ethernet over copper twisted pair connection, Standards provide data rates from 10 Mb/s to 40
gigabits per second and the higher. The shared medium in Ethernet can be a coaxial cable ,
twisted pair wire or and Optical fiber. Shared medium carries the communication for all the
devices on the network.

802.1- WI-FI:
IEEE 802.3 is a collections of wireless Local area network.(WLAN) communication
standards, including extensive descriptions of the link layer. For example 802.11a operate in the
5 GHz band, 802.11b and 802.11g operate in the 2.4 GHz band. 802.11ac operates in the 5G
hertz band.

802.16 wiMAX:
IEEE 802.16 is a collection of wirless broadband and Standards, including extensive
descriptions for the link layer also called WiMAX wimax standard provides a data rates from
from 1.5 Mb/s to 1Gb/s the recent update provides data rates of hundred megabits per second for
mobile station.

802.15.4 LR-WPAN:
IEEE 802.1 5.4 is a collections of standard for low rate wireless personal area
network(LRWPAN).These standard form the basis of specifications for high level
communication Zigbee. LR-WPAN standards provide data rates from 40 k b/ s. These standards
provide low cost and low speed Communications for power constrained devices.

2G / 3G / 4G mobile communications:
These are the different generations of mobile communication standards including second
generation (2G including GSM and CDMA). 3rd Generation (3G including UMTS and
CDMA2000) and 4th generation 4G including LTE.

Network / Internet layer:


The network layer are responsible for sending of IP datagrams from the source network
to the destination network. This layer Performs the host addressing and packet routing. The
datagrams contains a source and destination address which are used to route them from the
source to the destination across multiple networks. Host Identification is done using the
hierarchy IP addressing schemes such as ipv4 or IPv6.

IPV4:
Internet protocol versions for open parents close (IPV4) is there most deployed internet
protocol that is used to identify the device is on a network using a hierarchy latest schemes. It
uses 32 bit addresses scheme that allows total of 232 addresses. As more and more devices got
connected to the internet the Ipv4 has succeeded by IPv6.
IPv6:
It is the newest versions of internet protocol and successor to IPv4. IPv6 uses 128 bit
address schemes that are lost total of 2 128 are 3.4*10 38 address.

6LoWPAN:
IPv6 over low power wireless personal area networks brings IP protocol to the low power
device which have limited processing capability it operate in the 2.4 GHz frequency range and
provide the data transfer rate off to 50 kb/s.

Transport layer:
The Transport layer protocol provides end-to-end message transfer capability
independent of the underlying network. The message transfer capability can be set up on
connections, either using handshake or without handshake acknowledgements. Provides
functions such as error control, segmentation, flow control and congestion control.

TCP:
Transmission control protocol is the most widely used to transport layer protocol that is
used by the web browsers along with HTTP, HTTPS application layer protocols email program
(SMTP application layer protocol) and file transfer protocol. TCP is a connection Oriented and
stateful protocol while IP protocol deals with sending packets, TCP ensures reliable
transmissions of packets in order. TCP also provide error deduction capability so that duplicate
packets can be discarded and low packets are retransmitted. The flow control capability ensures
that the rate at which the sender since the data is now too high for the receiver to process.

UDP:
Unlike TCP, which requires carrying out an initial setup procedure, UDP is a connection
less protocol. UDP is useful for time sensitive application they have very small data units to
exchange and do not want the overhead of connection setup. UDP is a transactions oriented and
stateless protocol. UDP does not provide guaranteed delivery, ordering of messages and
duplicate eliminations.

Application layer:
Application layer protocol defines how the application interfaces with the lower layer
protocols to send the data over the network. Data are typically in files, is encoded by the
application layer protocol and encapsulated in the transport layer protocol .Application layer
protocol enable process-to-process connection using ports.

Http:
Hypertext transfer protocol is the application layer protocol that forms the foundations of
world wide web http includes, ,commands such as GET, PUT,POST, DELETE, HEAD, TRACE,
OPTIONS etc. The protocol follows a request response model where are client sends request to
server using the http, commands. Http is a stateless protocol and each http request is independent
father request and http client can be a browser or an application running on the client example
and application running on an IoT device, mobile mobile applications or other software.

CoAP:
Constrained application protocol is an application layer protocol for machine to machine
application M2M meant for constrained environment with constrained devices and constrained
networks. Like http CoAP is a web transfer protocol and uses a request- response model,
however it runs on the top of the UDP instead of TC CoAP uses a client –server architecture
where client communicate with server using connectionless datagrams. It is designed to easily
interface with http like http, CoAP supports method such as GET, PUT, DELETE.
Websocket:
Websocket protocol allows full duplex communication over a single socket connection
for sending message between client and server. Websocket is based on TCP and Allows streams
of messages to be sent back and forth between the client and server while keeping the TCP
connection open. The client can be a browser, a mobile application and IoT device

MQTT:
Message Queue Telemetry Transport it is a lightweight message protocol based on public
-subscribe model MQTT uses a client server Architecture by the clients such as an IoT device
connect to the server also called the MQTT broker and publishers message to topic on the server.
The broker forward the message to the clients subscribed to topic MQTT is well suited for
constrained and environments.

XMPP:
Extensible Messaging and Presence Protocol it is a protocol for real-time communication
and streaming XML data between network entities XMPP powers wide range of applications
including messaging, presence, data syndication, gaming multiparty chat and voice / voice calls.
XMPP Allows sending small chunks of XML data from one network entity to another in real
time. XMPP supports both client to server and server –client communication path.

DDS:
Data distribution service is the date centric middleware standard for device to-device
machine to machine communication DDS uses a publish subscribe model where publisher
example device that generate data create topics to which subscribers per can subscribe publisher
is an object responsible for data distributions and the subscriber responsible for receiving
published data. DDS provide quality of service (QoS) control and configurable reliability

AMQP:
Advanced Message Queuing Protocol. It is an open application layer protocol for
business messaging. AMQP support point to point and publish - subscribe model routing and
queuing. AMQP broker receive message from publishers example devices or applications that
generate data and about them over connections to consumers publishers publish the message to
exchange which then distribute message copies to queues.

1.5 Logical design of IoT


Logical design of an IoT system refers to an abstract representation of the entities and
process without going into low level specification of the implementations.
(i) IoT functional block
An IoT system comprises of a number of functional blocks that provide the system the
capabilities for identification , sensing, actuation ,communication and Management. The function
blocks are described as follows
Devices: An IoT system comprises of the devices that provide sensing, actuation, monitoring and
control function
Communication: communication block handle the communication systems
Services : An IoT system uses various types of IoT services such as services for device
monitoring ,device control services ,data publishing services and services for device Discovery.
Management: Functional blocks provide various functions to govern the IoT system
Security: Security functional block security IoT system and by providing functions such as
application authorization message and content integrity and data security.
Application: IoT application provides and interface that the user can used to control and monitor
various aspects of the IoT system. Application also allow users to view the system status and
view or analyze the processed to data.
Figure: IoT functional block

(ii) IoT communication model


(a) Request response:
Request-response is a Communications model in which the client sends request to the
server and the server responds to the requests. When the server receives a request it
decides how to respond, if it shows the data retrieved resources definitions for the
response , and then send the response to the client. Access to response model is a
stateless communication model and each request response per is independent of
others the crime and server interactions in the request response model.
Figure: Request-Response communication model

(b) Publish - Subscribe:


Respect is a communication model that involve Publishers brokers and consumers.
Publishers are the source of data. Publishers send the data to the topics which is
managed by the broker. Publishers are not aware of the consumer. Consumers
Subscribe to the topic which are managed by the broker. When the broker receives
the data for a topic from the publisher, it send the data to all the subscribed
consumers.
Figure: Publish - Subscribe communication model

(c) Push pull:


Push pull is communication model in which the data producers push the data to
queues and the consumers pull the data from the queues. Producers do not need to be
aware of the consumer. Queues help in decoupling the messaging between the
Producers and Consumers. It also act as a buffer which helps in situations when there
is a mismatch between the rate at which the produces push data and the rate at which
the consumers full the data
Figure: Push pull communication model

(d) Exclusive pair:


Exclusive pair is a bi directional, fully duplex communication model that uses a
persistent connections between the client and the server. Once the condition is setup it
remains open until the client sends a request to close the connection. client and server
can send messages to each other after connection setup. Exclusive pair is a stateful
communications model and the server is aware of all the open connections.
Figure: Exclusive pair communication model

(iii) IoT communication APIs


a) REST- based communication API:
Representational state transfer is a set of architectural principles by which you can
design web service and Web API that focus on a system resources and how resources
states and addressed the transferred. REST API follow the request- response
communication model.
The REST architectural constraints apply to the components, connectors, and data
elements.
Client server: The principle behind the client-server conference separations of
concerns for example client should not be concerned with the storage of
data which is their concern of the server.
Similarly the server should not be concerned about the user interface which is a
concern of the client. Separation allows client and server to be
independently deployed and updated.
Stateless: Each request from client to server must contain all the information
necessary to understand the request, and cannot take advantage of any
stored context on the server.
Catchable: Catch constrain requires that the data within the response to a request
be implicitly or explicitly labeled as catchable or non-catchable. Then a
client cache is given the right to reuse that response data for later, equivalent
requests. Completely eliminate some attractions and improve efficiency and
scalability.
Layered system: System constraint come off constraints, constrains the behavior
of components such that each component cannot see beyond the
immediate layer with which they are interacting.
Example client cannot tell whether it is connected directly to the end server or to
an intermediary along the way system scalability can be improved
allowing intermediaries to respond to request instead of tender server.
Uniform interface: Uniform interface constraints require that the method of
communication between client and server must be uniform. Resources are
identified in the request and separate from the representation of the
resource that is returned to the client. When climbing holds a representation of
your resource it has all the information required to update or delete the resource
Code on demand: Service can provide executable code script for clients to
execute in their context.
Figure: REST-based Communication APIs

b) WebSocket based communication API:


WebSocket API allow bi directional, full duplex communication between client
and server. Unlike request-response API allow full duplex communication and do not
require new connection to be set up for each message to be sent.
Websocket communication begins with connection setup request send by the
client to the server. The request is sent over http and the server interprets it as an
upgrade request.
If the server support protocol response to the website handshake response after the
connection setup the client and the server can send data or messages to each other in
full duplex model.
WebSocket API reduce network traffic and latency as there is no overhead for
connection setup and determination records to each message.
Figure: WebSocket based Communication APIs

1.6 IoT Enabled Technologies:


It is enabled by several Technologies including wireless sensor networks, cloud computing big
Data Analytics, embedded system, security protocols and architectures, communication
protocols, web service, mobile internet and semantic search engine.

(i) Wireless sensor network


Wireless sensor network (wsn) comprise of distributed devices with the sensor which are
used to monitor the environmental and physical conditions. A WSN consists of a number of end
nodes and routers and a coordinator. End nodes have several sensors attached to them. End node
can also act as routers. Routers are responsible for routing the data packet from end nodes to the
coordinator. The coordinator node collect the data from all the notes coordinator also act as a
Gateway that connects the WSN to the internet. IoT systems are described as follows
• Weather monitoring system using WSN in which the nodes collect temperature, humidity
and other data which is aggregated and analyzed .
• Indoor air quality monitoring system using WSN to collect data on the indoor air quality
and connections of various gases.
• Soil moisture monitoring system using WSN to monitor soil moisture at various location.
• Surveillance systems use WSN for collecting surveillance data(motion detection data)
• Smart grid use wireless sensor network for monitoring the grid at various point.
• Structural health monitoring systems use WSN to monitor the health of structure by
writing vibration data from sensor nodes deployed at various points in the structure.

(ii) Cloud computing:


Cloud Computing is a transformative computing paradigm that involves delivering
applications and services over the internet. Cloud Computing involves provisioning of
computing networking and storage resources on demand and providing these resources as
metered services to the users, in a “pay as you go” model. Cloud Computing resources can be
provisioned on demand by the user without requiring interactions with the Cloud Service
Provider.
The process of provisioning resources used automatic Cloud Computing resources can be
accessed then it worked using standard access mechanism that provide platform-independent
access through the use of heterogeneous client platforms such as workstations laptops tablets and
Smartphones the computing and storage resources provided by Cloud Service Provider our food
to serve multiple user using multi Tenancy. Multi-tenant aspects on the multiple users to be
served by the same physical hardware. Cloud Computing services are offered to user in different
forms
Infrastructure as a service (IAAS) :
IaaS provides the user the ability provision computing and storage resources. These
resources are provided to the users as virtual machine instances and virtual storage. Users can
start, stop configure and manage the virtual machines instance on the virtual storage using can
deploy operating systems and applications on their choice on the actual resources provisions in
the cloud . Cloud Service Provider manages the underlying infrastructure.
Platform as a service(PaaS) :
Platform as a service provides the user the ability to develop and deploy application in
the cloud using the deployment tool application programming interfaces API, software libraries
and services provided by the Cloud Service Provider. The Cloud Service Provider manages the
underlying cloud infrastructure including servers, network, operating systems and storage.
Software as a service(SaaS) :
Provide the user a complete software applications of the user interface to the application
itself. The Cloud Service Provider manage the underlying cloud infrastructure including server,
network storage and application software, and the user is unaware of the underlying architecture
of the cloud. Applications are provided to the user through a thin client interface example
Browser application. SaaS applications are accessed from various client smartphones running
different operating system.
(iii) Embedded systems:
An Embedded system is computer system that has computer hardware and software
embedded perform specific task. In contrast to general purpose computers or personal computers
which can perform various types of tasks, embedded systems are designed to perform a specific
set of tasks. Embedded system include Microprocessor and Microcontroller memory Ram ROM
cache networking units (Ethernet WI-FI adaptor) input/output unit display keyboard , display and
storage such as Flash Memory some embedded system have specialist processes such as digital
signal processor DSP graphic processor and application.

1.7 IoT levels and Deployment Templates:


The various levels of IoT systems are defined completely. IoT system comprises of the following
components:
1. Device : An IoT device allow identification, remote sensing, actuating and remote monitoring
capabilities.
2. Resources : Resources are software components on the device for accessing and storing
information for controlling actuator connected to the device also include software components
that enable network access for the device .
3. Controller service: Controller Service is a native service that runs on the device and interact
with the web services. Controller service sends data from the device to the web service receive
command from the application from controlling the device.
4. Database: Database can be either local or in the cloud and stores the data generated by the
IoT device.
5. Web service: Serve as a link between the device, application database and analysis
components. Web Services can be implemented using HTTP and REST principles or using
website protocol.
A comparison of restaurant website is provided below:
Stateless/stateful:
Rest services stateless in nature. Each request contain all the information needed to
process it. Requests are independent of each other. Website on the other hand is stateful in nature
where the server maintains the state and is aware of all the open connections.

Directional / Bi- directional:


REST service operate over http and unidirectional. Request is always sent by a client and
the server response to the request. And other hand website is a bi directional product server to
send message to each other

Request response / full duplex:


REST service follower request response Communications model where the client sends
request and the server response to the request. Website and the other hand Allow full-duplex
Communications between the client and server, it means both client and server can send
messages to can independently.

TCP connections:
For REST Service each http request involves setting up a new TCP connection.
Websocket on the other hand involves a single TCP connection over which the client and server
communicate in a full duplex mode.

Headache Overhead:
REST service operate over http, and each request is independent of others . Thus each
request carries http header which is an overhead. Due to the overhead of http headers, REST is
not suitable for real time applications left hand does not involve overhead of headers. After the
initial handshake the client and server exchange messages with minimal frame information.

Scalability:
Scalability is easier in this case of the REST services of request are independent and no
state information needs to be maintained by the server. Thus both horizontal out and vertical
scaling solutions are possible for REST services. For webSockets horizontal scaling can be
cumbersome due to stateful nature of the communication. Since the server maintains the state of
our connection, vertical scaling is easier for Websocket than horizontal scaling.

Analysis component:
The analysis component is responsible for analyzing the IoT data and generate results in
the form which are easy for the user to understand. Analysis of IoT data can be performed either
locally or in the cloud. Analyzed results are stored in the local or cloud database.

Application: IoT applications provide an interface that the user can use to control and monitor
various aspects of the IoT system. Applications also allow user to view the system status and
view the processed data.

IoT level 1:
Level One IoT system has a single node / device that performs sensing and/or actuation,
stores data, reforms analysis and the host to the application. Level 1 IoT systems are suitable for
modeling low cost and low complexity solutions where the data involving is not big and the
analysis requirements are not computationally intensive.
Let us now consider done example of Level 1 IoT system for home automation. This
system consists of the single node that allows controlling the lights and appliances in your home
remotely. The device used in this system interface with their lights and appliances using
electronic relay switches.
The status information of each light or appliance is maintained in a local database. REST
service deployed locally Allow retrieving and updating the state of the each light or appliances in
the status database.
The controller service continuously monitors the state of each light or appliance and
triggers the relay switches accordingly. The application which is deployed locally has a user
interface for controlling the lights or appliances. Since the device is connected to the internet, the
application can be accessed remotely as well.

IoT level 2:
Level 2 IoT system has a single node that performs sensing and/or actuation and local
analysis. Data is stored in the cloud and application is usually cloud based systems are suitable
for solutions where the data in world is big, however the primary analysis requirement is not
computationally intensive and can be done local itself.
Construct an example of Level 2 IoT system for smart irrigation. The system consists of
the single node that monitor the soil moisture level and control segregation system. The device
used in this system collect soil moisture data from sensor the controller service continuously
monitor the moisture level. If the monster level drops below a threshold t , the irrigation system
is turned on.
For controlling the irrigation system actuators such as solenoid valve can be used.. Rest
Web Services is used for storing and retrieving data which is stored in the cloud database. A
cloud based application is used for visualizing the moisture level over a period of time, which
can help in making decisions about irrigation schedules.
IoT Level 3:
Level 3 system has a single node . Data is stored and analyzed in the cloud application
is cloud-based. Level 3 IoT system suitable for solutions where the data involved is big and
analysis requirements computationally intensive.
Let us considered example of Level 3 IoT system tracking package handling. The system
consists of a single node that monitors the vibration level for package being shipped. The device
in the system uses accelerometer and gyroscope sensor for monitoring vibration levels. The
controller service send sensor data to the cloud in real time using a website service. The data is
stored in the cloud and also visualized using a cloud based application.
The analysis component in the cloud can Trigger alert the vibration level become greater
than threshold. The benefit of using websocket service instead of the REST service this example
the sensor data can be sent in real-time to the cloud. Cloud based application can subscribe to the
sensor data feeds for you in the real-time data.
IoT level 4:
A level 4 IoT system has multiple notes that perform local analysis. Data is stored in the
cloud and application is cloud based, level 4 contains local and cloud based observer notes which
can subscribe to and receive information collected in the cloud from IoT devices.
Observer node can process information and use it for various applications, however
observer notes do not perform any control function. level 4 IoT systems are suitable for solutions
where multiple nodes are required the data involved is big and the analysis requirements are
computationally intensive.
Let us consider an example of level four IoT system for noise monitoring. The system
consists of multiple notes placed in different locations for monitoring noise level in an area. In
this example with sound sensor nodes are independent of each other each node runs in one
controller service that sends the data to the cloud. The data is stored in a cloud database the
analysis of the data collected from a number of notes is done in the cloud.

IoT Level 5:
IoT system has multiple end nodes and one coordinator notes and notes that perform
sensing and / or actuation. Coordinator node collects data from the entry and send to the cloud.
Data is stored and analyzed in the cloud and applications is cloud based. Level 5 IoT system are
suitable for forest fire detection.
The system consists of multiple nodes placed in different locations for monitoring
temperature, humidity and carbon dioxide levels in a forest. The endnotes in this example are
equipped with various sensors such as temperature humidity and to CO2.
The coordinator node collects the data from the end nodes and act as a Gateway that
provides internet connectivity to the IoT system. The controller service on the coordinator device
sends the collected data to the cloud .The data is stored in the cloud database. The analysis of the
data is done in the computing cloud to aggregate the data and make prediction.
IoT Level 6:
IoT Level 6 system has multiple Independent and nodes that perform sensing and / or
actuations and send data to the cloud. Data is stored in the cloud and applications is cloud based.
The analytics component analyze the data and store the results in the cloud database. The results
are visualized with the cloud based application. The centralized controller is aware of the status
of all the end notes and send control commands to the notes.
Let us consider an example of the level 6 IoT system for weather monitoring. The system
consists of multiple nodes placed in different location for monitoring temperature, humidity and
pressure in an area. The end nodes are equipped with various sensors such as
temperature ,pressure and humidity. The end nodes send the data to the cloud in real time using a
websocket service .The data is stored in a cloud database. The analysis of the data is done in the
cloud to aggregate the data and make predictions. A cloud based applications is used for
visualizing the data.
1.8 Domain-specific IoT
Internet of things applications span wide range of Dubai including homes, cities
environment, energy systems, retail, logistics, industry, agriculture and health.
1. Home Automation:
(i) Smart lighting :
Smart lighting for homes helps in saving energy by adapting the lighting to the ambient
condition and switching on/off or dimming the lights when needed. Key enabling technologies
for smart lighting include solid-state lighting such as LED light and IP enabled the lights.
For solid state lighting solution both spectral and temporal characteristics can be
configured to adapt illumination to various needs. Smart lighting solutions for Home achieve
energy saving by sensing the human movements and their environments and controlling the
lights accordingly.
Wireless enabled and internet connected lights can be controlled remotely from IoT
applications such as a mobile or web application. Smart lights with sensor for occupancy,
Temperature Lux level etc can be configured to adapt the lighting based on the ambient
conditions sensed, in order to provide a good ambience. In controllable LED lighting system is
presented that is embedded with ambient intelligence gathered from a distributed smart wireless
sensor network to optimize and control the lighting system to be more efficient and user oriented,
A solid state lighting model is implemented on your wireless sensor network that provide
services for sensing illumination changes and dynamically adjusting luminary brightness
according to user preferences.
(ii) Smart Appliances:
Modern homes have a number of appliances such as TVs, refrigerator, music system,
washer / dryer etc. Managing and controlling these appliances can be cumbersome with the each
appliance having its own controls or remote controls. Smart appliance make the management
easier and also provide status information to the user remotely.
Examples smart watches /dryers that can be controlled remotely and notify when the
washing / driving cycle is complete smart thermostat Allow controlling the temperature remotely
and can learn the user preferences smart refrigerator can keep track of the item stored and send
update to the user when an item is low on stock.
Smart TV Allows user to search and stream videos and movies from the internet on a
local storage drive, search TV channel schedule and fetch news weather updates and other
content from the internet.
Open remote is an open source automation platform for homes buildings. Open remote is
platform agnostic and works with standard hardware. With OpenRemote, user can control
various appliances using mobile or web publications.
OpenRemote comprises of three components - a controller that manages scheduling and
runtime integrations between device, a designer that allows you to create both configuration for
the controller and create user interface design and control panel that allow you to interact with
the devices and control them.

(iii) Intrusion Detection:


Home Intrusion detection system used security cameras and sensor such as PIR sensors
and door sensor to detect intrusion and raise alert. Alerts can be in the form of an SMS and an
email sent to the user.
Advanced systems can even send detailed alert such as an image grab or a short video
clip send to email attachment. cloud controlled intrusion detections system is described in that
uses location aware services, where the geo location of each node of your home automation
system used independently detected and the stored in the cloud in the event of Institutions the
cloud services alert the accurate neighbors who are using the home automation system is
independently detected and stored in the cloud.
Event of intrusion, the cloud services after the accurate neighbors or local police. In an
intrusion detection system based on UPnP technology is described. The system uses image
processing to recognize the Institutions and extract institution subject and to generate Universal
plug and play instant messaging for alert .

(iv) Smoke / Gas Detector


Smoke detectors are installed in home and buildings to detect smoke that is typically and
early sign of Fire. Smoke detectors use optical detection class ionization for sampling techniques
to detect smoke.
Alerts raised by smoke detectors can be in the form of signals to fire alarm system. Gas
detectors can detect the presence of harmful gases such as carbon monoxide liquid Petroleum gas
(LPG).
A Smoke / gas detector raise alerts in human was this describing where the problem is
send or an SMS or email to the user or the local fire safety department and provide visual
feedback on its status the design of the system that detects gas leakage on smoke and it
gives visual level indication.

2. Smart Cities:
(i) Smart Parking
Finding a parking space during rush hours in crowded cities can be time consuming and
frustrating. Further for the more drivers blindly searching for parking spaces create additional
traffic conditions for Star smart parking make the search for parking space easier and convenient
for drivers.
Smart parking for powered by IoT system that detect the number of empty parking slots
and send the information over the internet to smart parking application back ends. These
applications can be accessed by the drivers from smartphones, tablets and in car navigation
system.
In smart parking sensors are used for each parking slot, to detect whether the slot is
empty or occupied. This information is aggregated by your local controller and then send over
the internet to the database. Design and implementation of a prototype smart parking system
based on wireless sensor Network Technology with just like a remote parking
monitoring ,automated guidance, and departing reservations mechanism .

(ii) Smart Lighting :


Smart lighting system for road parks and building can help in saving energy. According
to a IEA report, lightening is responsible for 19 % of global electricity use and around 6%
of global Greenhouse gas emission.
Smart lighting allows lighting to be dynamically controlled and also adapted to the
ambient conditions. Smart lights connected to the internet can be controlled remotely to
configure lighting schedules and lighting intensity.
Lighting configuration can be set for different situations such as a foggy day, a festival
etc. Smart. Lights equipped with the sensors and can communicate with other lights and
exchange information on the sensed ambient conditions to adapt lightening.

(iii) Smart Road:


Smart roads equipped with sensors can provide information on driving conditions, travel
time estimates and alerts in case of poor driving conditions , traffic congestions and accidents.
Such information can help in making the roads safe and help in reducing traffic jams.
Information sense to from the roads can be communicated via internet to cloud based
applications and social media and disseminated to the drivers who subscribed to such
applications.
Distributed and autonomous systems of sensor networks notes for improving driving
safety proposed system can provide the drivers and passengers with a consistent view of the road
situations of a few hundred meters ahead of them or a few dozen miles away, so that they can
react to potential dangers early enough.

(iv) Structural Health Monitoring:


Structural health monitoring system uses a network of sensors to monitor the vibrations
levels in the structures such as bridges and buildings. The data collected from the sensors is
analyzed to assess the health of the structures.
By analyzing the data it is possible to detect cracks and mechanical breakdown, locate the
damage to a structure and also calculate the remaining life of the structure. Using such systems
advance warning can be given in the case of imminent failure of the structure.
An environmental effect removal based structural health monitoring schemes is an IoT
environment is proposed. Since structural health monitoring schemes use large number of
wireless sensor nodes which are powered by traditional batteries researchers are exploring
energy harvesting Technologies to harvesting ambient energy, such as mechanical vibrations,
sunlight and wind.

(v) Surveillance
Surveillance of infrastructure, public transport and even in cities is required to ensure
safety and security. City wide surveillance infrastructure comprising of large number of
distributed and internet connected video surveillance cameras can be created. The video feeds
from surveillance cameras can be aggregated in cloud based storage solutions.
Cloud-based video analytics applications can be deployed to search for patterns for
specific events from the video feed.
Emergency Response IoT Systems can be used for monitoring the critical infrastructure
in cities such as building, gas and water pipelines, public transport and power substation systems.
IoT systems for fire directions, gas and water leakage directions can help in generating alerts and
minimizing their effects on the critical infrastructure.
IoT systems for critical infrastructure monitoring enable aggregations and sharing of
information is collected from large number of sensors. Cloud based architecture multimodel
information such as sensor data, audio, video feeds can be analyzed in near realtime to detect
adverse event.
Response to alerts generated by such systems can be in the form of alerts sent to the
public, re-routing of traffic, evacuation of the affected areas. Traffic management system for
emergency services is describe the system adapt by dynamically adjusting traffic lights, changing
related driving policies, recommending behavior change to drivers and applying essential
security controls.

3. Environment:
(i) Weather Monitoring:
IoT- based weather monitoring system can collect data from a number of sensor attached
such as temperature, humidity, pressure etc. and send the data to cloud based application and
storage back-ends. The data collected in the cloud can then be analyzed and visualized by cloud
based application.
Weather alerts can be sent to the subscribed users from such applications AirPi weather
and air quality monitoring kit capable of recording and uploading information about temperature,
humidity, air pressure light levels, UV levels, carbon monoxide Nitrogen dioxide and smoke
level to the internet.
(ii) Air Pollution Monitoring:
IoT based air pollution monitoring system can monitor emission of harmful gases ( CO2,
CO. NO, NO2) by factories and automobiles using gases and dermatological sensors the
collected data can be analyzed to make informed decisions on pollutions control approaches.
In real time air quality monitoring system is presented that comprises of several
distributed monitoring stations that communicate via wireless with a backend server using
machine to machine communication. In addition sums of GPRS modem and GPS module.

(iii) Noise Pollution Monitoring:


Due to growing Urban Development, noise levels in cities have increased and even
become alarmingly High in some cities. Noise pollution can cause health hazards for humans due
to sleep destruction and stress. Noise pollution monitoring can help in generating noise maps for
cities.
Urban noise maps can help the policy makers in urban planning and making policies to
control noise level near Residency areas, schools and parks. IoT based noise pollution smart
metering system use a number of noise monitoring station that are deployed at different places in
a city.
The data on noise levels from the stations is collected on server or in the cloud. The data
is then aggregated to generate noise map. In noise mapping study for a city is presented which
revealed that the cities suffers from serious noise pollution .In the design of smart phone
application is described that allows a user to continuously measure noise level and send it to a
central server where all generated information is aggregated and mapped to a meaningful noise
visualizations map.

(iv) Forest Fire Detection:


Forest fires can cause damage to natural resources, property and human life. There can be
different causes of forest fires including lightening, human negligence, volcanic eruptions and
sparks from rock Falls. Early deduction of forest fires can help in minimizing the damage.
IoT based forest fire detection systems can use a number of monitoring nodes deployed at
a different locations in a forest. Each monitoring node collects measurements on ambient
conditions including temperature, humidity, light levels.
A system for early detection of forest fire is described in that provides early warning of a
potential forest fire and estimate the scale and intensity of the fire if it materializes in a forest fire
detection system based on wireless sensor networks is presented.
The system uses multi-criteria deduction which is implemented by the artificial neural
network. The ANN fuses sensing data corresponding to multiple attributes of your forest fire
such as temperature, humidity, infrared and divisible light to detect forest fire.

(v) River Flood Detection:


River flood can cause extensive damage to the natural and human resources and human
life. River flood occurs due to continuous train for which cause the river level to rise and flow
rates to increase rapidly. Early warnings of floods can be given by monitoring the water level
and flow rate.
IoT based river flood monitoring system uses a number of sensor nodes that monitor the
water level using ultrasonic sensors and flow rate using the flow velocity sensors. Data from a
number of such sensor nodes is aggregated in a server or in the cloud.
Monitoring applications raise alert when rapid increase in water level and flow rate is
detected in a river flood monitoring system is described that measures river and weather
conditions through wireless sensor nodes equipped with different sensors. The systems include
water level monitoring module, and data processing module that provide flood information is in
the form of raw data, predicted data, and video feed.
4. Energy
Smart grid is a data communication network integrated with electrical grid that collects
and analyses data captured in real-time about power transmission, distribution and consumption.
Smart grid Technology provides protective information and recommendations to utilities, their
suppliers, and their customers on how best to manage power.
Smart Grids collect data regarding electricity generation (centralized or distributed
conceptions (instantaneous or predictive ) storage(or conversion of the energy into other forms),
distributions and equipment health data.
Smart fleet use high speed, fully integrated two way communication real time
information and power exchange. Smart meters can capture almost real time consumption,
remotely control the conceptions of electricity and remotely switch off supply when required.
power thefts can be prevented using smart metering by analyzing the data on power generation,
transmission and consumption smart grid can improve efficiency throughout the electric system.
Storage collection and analysis of smart grids data in the cloud can help in dynamic smart
grids data can improve energy usage levels via energy feedback to user coupled with realtime
pricing information.
Real time demand response and management strategies can be used for lowering peak
demand and the overall load via appliance control and energy storage mechanism. Condition
monitoring data collected from power generation and transmission system can help in detecting
fault and predicting outage.

(i) Renewable Energy System :


Due to the variability in the output from renewable energy sources such as solar and wind
integrating them into the grid can cause grid stability and reliability problems. Variable output
produces local voltage swing that can impact power quality. Existing grids were designed to
handle power flow from centralized to generation source to the loads through Transmission and
distribution lines.
When distributed renewable energy sources are integrated into the grid, they create power
bidirectional power flow for which the great were not originally designed to handle power flow
from temperature generation sources to the loss through transmissions and distribution lines.
When Distributed renewable energy sources are integrated into the grid is a create power
bi-directional power flows for which the grid were not originally designed. IoT based system
integrated within Transformer at the point of interconnections measures the electrical variables
and how much power is fed into the grid.
To ensure the grid stability one solution is to simply cut of the over protections. For wind
energy systems, closed-loop controls can be used to regulate the voltage at points of
interconnection

(ii) Prognostics:
Energy systems (Smart grids, power plants ,wind turbine forms) have a large number of
critical components that must function correctly so that the system can perform their operations
correctly.
For example a wind turbine has a number of critical components example bearing,
turning gears, for instance that must be monitored carefully as wear and tear in such critical
components or sudden change in operating conditions of the missions can result in failures. In
system such as Power Grids, real time information using specialist electrical sensor is called
phasor measurement unit (PMU) substations.
The information received from PMU must be monitored in real time for estimating the
state of a system and for predicting failures. Energy system have thousands of sensors that gather
real time maintenance data continuously for condition monitoring and failure prediction
purposes. IoT based prognostic real-time health management systems can predict performance of
machine or energy Systems by analyzing the extent of deviations of the system from its normal
operating profiles.
Analyzing massive amounts of maintenance data collected from sensors in energy
systems and equipment can provide protections for the impending failures (potentially in real
time) so that their reliability and availability can be improved. Prognostic health Management
systems have been developed for different energy systems open PDC set of applications for
processing of streaming time series data collected from phasor measurement units PMU in real
time.

5. Agriculture:
(i) Smart Irrigation:
Smart irrigation systems can improve crop yield while saving water. smart irrigation
system using IoT devices with soil moisture sensors to determine the amount of moisture in the
soil and realize the flow of water through the irrigation pipe only when the moisture level go
below a predefined threshold. Smart irrigation systems also collect Moisture level measurements
on a server or in the cloud where they collected data can be analyzed to plant watering schedule.

(ii) Green House Control:


Green house structures with glass or plastic roofs that provide conducive environment for
growth of plants . The Climatological conditions inside a Greenhouse can be monitored and
controlled to provide the best conditions for growth of plants. The temperature, humidity, soil
moisture, light and carbon dioxide levels are monitored using sensors and their climatological
conditions are controlled automatically using actuation devices.
IoT system plays an important role in greenhouse controlled and help in improving
productivity. The data collected from various sensors is stored on centralized servers or in the
cloud where analysis is performed to optimize the control strategies and also correlate the
productivity with different control strategies. The system uses wireless sensor network to
monitor and control the agriculture parameters like temperature and humidity in real time for
better management and maintenance of Agricultural production

6. Industry:
(i) Machine Diagnosis and Prognosis:
Machine prognosis refers to predicting the performance of a machine by analyzing the
data and the current operating conditions and how much deviations exist from the normal
operating conditions. Machine diagnosis refer to determining the causes of a machine
fault.
IoT plays a major role in both the prognosis s and Diagnostics of industrial machines.
Industrial machines have a large number of components that must function correctly for the
machine to perform its operations. Sensors in machine can monitor the operating conditions such
as temperatures and vibrations levels.
The sensor data measurements are done on time scale of few milliseconds to few
seconds, which leads to generations of the massive amount of the data.
Case-based reasoning (CBR) is a commonly used method to find solutions for new
problem based on past experience. This past experience is organized and represented as case in a
case base. CBR is an effective technique for problem solving in the field in which it is hard to
establish a quantitative mathematical model, such as machine Diagnostics and prognosis.
Since foe each machine, data from a very large number of sensors is collected using
search high-dimensional data for creation of a case library reduce the case retrieval efficiency.
Data reduction and feature extraction methods are used to find the representatives set of ability
as the of features.
(ii) Indoor Air Quality Monitoring:
Monitoring indoor air quality in factories is important for health and safety of the
workers. Harmful and toxic gas such as carbon monoxide, nitrogen monoxide and Nitrogen
dioxide etc can cause serious health problems .IoT based gas monitoring system can help in
monitoring the indoor air quality using various gas sensors. The indoor air quality can vary for
different locations. Wireless sensor networks based IoT devices can identify the other hazardous
zones, so that a corrective measure can be taken to ensure proper ventilation.
UNIT II IOT PROTOCOLS 9
Protocol Standardization for IoT – Efforts – M2M and WSN Protocols – SCADA and RFID
Protocols – Issues with IoT Standardization – Unified Data Standards – Protocols –
IEEE802.15.4 – BACNet Protocol– Modbus – KNX – Zigbee– Network layer – APS layer –
Security

2.1 Protocol Standardization for IoT:


In IoT, the interconnected devices are usually of short range low power wireless devices
with their own predefined set of operations or purpose.
Because of this, the protocols that are IOT Protocol Standardization currently used on the
internet cannot be directly used in these devices.
This brought in the need for creating a new set of protocols which can be catered to the
requirements of the IoT world.

IoT Stakeholders:
 Service Provider,
 Developers,
 Investor
 Investor and
 User

Figure: Protocol Standardization for IoT

The IoT- A (Internet of Things architecture) is targeting a holistic (universal) architecture


for all IoT sectors.17 European organizations from nine countries are a part of IoT- A.They
summarize the current status of IoT standardization as:
 Fragmented architectures
 No universal approach to implement IoT has yet been proposed
 Many island solutions do exist (RFID, sensor nets, etc.)
 Little cross-sector reuse of technology and exchange of knowledge

Proposed solution by IoT-A for Standardization:


Create Architectural foundation for IoT, that will be operable with future Internet
Use Existing technologies instead of creating new ones.
Demonstrating the applicability of IoT in a set of use cases
Interdisciplinary - Establish a strong stakeholder group to remove the barriers and accept
IoT on wide scale
Uniting Heterogeneous - Combine various IoT technologies into a single entity.

Groups working for standardization:


Aim to form an open group of companies to market and educate about how to use IP for
IoT smart objects based on an all- IP holistic approach. The groups working for standardization
are :
1) Work Package (WP)
2) Internet Protocol for Smart Object (IPSO)
3) International Telecommunication Union Telecommunication Standardization
Sector(ITU-T)

Work Package (WP):


It defines the overall gross view of an IoT System with respect to stakeholders. Work
Package also defines
 Use cases of the application which gives clear idea of available functionalities.
 Circulation of these services worldwide and its impact over the business.
The WPF divides the implementation standards of IoT into hierarchical groups of tasks as shown
in the below

Figure: Work Package hierarchical groups of tasks

Architectural Reference Model:


It describes which smart objects will deployed in the field, how they will be
communicating i.e. protocol used and service identification and how this service will be
integrating with future development of IoT. It is generated by gathering requirements from stake
holders.

Internet Protocol for smart objects (IPOS):


The IPSO Alliance is an open, informal and thought-leading association of like-minded
organizations and individuals that promote the value of using the Internet Protocol for the
networking of Smart Objects.
IP Stack can easily run on tiny, battery operated embedded devices as it is long-lived and
stable technology. The role of the alliance is to ensure how IPv4, IPv6, and 6LoWPAN are used,
deployed and provided to all potential users. Mobile IP is an approach by IETF (Internet
Engineering Task Force) which manages the movement of mobile devices over IPV4 and IPV6
IPOS defines an all IP approach for IoT standardization. IP defines wide range of
protocol that can be used to create highly scalable communication technology. IP provide an
Open, Lightweight, stable, pervasive and manageable way to communicate between applications
and devices. IPOS defines a smart object as:
1) An RFID tag (intelligent Device)
2) A sensor: A device that measures physical change in analog or digital format.
3) An actuator: a device that is able to alter or control physical devices in the field.
4) An Embedded device small electric devices build to serve specific functionality
5) Any complex combination of above devices.

Figure: All IP Network Protocol

International Telecommunication Union Telecommunication Standardization Sector


The ITU-T mission is to ensure the efficient and timely production of standards covering
all fields of telecommunications on a worldwide basis, as well as defining tariff and accounting
principles for international telecommunication services
The technical work, the development of Recommendations, of ITU-T is managed by
Study Groups (SGs).There are currently 11 SGs.
2.2 Efforts - M2M and WSN Protocols – SCADA and RFID Protocols:
M2M Standardization Efforts:
M2M Standardization Task Force (MSTF) coordinate the efforts of individual standards
development organizations (SDO) for M2M Applications. These define a conceptual framework
for M2M applications and specify a service layer that will enable application developers to create
applications that operate transparently across different vertical domains.
M2M standards activities include the following
• Use JSON as Data Transport Format
• Resolve IP addressing issues for devices IPV6
• Use Open REST- based API for M2M applications
• Remote management of devices behind a gateway or firewall be done
• Fix the charging standards

WSN Standardization Efforts:


There are number of standardization bodies in the field of WSNs. The IEEE focuses on
the physical and MAC layers. IETF works on layers 3 and above. IEEE 1451 is a set of smart
transducer interface standards developed by the IEEE Instrumentation and Measurement
Society’s Sensor Technology Technical Committee that describe a set of open, common,
network- independent communication interfaces for connecting sensors or actuators) to
microprocessors, instrumentation systems, and control/field networks
The goal of the IEEE 1451 family of standards is to allow the access of transducer data
through a common set of interfaces whether the transducers are connected to systems or
networks via a wired or wireless means

IEEE 1451 Activities:


• 1451.0-2007 Common Functions, Communication Protocols
• 1451.1-1999 Network Capable Application Processor Information Model
• 1451.2-1997 Transducer to Microprocessor Communication Protocols
• 1451.3-2003 Digital Communication Formats for Distributed Multi- drop Systems
• 1451.4-2004 Mixed- mode Communication Protocols
• 1451.5-2007 Wireless Communication Protocols
• 1451.7-2010 Transducers to Radio Frequency Identification (RFID) Systems
Communication Protocols

SCADA Standardization Efforts:


Supervisory Control and Data Acquisition is one of the IoT pillars to represent the whole
industrial automation arena.
IEEE created a standard specification, called StdC37.1™, for SCADA and automation
systems in the year 2007. The processing is now distributed, and functions that used to be done
at the control center can now be done by the intelligent electronic devices (IED) that is, M2M
between devices.
The ISA100 was developed by the standards committee of the Industrial Society for
Automation formed to define procedures for implementing wireless systems in the automation
and control environment with a focus on the field level.
OPC, which stands for Object Linking and Embedding (OLE) for Process Control
standard specification developed by an industrial automation industry task force (IAITF) . The
standard specifies the communication of real- time plant data between control devices from
different manufacturers.
OPC was designed to provide a common bridge for Windows- based software
applications and process control hardware.
In recent years, network-based industrial automation has greatly evolved with the use of
intelligent electronic devices (IEDs), or IoT devices in our terms, in substations and power
stations.
The processing is now distributed Functions that used to be done at control center can now be
done by IED i.e. M2M between devices Due to restructuring of electric industry, traditional
vertically integrated electric utilities are replaced by many entities such as
• GENCO (Generation Company),
• TRANSCO (Transmission Company),
• DISCO (Distribution Company),
• ISO (Independent System Operator), etc.

Figure: SCADA - IoT devices in substations and power stations

RFID Standardization Efforts


The RFID protocols and data formats are relatively well defined, mostly by EPC global
(Electronic Product Code).
The standard for contactless smart card communications is ISO/ IEC 14443 allows for
communications at distances up to 10 cm. ISO/ IEC 15693, which allows communications at
distances up to 50 cm International Organization for Standardization (ISO) and the International
Electrotechnical Commission (IEC).

2.3 Issues with IoT Standardization:


It should be noted that not everything about standardization is positive Standardization is
like a double-edged sword critical to market development but it may threaten innovation and
inhibit change when standards are accepted by the market. Standardization and innovation are
like yin & yang. They could be contradictory to each other in some cases, even though this
observation is debatable.
Different consortia, forums and alliances have been doing standardization in their own
limited scope. For example, 3GPP covers only cellular wireless networks while EPC global’s
middleware covers only RFID events. Even within same segment, there are more than one
consortium or forum doing standardization without enough communication with each other some
are even competing with each other.
Some people believe that the IoT concept is well established however, some gray zones
remain in the definition, especially which technology should be included. Following two issues
for IoT standardization in particular and ICT standardization in general may never have answers:
1. ICT standardization is a highly decentralized activity. How can the individual
activities of the network of extremely heterogeneous standards setting bodies be
coordinated?
2. It will become essential to allow all interested stakeholders to participate in the
standardization process toward the IoT and to voice their respective requirements
and concerns. How can this be achieved?

2.4 Unified Data Standards:


The two pillars of the Internet HTML/HTTP combination of data format and exchange
protocol is the foundation pillar of WWW .Great number of data standards and protocols
proposed for four pillar domains of IoT. Many issues still impede the development of IoT and
especially WoT vision.

Many standardization efforts have been trying to define unified data representation,
protocol for IoT. Before IoT, Internet was actually an Internet of documents or of multimedia
documents. Two pillars of Internet including HTML/HTTP turned the Internet into WWW. We
need to turn the IoT into the WoT. What will it take to make this to happen?
Do we need a new HTML/HTTP-like standard for MTC and WoT? If there is no need to
reinvent the wheel, what extensions do we need to build on top of HTML/HTTP or HTML5?
Browser is intended for humans, so do we need new browser for machines to make sense
of ocean of machine-generated data? If not, what extensions do we need to make to the existing
browsers?
Today, most new protocols are built on top of XML. For OS there must be XML-based
data format standards or a metadata standard to represent the machine-generated data (MGD). Is
it possible to define such a metadata standard that covers everything?
There are many different levels of protocols but the ones that most directly relate to
business and social issues are the ones closest to the top so-called application protocols such as
HTML/HTTP for the web. Web has always been visual medium, but restricted until recently,
HTML developers were limited to CSS & JavaScript in order to produce animations or they
would have to rely on a plug-in like Flash.

2.5 Protocols – IEEE802.15.4:


Defines operation of low-rate wireless personal area networks (LR-WPANs)
• Specifies physical layer and media access control for LR-WPANs
• Maintained by IEEE 802.15 working group, which defined the standard in 2003
• Basic framework conceives a 10m communications range with a transfer rate of
250 kbit/s
• Physical Layer (PHY) provides data transmission service & interface to physical
layer management entity
• MAC enables transmission of MAC frames through the use of the physical
channel
IEEE 802.15.4 task group began to develop a standard for LR-WPAN. The goal of this
group was to provide a standard with ultra-low complexity, cost, and power for low-data-rate
wireless connectivity among inexpensive fixed, portable, and moving devices.
In order to achieve the low power and low cost goals established by IEEE 802.15.4 the
following approaches are taken
• Reduce the amount of data transmitted
• Reduce the transceiver duty cycle and frequency of data transmissions
• Reduce the frame overhead
• Reduce complexity
• Reduce range
• Implement strict power management mechanisms (power-down and sleep
IEEE 802.15.4 deals with only PHY layer and portion of Data link layer. The higher-
layer protocols are left to industry and the individual applications.
The Zigbee Alliance is an association of companies involved with building higher-layer
standards based on IEEE 802.15.4. This includes network, security, and application protocols.
IEEE 802.15.4 draft standard supports multiple network topologies including star and peer to
peer topology.
IEEE 802 splits DLL into MAC and LLC sublayers. LLC is standardized and is common in
802.3, 802.11, 802.15.1.
Features of the IEEE 802.15.4 MAC are
– Association and disassociation
– acknowledged frame delivery
– Channel access mechanism
– Frame validation
– Guaranteed time slot management
– Beacon management.

MAC provides data and management services to upper layers. 802.15.4 MAC is of very
low complexity, making it very suitable for its intended low end applications, albeit at the cost of
a smaller feature set than 802.15.1 (e.g., 802.15.4 does not support synchronous voice links).
Frame control field indicates the type of MAC frame being transmitted, specifies the
format of the address field, and controls the acknowledgment. Multiple address types: 64 bit
physical address and short 8 bit network assigned address are provided. Address field size may
vary from 0 to 20 bytes.
Payload field is variable with condition size of mac frame <= 127 bytes. FCS is used for
integrity check using 16 bit CRC. This standard provides 2 PHY options with frequency band as
fundamental difference.
2.4 GHz band has worldwide availability and provides a transmission rate of 250 kb/s.
The 868/915 MHz PHY specifies operation in the 868 MHz band in Europe and 915 MHz ISM
band in the United States and offer data rates 20 kb/s and 40 kb/s respectively. Different
transmission rates can be exploited to achieve a variety of different goals.

2.6 BACNet Protocol:


Communications protocol for Building Automation and Control (BAC) networks.
Provides mechanisms for computerized building automation devices to exchange information.
Designed to allow communication of building automation & control system for application like
Heating, Ventilating and Air-conditioning Control (HVAC), Lighting Control, Access Control,
Fire Detection Systems and their Associated Equipment.
Defines a number of services that are used to communicate between building devices
Protocol services include Who-Is, I-Am, Who-Has, I Have which are used for Device & Object
discovery. Services such as Read-Property and WriteProperty are used for data sharing. Defines
60 object types that are acted upon by services.
Building Automation and Control Networks developed by American Society of heating,
Refrigerating and Air Conditioning Engineers (ASHRAE). It is a data communication protocol
designed for communication between building automated system components. This is an Object
Oriented protocol.
 Objects : Physical device, temperature input( analog input) , A relay control(binary
output), schedules
 Services : Used to perform read, write and I/O
 BACNet Objects are evaluated and controlled by their properties.

BACNet Network Types: Physical and Data Link Layer BACNet IP


• Used with existing ethernet, WAN BACNet MS/TP
• Uses Twisted Pair EIA -485 upto 4000 feet BACNet ISO 8802-3
• Limited to Single Infrastructure without IP routers BACNet P2P
• Used only for dial-up telephone networks
BACNet Services
BACNet services are formal requests that one BACNet device sends to another to ask it
to do something
Categories :
– Object Access (Read, Write, Create, Delete)
– Alarm and Event (Alarms and Changes of State)
– File Access (Trend data, Data transfer)
– Remote Device Management (Discover, Time Synchronization, Backup and Restore Database,
Initialization)
– Virtual Terminal (HMI via menus)
– Who Is, I Am , Who-Has, I-Have

Figure:

2.7 Modbus:
MODBUS is an application layer messaging protocol, positioned at level 7 of the OSI
model, that provides client/server communication between devices connected on different types
of buses or networks.
The industry’s serial de facto standard since 1979, MODBUS continues to enable
millions of automation devices to communicate. Today, support for the simple and elegant
structure of MODBUS continues to grow. The Internet community can access MODBUS at a
reserved system port 502 on the TCP/IP stack.
MODBUS is a request/reply protocol and offers services specified by function codes.
MODBUS function codes are elements of MODBUS request/reply PDUs. The objective of this
document is to describe the function codes used within the framework of MODBUS transactions.
MODBUS is an application layer messaging protocol for client/server communication
between devices connected on different types of buses or networks.

Working:
The MODBUS protocol defines a simple protocol data unit (PDU) independent of the
underlying communication layers. The mapping of MODBUS protocol on specific buses or
network can introduce some additional fields on the application data unit (ADU).
Figure 3: General MODBUS frame
The MODBUS application data unit is built by the client that initiates a MODBUS
transaction. The function indicates to the server what kind of action to perform. The MODBUS
application protocol establishes the format of a request initiated by a client.
The function code field of a MODBUS data unit is coded in one byte. Valid codes are in
the range of 1 ... 255 decimal (the range 128 – 255 is reserved and used for exception responses).
When a message is sent from a Client to a Server device the function code field tells the server
what kind of action to perform. Function code "0" is not valid. Sub-function codes are added to
some function codes to define multiple actions. The data field of messages sent from a client to
server devices contains additional information that the server uses to take the action defined by
the function code.
This can include items like discrete and register addresses, the quantity of items to be
handled, and the count of actual data bytes in the field. The data field may be nonexistent (of
zero length) in certain kinds of requests, in this case the server does not require any additional
information. The function code alone specifies the action.
If no error occurs related to the MODBUS function requested in a properly received
MODBUS ADU the data field of a response from a server to a client contains the data requested.
If an error related to the MODBUS function requested occurs, the field contains an exception
code that the server application can use to determine the next action to be taken.
For example a client can read the ON / OFF states of a group of discrete outputs or inputs
or it can read/write the data contents of a group of registers. When the server responds to the
client, it uses the function code field to indicate either a normal (error-free) response or that some
kind of error occurred (called an exception response). For a normal response, the server simply
echoes to the request the original function code.

For an exception response, the server returns a code that is equivalent to the original
function code from the request PDU with its most significant bit set to logic 1.
2.8 KNX:
Intelligent bus systems make buildings more cost-effective to operate, safer, more
flexible, more energy-efficient and above all more comfortable and convenient. The KNX
standard occupies a large share of the market for building automation systems. The KNX
building automation system was originally known as the European Installation Bus (EIB), and
was developed and marketed by the EIB Association (EIBA).
In 1999, EIBA, Batibus Club International (BCI, France) and the European Home
Systems Association (EHSA, Netherlands) amalgamated, the name KNX was adopted, and the
Brussels-based KNX Association was set up. The technology used in modern KNX devices is
compatible with that of the old EIB system, so all devices bearing either the KNX or the EIB
logo are mutually compatible.
The KNX system is a bus system for building control. This means that all devices in a
KNX system use the same transmission method and are able to exchange data via a common bus
network. This has the following consequences:
· Access to the bus network needs to be clearly regulated (bus access method)
· Most of the data transmitted are not payloads (e. g. light on / light off signals), but
address information (i. e. where have the data come from? Where are they going to?)

Another important feature of the KNX bus system is its decentralised structure: there is
no need for a central control unit, because the “intelligence” of the system is spread across all of
its devices. Centralised units are possible, however, for realising very specialised applications.
Every device has its own microprocessor.
A major advantage of KNX’s decentralized structure is that, if one device fails, the others
continue to function. Only those applications dependent on the failed device will be interrupted.
Generally in a KNX system, devices fall into three categories: system devices (power supply,
programming interface, etc.), sensors, and actuators. Sensors are devices that detect events in the
building (e.g. someone pressing a button, someone moving, a temperature falling above or below
a set value, etc.), convert these into telegrams (data packets), and send them along the bus
network. Devices that receive telegrams and convert the commands embedded in them into
actions are known as actuators. Sensors issue commands, while actuators receive them.

Figure: Sensor/actuator principal


Working Logic:
The key to making a building “intelligent” is to equip it with networked sensors and
actuators. There are several different ways of doing this:
(i) Conventional methods
The immediately obvious solution is to employ a star topology, i. e. an arrangement
where every socket outlet circuit, ceiling or wall outlet, and light switch is linked by its own
(ideally five core) NYM cable to a central distribution board in which the logical relationships
are created by contactors, switch relays, and a programmable logic controller (PLC). This works
well in reasonably small dwellings. However, the size of the house only needs to increase by a
fairly small amount before the extent of the wiring work and size of the power distribution
boards required becomes excessive. In a star topology, adding to or extending the system is also
very time-consuming in terms of installation and programming.
(ii) Bus technology
A far better solution is to link all sensors and actuators in the building with a “data
cable”, and enable them to share information with each other (Fig.2). Each device can then
communicate with every other device, for example: a light switch can “talk” to a dimmer and tell
it how bright to set the ceiling light; a motion sensor can tell the actuator for the corridor lighting
that someone has entered the corridor, or tell the room thermostat that there is no one in the room
any more, so it can turn down the temperature.

Thanks to their decentralised structure, KNX bus systems can be modified and added to
exactly as required. The smallest possible KNX application is a system linking two bus devices:
a sensor and an actuator. This basic system can later be upgraded with as many devices as
necessary to perform the desired control tasks. Theoretically a KNX system can consist of more
than 50,000 devices. When extending a KNX system it is necessary to adhere to a specific
topology.

Communication media:
Various communication media (and hence transmission methods) can be used for the exchange
of data between devices in a KNX system:
1. KNX Twisted Pair (KNX TP)
communication via a twisted pair data cable (bus cable)
2. KNX Powerline (KNX PL)
uses the existing 230 V mains network
3. KNX Radio Frequency (KNX RF)
communication via radio signal
4. KNX IP
communication via Ethernet
Protocol:
The KNX system uses two Ethernet communication methods – tunneling and routing –
both of which use the UDP protocol. Tunneling is used to access the bus from a local network or
the internet for purposes of e. g. programming the KNX installation, while routing is used for
exchanging telegrams over an Ethernet network, e. g. to couple two KNX TP systems via
Ethernet.
The KNX protocols for these two communication methods are called KNXnet/IP routing
and KNXnet/IP tunneling. IP communication in KNX can be explained using the OSI reference
model (Fig. 15). Communication takes place via the application layer (which generates the
KNXnet/IP telegram), the transport layer (UDP), the network layer (IP), and Ethernet – the
physical layer. Like with the TP protocol, additional information for the respective layer (the
header) is always added to the KNXnet/IP information.

Telegram structure
The KNXnet/IP telegram contains some further information in addition to that in the KNX TP
telegram (Fig. 16):
Header Length: The header length is always the same. This information is still sent, however,
because the header length may change in a later version of the protocol. The purpose of the
header is to identify the start of the telegram.
Protocol Version: This indicates what version of the KNXnet/IP protocol applies.
KNXnet/IP Service Type Identifier: The KNXnet/IP Service Type Identifier indicates the action
that is to be carried out.
Total Length: This field indicates the total length of the KNXnet/IP telegram.
KNXnet/IP-Body: This field contains the payload.

2.9 Zigbee:
ZigBee and IEEE 802.15.4 are standards-based protocols that provide the network
infrastructure required for wireless sensor network applications. 802.15.4 defines the physical
and MAC layers, and ZigBee defines the network and application layers.
For sensor network applications, key design requirements revolve around long battery
life, low cost, small footprint, and mesh networking to support communication between large
numbers of devices in an interoperable and multi-application environment.
There are numerous applications that are ideal for the redundant, self-configuring and
self-healing capabilities of ZigBee wireless mesh networks. Key ones include
• Energy Management and Efficiency—To provide greater information and control of energy
usage, provide customers with better service and more choice, better manage resources, and
help to reduce environmental impact.
• Home Automation—To provide more flexible management of lighting, heating and cooling,
security, and home entertainment systems from anywhere in the home.
• Building Automation—To integrate and centralize management of lighting, heating, cooling
and security.
• Industrial Automation—To extend existing manufacturing and process control systems
reliability.
The interoperable nature of ZigBee means that these applications can work together,
providing even greater benefits.

Motivation for ZigBee:


The ZigBee standard was developed to address the following needs:
1. Low cost
2. Secure
3. Reliable and self healing
4. Flexible and extendable
5. Low power consumption
6. Easy and inexpensive to deploy
7. Global with use of unlicensed radio bands
8. Integrated intelligence for network set-up and message routing

ZigBee is the only standards-based technology that addresses the unique needs of most
remote monitoring and control sensory network applications.

About the ZigBee Alliance


The ZigBee Alliance is an association of over 285 companies working together to enable
reliable, cost-effective, low-power, wirelessly networked, monitoring and control products based
on an open global standard. Their focus is on the following:
1. Defining the network, security and application software layers
2. Providing interoperability and conformance testing specifications
3. Promoting the ZigBee brand globally to build market awareness
4. Managing the evolution of the technology

The ZigBee Protocol Stack:


ZigBee sits on top of the IEEE 802.15.4 PHY and MAC layers. Each layer performs a
specific set of services for the layer above. Each service entity provides an interface to the upper
layer through a service access point (SAP).
Application (APL) Layer:
The top layer in the ZigBee protocol stack consists of the Application Framework,
ZigBee Device Object (ZDO), and Application Support (APS) Sublayer.
Ap
plication Framework:
Provides a description of how to build a profile onto the ZigBee stack (to help ensure that
profiles can be generated in a consistent manner). It also specifies a range of standard data types
for profiles, descriptors to assist in service discovery, frame formats for transporting data, and a
key value pair construct to rapidly develop simple attribute-based profiles.

Application Objects:
Software at an endpoint that controls the ZigBee device. A single ZigBee node supports
up to 240 application objects. Each application object supports endpoints numbered between 1
and 240 (with endpoint 0 reserved for the ZigBee Device Object (ZDO)).

ZigBee Device Object (ZDO):


Defines the role of a device within the network (coordinator, router or end device),
initiates and/or responds to binding and discovery requests, and establishes a secure relationship
between network devices. It also provides a rich set of management commands defined in the
ZigBee Device Profile (used in ZigBee commissioning). The ZDO is always endpoint zero.

ZDO Management Plane:


Facilitates communication between the APS and NWK layers with the ZDO. Allows the ZDO to
deal with requests from applications for network access and security using ZDP (ZigBee Device
Profile) messages.

Application Support (APS) Sublayer:


Responsible for providing a data service to the application and ZigBee device profiles. It also
provides a management service to maintain binding links and the storage of the binding table
itself.
Security Service Provider (SSP):
Provides security mechanisms for layers that use encryption (NWK and APS). Initialized
and configured through the ZDO.

Network (NWK) Layer:


Handles network address and routing by invoking actions in the MAC layer. Its tasks include
starting the network (coordinator), assigning network addresses, adding and removing network
devices, routing messages, applying security, and implementing route discovery.

The ZigBee Network:


Device Types
ZigBee networks include the following device types:
1. Coordinators
2. Routers
3. End devices

Coordinator:
This device starts and controls the network. The coordinator stores information about the
network, which includes acting as the Trust Center and being the repository for security keys.

Router:
These devices extend network area coverage, dynamically route around obstacles, and
provide
backup routes in case of network congestion or device failure. They can connect to the
coordinator and other routers, and also support child devices.

End Devices:
These devices can transmit or receive a message, but cannot perform any routing
operations. They must be connected to either the coordinator or a router, and do not support child
devices.

Mesh Network Topology:


Mesh topology, also called peer-to-peer, consists of a mesh of interconnected routers and
end devices. Each router is typically connected through at least two pathways, and can relay
messages for its neighbors.
As shown in the image above, a mesh network contains a single coordinator, and multiple
routers and end devices.
Mesh topology supports “multi-hop” communications, through which data is passed by
hopping from device to device using the most reliable communication links and most cost-
effective path until its destination is reached.
The multi-hop ability also helps to provide fault tolerance, in that if one device fails or
experiences interference, the network can reroute itself using the remaining devices.

Benefits:
1. This topology is highly reliable and robust. Should any individual router become
inaccessible, alternative routes can be discovered and used.
2. The use of intermediary devices in relaying data means that the range of the network can
be significantly increased, making mesh networks highly scalable.
3. Weak signals and dead zones can be eliminated by simply adding more routers to the
network.
2.10 Network layer, APS layer:
Network layer:
Network layer is also known as transmission layer. It acts like a bridge between
perception layer and application layer. It carries and transmits the information collected from the
physical objects through sensors. The medium for the transmission can be wireless or wire based.
It also takes the responsibility for connecting the smart things, network devices and networks to
each other. Therefore, it is highly sensitive to attacks from the side of attackers. It has prominent
security issues regarding integrity and authentication of information that is being transported in
the network.

Common security threats and problems to network layers are:


Denial of Service (DoS) Attack: A DoS attack is an attack to prevent authentic users from
accessing devices or other network resources. It is typically accomplished by flooding the
targeted devices or network resources with redundant requests in an order to make it impossible
or difficult for some or all authentic users to use them .

Main-in-The-Middle (MiTM) Attack: MiTM attack is an attack where the attacker secretly
intercepts and alters the communication between sender and receiver who believe they are
directly communicating with each other. Since an attacker controls the communication, therefore
he or she can change messages according to their needs. It causes a serious threat to online
security because they give the attacker the facility to capture and manipulate information in real
time.

Storage Attack: The information of users is stored on storage devices or the cloud. Both storage
devices and cloud can be attacked by the attacker and user’s information may be changed toin
correct details. The replication of information associated with the access of other information by
different types of people provides more chances for attacks.

Exploit Attack: An exploit is any immoral or illegal attack in a form of software, chunks of data
ora sequence of commands. It takes advantage of security vulnerabilities in an application,
system or hardware. It usually comes with the aim of gaining control of the system and steals
information stored on a network
Application Layer:
Application layer defines all applications that use the IoT technology or in which IoT has
deployed. The applications of IoT can be smart homes, smart cities, smart health, animal
tracking, etc. It has the responsibility to provide the services to the applications. The services
may be varying for each application because services depend on the information that is collected
by sensors.
There are many issues in the application layer in which security is the key issue. In
particular, when IoT is used in order to make a smart home, it introduces many threats and
vulnerabilities from the inside and outside. To implement strong security in an IoT based smart
home, one of the main issues is that the devices used in smart homes have weak computational
power and a low amount of storage such as ZigBee. Common security threats and problem of
application layer are:
Sensors

Cross Site Scripting: It is an injection attack. It enables an attacker to insert a client-side script,
such as java script in a trusted site viewed other users. By doing so, an attacker can completely
change the contents of the application according to his needs and use original information in an
illegal way.

Malicious Code Attack: It is a code in any part of software intended to cause undesired effects
and damage to the system. It is a type of threat that may not be blocked or controlled by the
useof anti-virus tools. It can either activate itself or be like a program requiring a user’s attention
to perform an action.

The ability of dealing with Mass Data: Due to a large number of devices and a massive amount
of data transmission between users, it has no ability to deal with data processing according to the
requirements. As a result, it leads to network disturbance and data loss.
UNIT III IOT PHYSICAL DEVICES AND ENDPOINTS 9
Introduction to Arduino and Raspberry Pi- Installation, Interfaces (serial, SPI, I2C),
Programming –Python program with Raspberry PI with focus on interfacing external gadgets,
controlling output, and reading input from pins.

3.1 Introduction to Arduino and Raspberry Pi:

Arduino is a prototype platform (open-source) based on an easy-to-use hardware and


software. It consists of a circuit board, which can be programed (referred to as a microcontroller)
and a ready-made software called Arduino IDE (Integrated Development Environment), which is
used to write and upload the computer code to the physical board.
The Arduino platform was created back in 2005 by the Arduino company and allows for
open source prototyping and flexible software development and back-end deployment while
providing significant ease of use to developers, even those with very little experience building
IoT solutions. Arduino is sensible to literally every environment by receiving source data from
different external sensors and is capable to interact with other control elements over various
devices, engines and drives.
Arduino has a built-in micro controller that operates on the Arduino software. Projects
based on this platform can be both standalone and collaborative, i.e. realized with use of external
tools and plugins. The integrated development environment (IDE) is composed of the open
source code and works equally good with Мac, Linux and Windows OS. Based on a processing
programming language, the Arduino platform seems to be created for new users and for
experiments.
The processing language is dedicated to visualizing and building interactive apps using
animation and Java Virtual Machine (JVM) platform. Let's note that this programming language
was developed for the purpose of learning basic computer programming in a visual context. It is
an absolutely free project available to every interested person. Normally, all the apps are
programmed in C/C++, and are wrapped with avr-gcc (WinAVR in OS Windows).
Arduino offers analogue-to-digital input with a possibility of connecting light,
temperature or sound sensor modules. Such sensors as SPI or I2C may also be used to cover up
to 99% of these apps’ market. Arduino is a microcontroller (generally it is the 8-bit ATmega
microcontroller), but not a mini-computer, which makes Arduino somehow limited in its features
for advanced users. Arduino provides an excellent interactivity with external devices and offers a
wide range of user manuals, project samples as well as a large community of users to learn
from / share knowledge with.

The key features are −


• Arduino boards are able to read analog or digital input signals from different
sensors and turn it into an output such as activating a motor, turning LED on/off,
connect to the cloud and many other actions.
• You can control your board functions by sending a set of instructions to the
microcontroller on the board via Arduino IDE (referred to as uploading software).
• Unlike most previous programmable circuit boards, Arduino does not need an
extra piece of hardware (called a programmer) in order to load a new code onto
the board. You can simply use a USB cable.
• Additionally, the Arduino IDE uses a simplified version of C++, making it easier
to learn to program.
• Finally, Arduino provides a standard form factor that breaks the functions of the
micro-controller into a more accessible package.
Board Types
Various kinds of Arduino boards are available depending on different microcontrollers
used. However, all Arduino boards have one thing in common: they are programed through the
Arduino IDE.
The differences are based on the number of inputs and outputs (the number of sensors,
LEDs, and buttons you can use on a single board), speed, operating voltage, form factor etc.
Some boards are designed to be embedded and have no programming interface (hardware),
which you would need to buy separately. Some can run directly from a 3.7V battery, others need
at least 5V.

Here is a list of different Arduino boards available.


First we must have our Arduino board (can choose your favorite board) and a USB cable.
In case you use Arduino UNO, Arduino Duemilanove, Nano, Arduino Mega 2560, or Diecimila,
you will need a standard USB cable (A plug to B plug), the kind you would connect to a USB
printer as shown in the following image.

In case we use Arduino Nano, we will need an A to Mini-B cable instead as shown in the
following image.

Download Arduino IDE Software:


You can get different versions of Arduino IDE from the Download page on the Arduino
Official website. You must select your software, which is compatible with your operating system
(Windows, IOS, or Linux). After your file download is complete, unzip the file.

Launch Arduino IDE:


After your Arduino IDE software is downloaded, you need to unzip the folder. Inside the
folder, you can find the application icon with an infinity label (application.exe). Double-click the
icon to start the IDE.
Open your first project:
Once the software starts, we have two options −
o Create a new project.
o Open an existing project example.

To create a new project, select File → New.

To open an existing project example, select File → Example → Basics → Blink.


Select your Arduino board.
To avoid any error while uploading your program to the board, you must select the
correct Arduino board name, which matches with the board connected to your computer.
Go to Tools → Board and select your board.

Here, we have selected Arduino Uno board according to our tutorial, but you must select
the name matching the board that you are using.

Select your serial port:


Select the serial device of the Arduino board. Go to Tools → Serial Port menu. This is
likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports).
To find out, you can disconnect your Arduino board and re-open the menu, the entry that
disappears should be of the Arduino board. Reconnect the board and select that serial port.

Upload the program to your board:


Before explaining how we can upload our program to the board, we must demonstrate the
function of each symbol appearing in the Arduino IDE toolbar.
A − Used to check if there is any compilation error.
B − Used to upload a program to the Arduino board.
C − Shortcut used to create a new sketch.
D − Used to directly open one of the example sketch.
E − Used to save your sketch.
F − Serial monitor used to receive serial data from the board and send the serial data to
the board.
Now, simply click the "Upload" button in the environment. Wait a few seconds; you will see the
RX and TX LEDs on the board, flashing. If the upload is successful, the message "Done
uploading" will appear in the status bar.

Raspberry Pi
Raspberry Pi (/paɪ/) is a series of small single-board computers developed in the United
Kingdom by the Raspberry Pi Foundation in association with Broadcom. Early on, the Raspberry
Pi project leaned towards the promotion of teaching basic computer science in schools and in
developing countries. Later, the original model became far more popular than anticipated,selling
outside its target market for uses such as robotics.
It is now widely used in many areas, such as for weather monitoring, because of its low
cost, modularity, and open design. After the release of the second board type, the Raspberry Pi
Foundation set up a new entity, named Raspberry Pi Trading, and installed Eben Upton as CEO,
with the responsibility of developing technology.
The Foundation was rededicated as an educational charity for promoting the teaching of
basic computer science in schools and developing countries. The Raspberry Pi is one of the best-
selling British computers. The Raspberry Pi hardware has evolved through several versions that
feature variations in the type of the central processing unit, amount of memory capacity,
networking support, and peripheral-device support.
This block diagram describes Model B and B+; Model A, A+, and the Pi Zero are similar,
but lack the Ethernet and USB hub components. The Ethernet adapter is internally connected to
an additional USB port. In Model A, A+, and the Pi Zero, the USB port is connected directly to
the system on a chip (SoC). On the Pi 1 Model B+ and later models the USB/Ethernet chip
contains a five-port USB hub, of which four ports are available, while the Pi 1 Model B only
provides two.
On the Pi Zero, the USB port is also connected directly to the SoC, but it uses a micro
USB (OTG) port. Unlike all other Pi models, the 40 pin GPIO connector is omitted on the Pi
Zero, with solderable through-holes only in the pin locations. The Pi Zero WH remedies this.
Processor speed ranges from 700 MHz to 1.4 GHz for the Pi 3 Model B+ or 1.5 GHz for the Pi 4;
on-board memory ranges from 256 MiB to 1 GiB random-access memory (RAM), with up to 8
GiB available on the Pi 4. Secure Digital (SD) cards in MicroSDHC form factor (SDHC on early
models) are used to store the operating system and program memory.
The boards have one to five USB ports. For video output, HDMI and composite video are
supported, with a standard 3.5 mm tip-ring-sleeve jack for audio output. Lower-level output is
provided by a number of GPIO pins, which support common protocols like I²C. The B-models
have an 8P8C Ethernet port and the Pi 3, Pi 4 and Pi Zero W have on-board Wi-Fi 802.11n and
Bluetooth.
Raspberry Pi is a mono-board computing platform that's as tiny as a credit card. Initially
it was developed for computer science education with later on progress to wider functions. Since
the inception of Raspberry, the company sold out more than 8 million items. Raspberry Pi 3 is
the latest version and it is the first 64-bit computing board that also comes with built-in Wi-Fi
and Bluetooth functions.
According to Raspberry Pi Foundation CEO Eben Upton, "it's been a year in the
making". The Pi3 version is replaced with a quad-core 64-bit 1.2 GHz ARM Cortex A53 chip,
1GB of RAM, VideoCore IV graphics, Bluetooth 4.1 and 802.11n Wi-Fi. The developers claim
the new architecture delivers an average 50% performance improvement over the Pi 2. Another
peculiarity of Raspberry Pi is the GPIO (General Purpose Input-Output), which is a low-level
interface of self-operated control by input-output ports.
Raspberry has it as a 40-pin connector. Raspberry Pi uses Linux as its default operating
system (OS). It’s also fully Android compatible. Using the system on Windows OS is enabled
through any virtualization system like XenDesktop. If you want to develop an application for
Raspberry Pi on your computer, it is necessary to download a specific toolset comprised of
ARM-compiler and some libraries complied down to ARM-target platform like glibc.

3.2 Raspberry Pi- Installation


There are a number of different Raspberry Pi distributions. You are not sure which one to
use. The answer to this question depends on what you intend to do with your Raspberry Pi. If
you plan to build hardware projects with the Raspberry Pi, then use Raspbian or Occidentalis
(from Adafruit). Of these, Raspbian is the official and most commonly used distribution for
Raspberry Pi, but Occidentalis requires less setup to start hacking hardware.
If you plan to use your Raspberry Pi as a media center, there are a number of distributions
specifically for that purpose. We use the Raspbian distribution. SD cards—especially a 4 GB SD
card, which is recommended for most distributions— are not expensive, so get a few and try out
a few distributions. If you do this, it is a good idea to keep your own files on a USB flash drive
so that you don’t have to keep copying them onto each SD card.

Writing an SD Card with NOOBS:


Download the NOOBS archive file from http://www.raspberrypi.org/downloads, extract
it, and place it on an SD card. Once you have downloaded the NOOBS archive file, extract it and
copy the folder contents onto the SD card. Note that if the archive extracts to a folder called
NOOBS_v1_2_1 or similar, it is the contents of the folder that should be copied to the root of the
SD card, not the folder itself.
Put the SD card containing the extracted NOOBS files into your Raspberry Pi and then
power up your Raspberry Pi. When it boots, the window shown in below Figure will appear.
From this screen, you can select which distribution you want to install. Raspbian will be selected
as the default, and this is the best choice to start off with.

You will get a warning message that the SD card will be overwritten (which is fine) and
then as the distribution is installed onto the SD card, you will see a progress screen accompanied
by helpful information about the distribution.
Once the file copying is complete, you will get the message Image applied successfully.
When you hit return, the Raspberry Pi will reboot and then raspi_config will automatically run so
that you can configure the new installation.
For NOOBS to install correctly onto an SD crd, the card must be formatted as FAT. Most
SD cards are supplied already formatted in FAT. If you are reusing an old card and need to
format it as FAT, then use your operating system’s tool for formatting removeable media.
Alternatively, the Raspberry Pi foundation recommends the SD Association’s formatting
tool, which is available for Mac and Windows.

3.3 Interfaces (serial, SPI, I2C):


Serial Communication basics:
Communication between electronic devices is like communication between humans. Both
sides need to speak the same language. In electronics, these languages are called communication
protocols. Luckily for us, there are only a few communication protocols (SPI,I2C,UART,USB)
we need to know when building most electronics projects.
SPI, I2C, and UART are quite a bit slower than protocols like USB, Ethernet, Bluetooth,
and Wi-Fi, but they’re a lot simpler and use less hardware and system resources. SPI, I2C, and
UART are ideal for communication between microcontrollers and between microcontrollers and
sensors where large amounts of high speed data don’t need to be transferred.

DATA COMMUNICATION TYPES:


(1) PARALLEL
(2) SERIAL:
(I) ASYNCHRONOUS
(II) SYNCHRONOUS

Parallel Communication:
• In parallel communication, all the bits of data are transmitted simultaneously on separate
communication lines.
• Used for shorter distance.
• In order to transmit n bit, n wires or lines are used.
• More costly.
• Faster than serial transmission.
• Data can be transmitted in less time.
Example: printers and hard disk

Serial Communication:
• In serial communication the data bits are transmitted serially one by one i.e. bit by bit on single
communication line
• It requires only one communication line rather than n lines to transmit data from sender to
receiver.
• Thus all the bits of data are transmitted on single lines in serial fashion.
• Less costly.
• Long distance transmission.
Example: Telephone.

Serial communication uses two methods:


• Asynchronous.
• Synchronous.
Asynchronous:
• transfers single byte at a time
• No need of clock signal
Example: UART (universal asynchronous receiver transmitter)

Synchronous:
• Transfers a block of data (characters) at a time.
• Requires clock signal
Example:
• SPI (serial peripheral interface),
• I2C (inter integrated circuit).

Serial Peripheral Interface (SPI)


It is similar to I2C and it is a different form of serial-communications protocol specially
designed for microcontrollers to connect.
Operates at full-duplex where data can be sent and received simultaneously.
Operate at faster data transmission rates = 8Mbits or more
It is typically faster than I2C due to the simple protocol. Even if data/clock lines are
shared between devices, each device will require a unique address wire.
Used in places where speed is important. (eg. SD cards, display modules or when info
updates and changes quickly like thermometers)

Working:
Communicate with 2 ways:
Selecting each device with a Chip Select line. A separate Chip Select line is required for
each device. This is the most common way RPi’s currently use SPI.
Daisy chaining where each device is connected to the other through its data out to the
data in line of the next.
There is no limit to the number of SPI device that can be connected. However, there are
practical limits due to the number of hardware select lines available on the main device with the
chip select method or the complexity of passing data through devices in the daisy-chaining
method.
In point-to-point communication, the SPI interface does not require addressing operations
and is full-duplex communication, which is simple and efficient.

SPI Protocol
The SPI communicates via 4 ports which are:
• MOSI – Master Data Output, Slave Data Input
• MISO – master data input, slave data output
• SCLK – clock signal, generated by the master device, up to fPCLK/2, slave mode
frequency up to fCPU/2
• NSS – Slave enabled signal, controlled by the master device, some ICs will be
labelled as CS (Chip select)
In a multi-slave system, each slave requires a separate enable signal, which is slightly
more complicated on hardware than the I2C system.
The SPI interface is actually two simple shift registers in the internal hardware. The
transmitted data is 8 bits. It is transmitted bit by bit under the slave enable signal and shift pulse
generated by the master device. The high bit is in the front and the low bit is in the back.
The SPI interface is synchronous serial data transmission between the CPU and the
peripheral low-speed device. Under the shift pulse of the master device, the data is transmitted
bit by bit.
The high bit is in the front and the low bit is in the back. It is full-duplex communication,
and the data transmission speed is overall faster than the I2C bus and can reach speeds of a few
Mbps.
Advantages of using SPI
The protocol is simple as there is no complicated slave addressing system like I2C.
It is the fastest protocol compared to UART and I2C.
No start and stop bits unlike UART which means data can be transmitted continuously
without interruption
Separate MISO and MOSI lines which means data can be transmitted and received at the
same time
Disadvantages of using SPI
More Pin ports are occupied, the practical limit to a number of devices.
There is no flow control specified, and no acknowledgement mechanism confirms whether data
is received unlike I2C
Uses four lines – MOSI, MISO, NCLK, NSS
No form of error check unlike in UART (using parity bit)
Only 1 master

I2C Interface
Stands for Inter-integrated-circuit (I2C). It is a serial communications protocol similarly
to UART. However, it is not used for PC-device communication but instead with modules and
sensors. It is a simple, bidirectional two-wire synchronous serial bus and requires only two wires
to transmit information between devices connected to the bus.
They are useful for projects that require many different parts (eg. sensors, pin, expansions
and drivers) working together as they can connect up to 128 devices to the mainboard while
maintaining a clear communication pathway!
This is because I2C uses an address system and a shared bus = many different devices
can be connected using the same wires and all data are transmitted on a single wire and have a
low pin count. However, the tradeoff for this simplified wiring is that it is slower than SPI.
Speed of I2C is also dependent by data speed, wire quality and external noise. The I2C
protocol is also used as a two-wire interface to connect low-speed devices like microcontrollers,
EEPROMs, A/D and D/A converters, I/O interfaces and other similar peripherals in embedded
systems.

Working:
It has 2 Lines which are SCL (serial clock line) and SDA (serial data line acceptance
port) CL is the clock line for synchronizing transmission. SDA is the data line through which bits
of data are sent or received.
The master device initiates the bus transfer of data and generates a clock to open the
transferred device and any addressed device is considered a slave device. The relationship
between master and slave devices, transmitting and receiving on the bus is not constant. It
depends on the direction of data transfer at the time.
If the master wants to send data to the slave, the master must first address the slave before
sending any data. The master will then terminate the data transfer. If the master wants to receive
data from the slave, the master must again address the slave first.
The host then receives the data sent by the slave and finally, the receiver terminates the
receiving process. The host is also responsible for generating the timing clock and terminating
the data transfer.
It is also necessary to connect the power supply through a pull-up resistor. When the bus
is idle, both lines operate on a high power level. The capacitance in the line will affect the bus
transmission speed. As the current power on the bus is small, when the capacitance is too large, it
may cause transmission errors. Thus, its load capacity must be 400pF, so the allowable length of
the bus and the number of connected devices can be estimated.

I2C Protocol
Data Transmission Method
The master sends the transmitting signal to every connected slave by switching the SDA
line from a high voltage level to a low voltage level and SCL line from high to low after
switching the SDA line.
The master sends each slave the 7 or 10-bit address of the slave and a read/write bit to the
slave it wants to communicate with.
The slave will then compare the address with its own. If the address matches, the slave
returns an ACK bit which switches the SDA line low for one bit. If the address does not match
its address, the slave leaves the SDA line high.
The master will then send or receive the data frame. After each data frame has been
transferred, the receiving device returns another ACK bit to the sender to acknowledge
successful transmission.
To stop the data transmission, the master sends a stop signal to the slave by switching
SCL high before switching SDA high

Clock Synchronisation
All masters generate their own clocks on the SCL line to transmit messages on the I2C
bus. Data is only valid during the high period of the clock. Clock synchronization is performed
by connecting the I2C interface to the SCL line where the switch goes from high to low. Once
the device’s clock goes low, it keeps the SCL line in this state until it reaches the high level of
the clock.
If another clock is still in a low period, the low-to-high switch does not change the state
of the SCL line. The SCL line is always held low by the device with the longest low period. At
this time, the device with a short and low period will enter a high and waiting state.
When all relevant devices have completed their low period, the clock line goes high.
After that, there is no difference in the state of the device clock and the SCL line, and all devices
begin to count their high period. The device that first completes the high period will pull the SCL
line low again.
The low period of the synchronous SCL clock is determined by the device with the
longest low clock period, while the high period is determined by the device with the shortest
high clock period.

Transmission Modes
Quick Mode:
Fast mode devices can receive and transmit at 400kbit/s. They have to be able to
synchronize with a 400kbit/s transmission and extend the low period of the SCL signal to slow
down the transmission.
Fast mode devices are backwards compatible and can communicate with standard mode
devices from 0 to 100 kbit/s I2C bus systems. However, as standard mode devices are not
upward compatible, they cannot operate in a fast I2C bus system. The fast mode I2C bus
specification has the following characteristics compared to the standard mode:
1. The maximum bit rate is increased to 400 kbit/s
2. Adjusted the timing of the serial data (SDA) and serial clock (SCL) signals.
3. Has the function of suppressing glitch and the SDA and SCL inputs have Schmitt
triggers.
4. The output buffer has a slope control function for the falling edges of the SDA and SCL
signals. Once the power supply of the fast mode device is turned off, the I/O pins of SDA
and SCL must be left idle and cannot block the bus.
5. The external pull-up device connected to the bus must be tuned to accommodate the
shortest maximum allowable rise time of the fast mode I2C bus. For buses with a
maximum load of 200pF, the pull-up device of each bus can be a resistor. For a bus with
a load between 200pF and 400pF, the pull-up device can be a current source (maximum
3mA) or a switched resistor circuit.

High-Speed Mode:
Hs mode devices can transmit information at bit rates up to 3.4 Mbit/s and remain fully
backwards compatible with fast mode or standard mode (F/S mode) devices that can
communicate bi-directionally in a speed mixed bus system.
The Hs mode transmission has the same serial bus principle and data format as the F/S
mode system except for arbitration and clock synchronization which is not performed.
The I2C bus specification in high-speed mode is as follows:
1. In high speed (Hs) mode, the master device has an open-drain output buffer for
the high-speed (SDAH) signal and an open-drain pull-down and current source
pull-up circuit at the high-speed serial clock (SCLH) output. This shortens the rise
time of the SCLH signal and at any time, only one host current source is active;
2. In the Hs mode of a multi-master system, arbitration and clock synchronization
are not performed in order to speed up the bit processing capability. The
arbitration process normally ends after the host code is transmitted in the F/S
mode.
3. The Hs mode master device generates a high and low serial clock signal with a
ratio of 1:2 which removes the timing requirements for setup and hold time.
4. The Hs mode device can have a built-in bridge. During Hs mode transmission, the
SDAH and SCLH lines of the Hs mode device are separated from the SDA and
SCL lines which reduces the capacitive loading of the SDAH and SCLH lines and
make rise and fall faster.
5. The difference between Hs mode slave devices and F/S slave devices is the speed
at which they operate.
6. The Hs mode device can suppress glitches, and the SDAH and SCLH outputs also
have a Schmitt trigger;
7. The output buffer of the Hs mode device has a slope control function for the
falling edges of the SDAH and SCLH signals.

Advantages of using I2C


1. Has a low pin/signal count even with numerous devices on the bus
2. Flexible, as it supports multi-master and multi slave communication.
3. Simple as it only uses 2 bidirectional wires to establish communication among multiple
devices.
4. Adaptable as it can adapt to the needs of various slave devices.
5. Support multiple masters.

Disadvantages of using I2C


1. Slower speed as it requires pull-up resistors rather than push-pull resistors used by SPI. It
also has an open-drain design = limited speed.
2. Requires more space as the resistors consume valuable PCB real estate.
3. May become complex as the number of devices increases.
3.4 Programming –Python program with Raspberry PI with focus on interfacing
external gadgets, controlling output, and reading input from pins:

The common Raspberry Pi distributions come with the IDLE Python development tool in both
the Python and Python 3 versions. IDLE and IDLE 3 appear identical; the only difference is the
version of Python that they use, so open IDLE 3.

The window that opens is labeled Python Shell. This is an interactive area where you can
type Python and see the results immediately. So try typing the following into the shell next to the
>>> prompt:
>>> 2 + 2
4
>>>
Python has evaluated the expression 2 + 2 and given us the answer of 4.
The Python Shell is fine for trying things out, but if you want to write programs, then you
need to use an editor. To open a new file to edit using IDLE, select New Window from the File
menu.
You can now enter your program into the editor window. Just to try things, paste the
following text into the editor, save the file as count.py, and then select Run Module from the Run
menu. You can see the results of the program running in the Python console:
for i in range(1, 10):
print(i)
Python is unusual for a programming language in that indentation is a fundamental part
of the language. Whereas many C-based languages use { and } to delimit a block of code, Python
uses the indentation level. So, in the preceding example, Python knows that print is to be invoked
repeatedly as part of the for loop because it is indented out four spaces.

Displaying Output:
>>> x = 10
>>> print(x)
10
>>>

Use the print command or print function to display output in the console.

Reading User Input:

>>> x = input("Enter Value:")


Enter Value:23
>>> print(x)
23
>>>

Python also has an input function, but this validates the input and attempts to convert it
into a Python value of the appropriate type, whereas raw_input does the same thing as input in
and just returns a string.

Arithmetic:
The most common operators for arithmetic are +, -, *, and /, which are, respectively, add,
subtract, multiply, and divide. You can also group parts of the expression together with
parentheses, as shown in the following example, which, given a temperature in degrees Celsius,
converts it to degrees Fahrenheit:

>>> tempC = input("Enter temp in C: ")


Enter temp in C: 20
>>> tempF = (int(tempC) * 9) / 5 + 32
>>> print(tempF)
68.0
>>>

Installing RPi.GPIO
A GPIO general-purpose input/output connector pin can be used as either a digital input
or a digital output, and both operate at 3.3V. Unlike the Arduino, the Raspberry Pi does not have
any analog inputs. For that you must use an external analog-to-digital converter (ADC) or
connect the Pi to an interface board (like the Gertboard) or to an Arduino or an aLaMode board.
Download and install the RPi.GPIO Python library. From a Terminal window on your Pi,
type the following commands to fetch and install the RPi.GPIO library.
$ sudo apt-get install python-dev
$ sudo apt-get install python-rpi.gpio

Writing in GPIO output:


Connect an LED (see “Opto-Electronics” on page 381) to one of the GPIO pins using a
470Ω or 1kΩ series resistor (see “Resistors and Capacitors” on page 380) to limit the current. To
make this recipe, you will need:
• Breadboard and jumper wires
• 1kΩ resistor
• LED

import RPi.GPIO as GPIO


import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
while (True):
GPIO.output(18, True)
time.sleep(0.5)
GPIO.output(18, False)
time.sleep(0.5)

Run the program using following command:


$ sudo python led_blink.py

Controlling the Brightness of an LED:

import RPi.GPIO as GPIO


led_pin = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(led_pin, GPIO.OUT)
pwm_led = GPIO.PWM(led_pin, 500)
pwm_led.start(100)
while True:
duty_s = raw_input("Enter Brightness (0 to 100):")
duty = int(duty_s)
pwm_led.ChangeDutyCycle(duty)

Run the Python program, and you will be able to change the brightness by entering a number
between 0 and 100:
pi@raspberrypi ~ $ sudo python led_brightness.py
Enter Brightness (0 to 100):0
Enter Brightness (0 to 100):20
Enter Brightness (0 to 100):10
Enter Brightness (0 to 100):5
Enter Brightness (0 to 100):1
Enter Brightness (0 to 100):90
You can exit the program by pressing Ctrl-C.

Using Resistive Sensors:


You can measure resistance on a Raspberry Pi using nothing more than a capacitor, a
couple of resistors, and two GPIO pins.
• Breadboard and jumper wires
• 10kΩ trimpot
• Two 1kΩ resistors
• 220 nF capacitor

import RPi.GPIO as GPIO


import time
GPIO.setmode(GPIO.BCM)
a_pin = 18
b_pin = 23

def discharge():
GPIO.setup(a_pin, GPIO.IN)
GPIO.setup(b_pin, GPIO.OUT)
GPIO.output(b_pin, False)
time.sleep(0.005)
def charge_time():
GPIO.setup(b_pin, GPIO.IN)
GPIO.setup(a_pin, GPIO.OUT)
count = 0
GPIO.output(a_pin, True)
while not GPIO.input(b_pin):
count = count + 1
return count

def analog_read():
discharge()
return charge_time()

while True:
print(analog_read())
time.sleep(1)

Run the program using below command :


$ sudo python pot_step.py
10
12
10
10
16
23
43
53
67
72
86
105
123
143
170

The reading will vary between about 10 and about 170 as you rotate the knob of the
trimpot.

You might also like