IoT Notes
IoT Notes
ON
INTERNET OF THINGS
MALLA REDDY
INSTITUTE OF ENGINEEING & TECHNOLOGY
Definition:
A dynamic global n/w 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 information n/w, often communicate data associated with users and their
environments.
Characteristics:
1) Dynamic & Self Adapting: IoT devices and systems may have the capability to
dynamically adapt with the changing contexts and take actions based on their operating
conditions, user‘s context or sensed environment.
Eg: the surveillance system is adapting itself based on context and changing conditions.
2) Self Configuring: allowing a large number of devices to work together to provide certain
functionality.
3) Inter Operable Communication Protocols: support a number of interoperable
communication protocols ans can communicate with other devices and also with
infrastructure.
4) Unique Identity: Each IoT device has a unique identity and a unique identifier
(IPaddress).
5) Integrated into Information Network: that allow them to communicate and exchange
data with other devices and systems.
Applications of IoT:
1) Home
2) Cities
3) Environment
4) Energy
5) Retail
6) Logistics
7) Agriculture
8) Industry
9) Health & LifeStyle
Protocols:
IPv4: Internet Protocol version4 is used to identify the devices on a n/w using a
hierarchical addressing scheme. 32 bit address. Allows total of 2**32addresses.
IPv6: Internet Protocol version6 uses 128 bit address scheme and allows 2**128
addresses.
1) IoT Functional Blocks: Provide the system the capabilities for identification,
sensing, actuation, communication andmanagement.
2) IoT CommunicationModels:
1) Request-ResponseModel:
2) Publish-SubscibeModel:
Involves publishers, brokers and consumers. Publishers are source of data. Publishers send data
to the topics which are managed by the broker. Publishers are not aware of the consumers.
Consumers subscribe to the topics which are managed by the broker. When the broker receives
data for a topic from the publisher, it sends the data to all the subscribedconsumers.
3) Push-Pull Model: in which data producers push data to queues and consumers pull
data from the queues. Producers do not need to aware of the consumers. Queues help in
decoupling the message between the producers andconsumers.
3) IoT CommunicationAPIs:
a) REST based communication APIs(Request-Response BasedModel)
b) WebSocket based Communication APIs(Exclusive PairBasedModel)
a) REST based communication APIs: Representational State Transfer(REST) is a set of
architectural principles by which we can design web services and web APIs that focus on a
system‘s resources and have resource states are addressed andtransferred.
The REST architectural constraints: Fig. shows communication between client server with
REST APIs.
4) Communication Protocols: form the back-bone of IoT systems and enable network
connectivity and coupling toapplications.
Allow devices to exchange data overnetwork.
Define the exchange formats, data encoding addressing schemes for device and
routing of packets from source todestination.
It includes sequence control, flow control and retransmission of lostpackets.
5) Embedded Systems: is a computer system that has computer hardware and software
embedded to perform specific tasks. Embedded System range from low cost miniaturized
devices such as digital watches to devices such as digital cameras, POS terminals,
vending machines, appliancesetc.,
3) IoT Level3: system has a single node. Data is stored and analyzed in the cloud
application is cloud based as shown in fig. Level3 IoT systems are suitable for solutions
where the data involved is big and analysis requirements are computationally intensive.
An example of IoT level3 system for tracking packagehandling.
5) IoT Level5: System has multiple end nodes and one coordinator node as shown in fig.
The end nodes that perform sensing and/or actuation. Coordinator node collects data from
theendnodesandsendstothecloud.Dataisstoredandanalyzedinthecloudand
6) IoT Level6: System has multiple independent end nodes that perform sensing and/or
actuation and sensed data to the cloud. Data is stored in the cloud and application is cloud
based as shown in fig. The analytics component analyses the data and stores the result in
the cloud data base. The results are visualized with cloud based application. The
centralized controller is aware of the status of all the end nodes and sends control
commands to nodes. An example of a Level6 IoT system for Weather Monitoring
System.
2) Cities:
a) Smart Parking: make the search for parking space easier and convenient for drivers.
Smart parking are powered by IoT systems that detect the no. of empty parking slots
and send information over internet to smart application backends.
b) Smart Lighting: for roads, parks and buildings can help in savingenergy.
c) Smart Roads: Equipped with sensors can provide information on driving condition,
travel time estimating and alert in case of poor driving conditions, traffic condition
andaccidents.
d) Structural Health Monitoring: uses a network of sensors to monitor the vibration
levels in the structures such as bridges and buildings.
e) Surveillance: The video feeds from surveillance cameras can be aggregated in cloud
based scalable storagesolution.
3) Environment:
a) Weather Monitoring: Systems collect data from a no. of sensors attached and send
the data to cloud based applications and storage back ends. The data collected in
cloud can then be analyzed and visualized by cloud basedapplications.
b) Air Pollution Monitoring: System can monitor emission of harmful gases(CO2, CO,
NO, NO2 etc.,) by factories and automobiles using gaseous and meteorological
sensors. The collected data can be analyzed to make informed decisions on pollutions
controlapproaches.
c) Noise Pollution Monitoring: Due to growing urban development, noise levels in
cities have increased and even become alarmingly high in some cities. IoT based
noise pollution monitoring systems use a no. of noise monitoring systems that are
deployed at different places in a city. The data on noise levels from the station is
collected on servers or in the cloud. The collected data is then aggregated to generate
noise maps.
d) Forest Fire Detection: Forest fire can cause damage to natural resources, property
and human life. Early detection of forest fire can help in minimizingdamage.
e) River Flood Detection: River floods can cause damage to natural and human
resources and human life. Early warnings of floods can be given by monitoring the
water level and flow rate. IoT based river flood monitoring system uses a no. of
sensor nodes that monitor the water level and flow ratesensors.
4) Energy:
a) Smart Grids: is a data communication network integrated with the electrical grids
that collects and analyze data captured in near-real-time about power transmission,
distribution and consumption. Smart grid technology provides predictive information
and recommendations to utilities, their suppliers, and their customers on how best to
manage power. By using IoT based sensing and measurement technologies, the health
of equipment and integrity of the grid can beevaluated.
b) Renewable Energy Systems: IoT based systems integrated with the transformers at
the point of interconnection measure the electrical variables and how much power is
fed into the grid. For wind energy systems, closed-loop controls can be used to
regulate the voltage at point of interconnection which coordinate wind turbine outputs
and provides powersupport.
c) Prognostics: In systems such as power grids, real-time information is collected using
specialized electrical sensors called Phasor Measurment Units(PMUs) at the
substations. The information received from PMUs must be monitored in real-time for
estimating the state of the system and for predictingfailures.
5) Retail:
a) Inventory Management: IoT systems enable remote monitoring of inventory using
data collected by RFIDreaders.
6) Logistics:
a) Route generation & scheduling: IoT based system backed by cloud can provide first
response to the route generation queries and can be scaled upto serve a large
transportationnetwork.
b) Fleet Tracking: Use GPS to track locations of vehicles inreal-time.
c) Shipment Monitoring: IoT based shipment monitoring systems use sensors such as
temp, humidity, to monitor the conditions and send data to cloud, where it can be
analyzed to detect foodspoilage.
d) Remote Vehicle Diagnostics: Systems use on-board IoT devices for collecting data
on Vehicle operaions(speed, RPMetc.,) and status of various vehicle subsystems.
7) Agriculture:
a) Smart Irrigation: to detemine moisture amount insoil.
b) Green House Control: to improveproductivity.
8) Industry:
a) Machine diagnosis andprognosis
b) Indoor Air QualityMonitoring
An M2M area network comprises of machines( or M2M nodes) whiach have embedded
network modules for sensing, actuation and communicating various communiction
protocols can be used for M2M LAN such as ZigBee, Bluetooth, M-bus, Wireless M-Bus
etc., These protocols provide connectivity between M2M nodes within an M2M area
network.
The communication network provides connectivity to remote M2M area networks. The
communication network provides connectivity to remote M2M area network. The
communication networkcan use either wired or wireless network(IP based). While the
M2M are networks use either properietorary or non-IP baed communication protocols,
the communication network uses IP-based network. Since non-IP based protocols are
used within M2M area network, the M2M nodes within one network cannot
communicate with nodes in an externalnetwork.
To enable the communication between remote M2M are network, M2M gateways are
used.
5) Applications
1) Centralized NetworkController
With decoupled control and data planes and centralized network controller, the
network administrators can rapidly configure the network.
2) Programmable OpenAPIs
SDN architecture supports programmable open APIs for interface between the
SDN application and control layers (Northbound interface).
2) NFV Infrastructure(NFVI):
NFVI includes compute, network and storage resources that are virtualized.
• Introduction to Python
• Installing Python
• Python Data Types & Data Structures
• Control Flow
• Functions
• Modules
• Packages
• File Input/Output
• Date/Time Operations
• Classes
INTERNET OF THINGS Page 28
Python
• Python is a general-purpose high level programming language and suitable for providing a solid
foundation to the reader in the area of cloud computing.
• Windows
• Python binaries for Windows can be downloaded from http://www.python.org/getit .
• For the examples and exercise in this book, you would require Python 2.7 which can be directly downloaded from:
http://www.python.org/ftp/python/2.7.5/python-2.7.5.msi
• Once the python binary is installed you can run the python shell at the command prompt using
> python
• Linux
#Install Dependencies
sudo apt-get install build-essential
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
#Download Python
wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tgz
tar -xvf Python-2.7.5.tgz
cd Python-2.7.5
#Install Python
./configure
make
INTERNET OF THINGS Page 32
sudo make install
Numbers
• Numbers
• Number data type is used to store numeric values. Numbers are immutable data types, therefore changing the value of a number data
type results in a newly allocated object.
#Integer #Addition #Division
>>>a=5 >>>c=a+b >>>f=b/a
>>>type(a) >>>c >>>f
<type ’int’> 7.5 0.5
>>>type(c) >>>type(f)
#Floating Point <type ’float’> <type float’>
>>>b=2.5
>>>type(b) #Subtraction #Power
<type ’float’> >>>d=a-b >>>g=a**2
>>>d >>>g
#Long 2.5 25
>>>x=9898878787676L >>>type(d)
>>>type(x) <type ’float’>
<type ’long’>
#Multiplication
#Complex >>>e=a*b
>>>y=2+5j >>>e
>>>y 12.5
(2+5j) >>>type(e)
>>>type(y) <type ’float’>
<type ’complex’>
>>>y.real
• Strings
• A string is simply a list of characters in order. There are no limits to the number of characters you can have in a string.
#Create string #Print string #strip: Returns a copy of the string with the
>>>s="Hello World!" >>>print s #leading and trailing characters removed.
>>>type(s) Hello World!
<type ’str’> >>>s.strip("!")
#Formatting output ’Hello World’
#String concatenation >>>print "The string (The string (Hello World!)
>>>t="This is sample program." has 12 characters
>>>r = s+t
>>>r #Convert to upper/lower case
’Hello World!This is sample program.’ >>>s.upper()
’HELLO WORLD!’
#Get length of string >>>s.lower()
>>>len(s) ’hello world!’
12
#Accessing sub-strings
#Convert string to integer >>>s[0]
>>>x="100" ’H’
>>>type(s) >>>s[6:]
<type ’str’> ’World!’
>>>y=int(x) >>>s[6:-1]
>>>y ’World’
100
• Tuples
• A tuple is a sequence data type that is similar to the list. A tuple consists of a number of values separated by commas and enclosed
within parentheses. Unlike lists, the elements of tuples cannot be changed, so tuples can be thought of as read-only lists.
• Dictionaries
• Dictionary is a mapping data type or a kind of hash table that maps keys to values. Keys in a dictionary can be of any data type, though
numbers and strings are commonly used for keys. Values in a dictionary can be any data type or object.
#Create a dictionary #Get all keys in a dictionary #Check if dictionary has a key
>>>student={’name’:’Mary’,’id’:’8776’,’major’:’CS’} >>>student.keys() >>>student.has_key(’name’)
>>>student [’gender’, ’major’, ’name’, ’id’] True
{’major’: ’CS’, ’name’: ’Mary’, ’id’: ’8776’} >>>student.has_key(’grade’)
>>>type(student) #Get all values in a dictionary False
<type ’dict’> >>>student.values()
[’female’, ’CS’, ’Mary’, ’8776’]
#Get length of a dictionary
>>>len(student) #Add new key-value pair
3 >>>student[’gender’]=’female’
>>>student
#Get the value of a key in dictionary {’gende
>>>student[’name’] r’: ’female’, ’major’: ’CS’, ’name’: ’Mary’, ’id’: ’8776’}
’Mary’
#A value in a dictionary can be another dictionary
#Get all items in a dictionary >>>student1={’name’:’David’,’id’:’9876’,’major’:’ECE’}
>>>student.items() >>>students={’1’: student,’2’:student1}
[(’gender’, ’female’), (’major’, ’CS’), (’name’, ’Mary’), >>>students
(’id’, ’8776’)] {’1’:
{’gende
r’: ’female’, ’major’: ’CS’, ’name’: ’Mary’, ’id’: ’8776’}, ’2’:
INTERNET OF THINGS Page 39
{’
major’: ’ECE’, ’name’: ’David’, ’id’: ’9876’}}
• The for statement in Python iterates over items of any sequence (list, string, etc.) in the order in which they
appear in the sequence.
• This behavior is different from the for statement in other languages such as C in which an initialization,
incrementing and stopping criteria are provided.
#Looping over characters in a string #Looping over items in a list #Looping over keys in a dictionary
• The while statement in Python executes the statements within the while loop as long as the while condition is
true.
>>> i = 0
#Generate a list of numbers from 0 – 9 #Generate a list of numbers from 10 - 100 with increments
of 10
>>>range (10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>>range(10,110,10)
[10, 20, 30, 40, 50, 60, 70, 80, 90,100]
• The break and continue statements in Python are similar to the statements in C.
• Break #Break statement example
• Break statement breaks out of the for/while loop >>>y=1
>>>for x in range(4,256,4):
y=y*x
if y > 512:
break
print y
4
32
384
apple
INTERNET OF THINGS orange Page 46
mango
Control Flow – pass statement
>fruits=[’apple’,’orange’,’banana’,’mango’]
>for item in fruits:
if item == "banana":
pass
else:
print item
apple
orange
mango
• A function is a block of code that takes information in (in the form of students = { '1': {'name': 'Bob', 'grade': 2.5},
parameters), does some computation, and returns a new piece of '2': {'name': 'Mary', 'grade': 3.5},
'3': {'name': 'David', 'grade': 4.2},
information based on the parameter information. '4': {'name': 'John', 'grade': 4.1},
'5': {'name': 'Alex', 'grade': 3.8}}
avg = averageGrade(students)
print "The average garde is: %0.2f" % (avg)
• The first statement of the function body can optionally be a
documentation string or docstring.
>>>def displayFruits(fruits=[’apple’,’orange’]):
print "There are %d fruits in the list" % (len(fruits))
for item in fruits:
print item
>>>def displayFruits(fruits):
print "There are %d fruits in the list" % (len(fruits))
for item in fruits:
print item
print "Adding one more fruit"
fruits.append('mango')
• Functions can also be called using keyword arguments that identifies the arguments by the parameter name when the
function is called.
• Python functions can have variable length arguments. The variable length arguments are passed to as a tuple to the
function with an argument prefixed with asterix (*)
>>>student(’Nav’)
Student Name: Nav
• Python allows organizing the program #student module - saved as student.py #Using student module
>>>import student
def averageGrade(students):
code into different modules which sum = 0.0 >>>students = '1': 'name': 'Bob', 'grade': 2.5,
improves the code readability and for key in students: '2': 'name': 'Mary', 'grade': 3.5,
management. sum = sum + students[key]['grade'] '3': 'name': 'David', 'grade': 4.2,
average = sum/len(students) '4': 'name': 'John', 'grade': 4.1,
• A module is a Python file that defines return average '5': 'name': 'Alex', 'grade': 3.8
• Python package is hierarchical file structure that consists of # skimage package listing
modules and subpackages. skimage/ Top level package
init .py Treat directory as a package
• Packages allow better organization of modules related to a single
application environment. color/ color color subpackage
init .py
colorconv.py
colorlabel.py
rgb_colors.py
• Python allows reading and writing to files using the file # Example of reading an entire file
object. >>>fp = open('file.txt','r')
>>>content = fp.read()
>>>print content
This is a test file.
• The open(filename, mode) function is used to get a file >>>fp.close()
object.
# Example of reading line by line
>>>fp = open('file1.txt','r')
• The mode can be read (r), write (w), append (a), read and >>>print "Line-1: " + fp.readline()
write (r+ or w+), read-binary (rb), write-binary (wb), etc. Line-1: Python supports more than one programming paradigms.
>>>print "Line-2: " + fp.readline()
Line-2: Python is an interpreted language.
>>>fp.close()
• After the file contents have been read the close function is
called which closes the file object. # Example of reading lines in a loop
>>>fp = open(’file1.txt’,’r’)
>>>lines = fp.readlines()
>>>for line in lines:
print line
• Python provides several functions for date and time access and conversions.
• The datetime module allows manipulating date and time in several ways.
• The time module in Python provides various time-related functions.
>>>print "Month: " + now.strftime("%B") >>>time.strftime("The date is %d-%m-%y. Today is a %A. It is %H hours, %M minutes and %S seconds now.")
Month: July 'The date is 24-07-13. Today is a Wednesday. It is 16 hours, 15 minutes and 14 seconds now.'
>>>then = date(2013, 6, 7)
>>>timediff = now - then
>>>timediff.days
47
INTERNET OF THINGS Page 58
Classes
• Python is an Object-Oriented Programming (OOP) language. Python provides all the standard features of Object
Oriented Programming such as classes, class variables, class methods, inheritance, function overloading, and
operator overloading.
• Class
• A class is simply a representation of a type of object and user-defined prototype for an object that is composed of three things: a name,
attributes, and operations/methods.
• Instance/Object
• Object is an instance of the data structure defined by a class.
• Inheritance
• Inheritance is the process of forming a new class from an existing class or base class.
• Function overloading
• Function overloading is a form of polymorphism that allows a function to have different meanings, depending on its context.
• Operator overloading
• Operator overloading is a form of polymorphism that allows assignment of more than one function to a particular operator.
• Function overriding
• Function overriding allows a child class to provide a specific implementation of a function that is already provided by the base class. Child class
implementation of the overridden function has the same name, parameters and return type as the function in the base class.
def draw(self):
INTERNET OF THINGS Page 61
print "Draw Circle (overridden function)"
Further Reading
IoT Device
A "Thing" in Internet of Things (IoT) can be any object that has a unique identifier and which
can send/receive data (including user data) over a network (e.g., smart phone, smartTV,
computer, refrigerator, car, etc.).
• IoT devices are connected to the Internet and send information about themselves or about their
surroundings (e.g. information sensed by the connected sensors) over a network (to other devices
or servers/storage) or allow actuation upon the physical entities/environment around them
remotely.
Raspberry Pi
Linux on Raspberry Pi
Raspberry Pi GPIO
GPIO.setmode(GPIO.BCM)
#LEDPin
GPIO.setup(18,GPIO.OUT)
state=false
deftoggleLED(pin):
GPIO.output(pin,state)
whileTrue:
try:
if (GPIO.input(25) ==True):
toggleLED(pin)
sleep(.01)
exit()
Other Devices
1. pcDuino
2. BeagleBoneBlack
3. Cubieboard
The Internet of Things (IoT) involves the internet-connected devices we use to perform
the processes and services that support our way of life. Another component set to help IoT
succeed is cloud computing, which acts as a sort of front end. Cloud computing is an
increasingly popular service that offers several advantages to IOT, and is based on the concept of
allowing users to perform normal computing tasks using services delivered entirely over the
internet. A worker may need to finish a major project that must be submitted to a manager, but
perhaps they encounter problems with memory or space constraints on their computing device.
Memory and space constraints can be minimized if an application is instead hosted on the
internet. The worker can use a cloud computing service to finish their work because the data is
managed remotely by a server. Another example: you have a problem with your mobile device
and you need to reformat it or reinstall the operating system. You can use Google Photos to
upload your photos to internet-based storage. After the reformat or reinstall, you can then either
move the photos back to you device or you can view the photos on your device from the internet
when you want.
Concept
In truth, cloud computing and IoT are tightly coupled. The growth of IoT and the rapid
development of associated technologies create a widespread connection of ―things. This has lead to
the production of large amounts of data, which needs to be stored, processed and accessed. Cloud
computing as a paradigm for big data storage and analytics. While IoT is exciting on its own, the
real innovation will come from combining it with cloud computing. The combination of cloud
computing and IoT will enable new monitoring services and powerful processing of sensory data
streams. For example, sensory data can be uploaded and stored with cloud computing, later to be
used intelligently for smart monitoring and actuation with other smart devices. Ultimately, the
goal is to be able to transform data to insight and drive productive, cost-effective action from
those insights. The cloud effectively serves as the brain to improved decision-making and
optimized internet-based interactions. However, when IoT meets cloud, new challenges arise.
There is an urgent need for novel network architectures that seamlessly integrate them. The
critical concerns during integration are quality of service (QoS) and quality of experience (QoE),
as well as data security, privacy and reliability. The virtual infrastructure for practical mobile
computing and interfacing includes integrating applications, storage devices, monitoring devices,
visualization platforms, analytics tools and client delivery. Cloud computing offers a practical
utility-based model that will enable businesses and users to access applications on demand
anytime and from anywhere.
First, the cloud computing of IoT is an on-demand self service, meaning it‘s there when you need
it. Cloud computing is a web-based service that can be accessed without any special assistance or
permission from other people; however, you need at minimum some sort of internet access.
Second, the cloud computing of IoT involves broad network access, meaning it offers several
connectivity options. Cloud computing resources can be accessed through a wide variety of
internet-connected devices such as tablets, mobile devices and laptops. This level of convenience
means users can access those resources in a wide variety of manners, even from older devices.
Again, though, this emphasizes the need for network access points.
Third, cloud computing allows for resource pooling, meaning information can be shared with
those who know where and how (have permission) to access the resource, anytime and
anywhere. This lends to broader collaboration or closer connections with other users. From an
IoT perspective, just as we can easily assign an IP address to every "thing" on the planet, we can
Service models
Service delivery in cloud computing comprises three different service models: software as a
service (SaaS), platform as a service (PaaS), and infrastructure as a service (IaaS).
Software as a service (SaaS) provides applications to the cloud‘s end user that are mainly
accessed via a web portal or service-oriented architecture-based web service technology. These
services can be seen as ASP (application service provider) on the application layer. Usually, a
specific company that uses the service would run, maintain and give support so that it can be
reliably used over a long period of time.
Platform as a service (PaaS) consists of the actual environment for developing and provisioning
cloud applications. The main users of this layer are developers that want to develop and run a
cloud application for a particular purpose. A proprietary language was supported and provided
by the platform (a set of important basic services) to ease communication, monitoring, billing
and other aspects such as startup as well as to ensure an application‘s scalability and flexibility.
Limitations regarding the programming languages supported, the programming model, the ability
to access resources, and the long-term persistence are possibledisadvantages.
Infrastructure as a service (IaaS) provides the necessary hardware and software upon which a
customer can build a customized computing environment. Computing resources, data storage
resources and the communications channel are linked together with these essential IT resources
to ensure the stability of applications being used on the cloud. Those stack models can be
referred to as the medium for IoT, being used and conveyed by the users in different methods for
the greatest chance of interoperability. This includes connecting cars, wearables, TVs,
smartphones, fitness equipment, robots, ATMs, and vending machines as well as the vertical
applications, security and professional services, and analytics platforms that come withthem.
A private cloud has infrastructure that‘s provisioned for exclusive use by a single organization
comprising multiple consumers such as business units. It may be owned, managed and operated
by the organization, a third party or some combination of them, and it may exist on or off
premises.
A public cloud is created for open use by the general public. Public cloud sells services to
anyone on the internet. (Amazon Web Services is an example of a large public cloud provider.)
This model is suitable for business requirements that require management of load spikes and the
applications used by the business, activities that would otherwise require greater investment in
infrastructure for the business. As such, public cloud also helps reduce capital expenditure and
bring down operational ITcosts.
A community cloud is managed and used by a particular group or organizations that have shared
interests, such as specific security requirements or a common mission.
Finally, a hybrid cloud combines two or more distinct private, community or public cloud
infrastructures such that they remain unique entities but are bound together by standardized or
proprietary technology that enables data and application portability. Normally, information that‘s
not critical is outsourced to the public cloud, while business-critical services and data are kept
within the control of the organization.
A cloud storage API is an application program interface that connects a locally-based application
to a cloud-based storage system, so that a user can send data to it and access and work with data
stored in it. To the application, the cloud storage system is just another target device, like tape or
disk-based storage. An application program interface (API) is code that allows two software
programs to communicate with each other. The API defines the correct way for a developer to
write a program that requests services from an operating system (OS) or other application. APIs
are implemented by function calls composed of verbs and nouns. The required syntax is
described in the documentation of the application beingcalled.
1. Local APIs are the original form, from which the name came. They offer OS
or middleware services to application programs. Microsoft's .NET APIs, the TAPI
(Telephony API) for voice applications, and database access APIs are examples of the
local APIform.
2. Web APIs are designed to represent widely used resources like HTML pages and are
accessed using a simple HTTP protocol. Any web URL activates a web API. Web APIs
are often called REST (representational state transfer) or RESTful because the publisher
of REST interfaces doesn't save any data internally between requests. As such, requests
from many users can be intermingled as they would be on theinternet.
3. Program APIs are based on remote procedure call (RPC) technology that makes a
remote program component appear to be local to the rest of the software. Service oriented
architecture (SOA) APIs, such as Microsoft's WS-series of APIs, are programAPIs.
A Small Medium Enterprise (SME) developing an energy management IoT product, targeting
smart homes and smart buildings. By streaming the data of the product (e.g., sensors and WSN
data) into the cloud it can accommodate its growth needs in a scalable and cost effective fashion.
As the SMEs acquires more customers and performs more deployments of its product, it is able
tocollectandmanagegrowingvolumesofdatainascalableway,thustakingadvantageofa
―pay-as-you-grow‖model. Moreover, cloud integration allows the SME to store and
processmassive datasets collected from multiple (rather than a single)deployments.
A smart city can benefit from the cloud-based deployment of its IoT systems and applications. A
city is likely to deploy many IoT applications, such as applications for smart energy
management, smart water management, smart transport management, urban mobility of the
citizensandmore.Theseapplicationscomprisemultiplesensorsanddevices,alongwith
A cloud computing provider offering pubic cloud services can extend them to the IoT area,
through enabling third-parties to access its infrastructure in order to integrate IoT data and/or
computational components operating over IoT devices. The provider can offer IoT data access
and services in a pay-as-you-fashion, through enabling third-parties to access resources of its
infrastructure and accordingly to charge them in a utility-based fashion.
These motivating examples illustrate the merit and need for converging IoT and cloud computing
infrastructure. Despite these merits, this convergence has always been challenging mainly due to
the conflicting properties of IoT and cloud infrastructures, in particular, IoT devices tend to be
location specific, resource constrained, expensive (in terms of development/ deployment cost)
and generally inflexible (in terms of resource access and availability). On the other hand, cloud
computing resources are typically location independent and inexpensive, while at the same time
providing rapid and flexibly elasticity. In order to alleviate these incompatibilities, sensors and
devices are virtualized prior to integrating their data and services in the cloud, in order to enable
their distribution across any cloud resources. Furthermore, service and sensor discovery
functionalities are implementing on the cloud in order to enable the discovery of services and
sensors that reside in different locations.
Based on these principles the IoT/cloud convergence efforts have started since over a decade i.e.
since they very early days of IoT and cloud computing. Early efforts in the research community
(i.e. during 2005-2009) have focused on streaming sensor and WSN data in a cloud
infrastructure. Since 2007 we have also witnessed the emergence of public IoT clouds, including
commercial efforts. One of the earliest efforts has been the famous Pachube.com infrastructure
(used extensively for radiation detection and production of radiation maps during earthquakes in
Japan). Pachube.com has evolved (following several evolutions and acquisitions of this
infrastructure) to Xively.com, which is nowadays one of the most prominent public IoT clouds.
Nevertheless, there are tens of other public IoT clouds as well, such
as ThingsWorx, ThingsSpeak,Sensor-Cloud,Realtime.io and more. The list is certainly non-
exhaustive. These public IoT clouds offer commercial pay-as-you-go access to end-users wishing
to deploying IoT applications on the cloud. Most of them come with developer friendly tools,
which enable the development of cloud applications, thus acting like a PaaS for IoT in the cloud.
Similarly to cloud computing infrastructures, IoT/cloud infrastructures and related services can
be classified to the followingmodels:
3. Software-as-a-Service (SaaS) IoT/Clouds: SaaS IoT services are the ones enabling their
uses to access complete IoT-based software applications through the cloud, on-demand
and in a pay-as-you-go fashion. As soon as sensors and IoT devices are not visible, SaaS
IoT applications resemble very much conventional cloud-based SaaS applications. There
are however cases where the IoT dimension is strong and evident, such as applications
involving selection of sensors and combination of data from the selected sensors in an
integrated applications. Several of these applications are commonly called Sensing-as-a-
Service, given that they provide on-demand access to the services of multiple sensors.
Note that SaaS IoT applications are typically built over a PaaS infrastructure and enable
utility based business models involving IoT software andservices.
These definitions and examples provide an overview of IoT and cloud convergence and why it is
important and useful. More and more IoT applications are nowadays integrated with the cloud in
order to benefit from its performance, business agility and pay-as-you-go characteristics. In
following chapters of the tutorial, we will present how to maximize the benefits of the cloud for
IoT, through ensuring semantic interoperability of IoT data and services in the cloud, thus
enabling advanced data analytics applications, but also integration of a wide range of vertical
(silo) IoT applications that are nowadays available in areas such as smart energy, smart transport
and smart cities. We will also illustrate the benefits of IoT/cloud integration for specific areas
and segments of IoT, such as IoT-based wearablecomputing.
1. Caller: Caller issues calls to the remote procedures along with call arguments. – Callee:
Callee executes the procedures to which the calls are issued by the caller and returns the
results back to the caller. • Router: Routers are peers that perform generic call and event
routing. In publish-subscribe model Router has the role of a Broker: – Broker: Broker acts as
a router and routes messages published to a topic to all subscribers subscribed to thetopic.
1. Dealer: Dealer acts a router and routes RPC calls from the Caller to the Callee and routes
results from Callee toCaller.
2. Application Code: Application code runs on the Clients (Publisher, Subscriber, Callee or
Caller).
scale_up_policy = ScalingPolicy(name='scale_up',
adjustment_type='ChangeInCapacity',
as_name='My-Group',
scaling_adjustment=1,
cooldown=180)
scale_down_policy =ScalingPolicy(name='scale_down',
adjustment_type='ChangeInCapacity',
as_name='My-Group', scaling_adjustment=-1,
cooldown=180)
conn.create_scaling_policy(scale_up_policy)
conn.create_scaling_policy(scale_down_policy)
AutoScaling Policies:
1. After creating an AutoScaling group, the policies for scaling up and scaling down are
defined.
2. In this example, a scale up policy with adjustment type ChangeInCapacity and scaling_ad
justment = 1 isdefined.
3. Similarly a scale down policy with adjustment type ChangeInCapacity and scaling_ad
justment = -1 isdefined.
CloudWatch Alarms
#Connecting to CloudWatch
cloudwatch = boto.ec2.cloudwatch.connect_to_region(REGION,
aws_access_key_id=ACCESS_KEY,
scale_up_alarm = MetricAlarm(
name='scale_up_on_cpu', namespace='AWS/EC2',
metric='CPUUtilization', statistic='Average',
comparison='>', threshold='70',
period='60', evaluation_periods=2,
alarm_actions=[scale_up_policy.policy_arn],
dimensions=alarm_dimensions)
cloudwatch.create_alarm(scale_up_alarm)
scale_down_alarm =MetricAlarm(
name='scale_down_on_cpu',namespace='AWS/EC2',
metric='CPUUtilization', statistic='Average',
comparison='<',threshold='40',
period='60', evaluation_periods=2,
alarm_actions=[scale_down_policy.policy_arn],
dimensions=alarm_dimensions) cloudwatch.create_alarm(scale_down_alarm)
1. With the scaling policies defined, the next step is to create Amazon CloudWatch alarms
that trigger thesepolicies.
2. The scale up alarm is defined using the CPUUtilization metric with the Average statistic
and threshold greater 70% for a period of 60 sec. The scale up policy created previously
is associated with this alarm. This alarm is triggered when the average CPU utilization of
the instances in the group becomes greater than 70% for more than 60seconds.
3. The scale down alarm is defined in a similar manner with a threshold less than50%.
The example shows inverted index mapper program. The map function reads the
data from the standard input (stdin) and splits the tab-limited data into document-
ID and contents of the document. The map function emits key-value pairs where
key is each word in the document and value is the document-ID.
for line in sys.stdin: # remove leading and trailing whitespace line = line.strip() #
parse the input we got from mapper.py word, doc_id = line.split(‘‘) if current_word
== word: current_docids.append(doc_id) else: if current_word: print ‘%s%s‘ %
(current_word, current_docids) current_docids = [] current_docids.append(doc_id)
current_word = word
The example shows inverted index reducer program. The key-value pairs emitted
by the map phase are shuffled to the reducers and grouped by the key. The reducer
reads the key-value pairs grouped by the same key from the standard input (stdin)
and creates a list of document-IDs in which the word occurs. The output of reducer
contains key value pairs where key is a unique word and value is the list of
document-IDs in which the word occurs.
Django Architecture
Django is Model-Template-View (MTV) framework.
1. Model: The model acts as a definition of some stored data and handles the
interactions with the database. In a web application, the data can be stored in a
relational database, non-relational database, an XML file, etc. A Django
model is a Python class that outlines the variables and methods for a particular
type ofdata.
2. Template: In a typical Django web application, the template is simply an
HTML page with a few extra placeholders. Django‘s template language can
be used to create various forms of text files (XML, email, CSS, Javascript,
CSV,etc.)
3. View :The view ties the model to the template. The view is where you write
the code that actually generates the web pages. View determines what data is
to be displayed, retrieves the data from the database and passes the data to the
template.
A user has the following features through a mobile application in which he/she:
1. can turn on or o_ LED lights and monitor the state of theLED.
2. can lock and unlock doors through servo motors and monitor if the doors are
locked orunlocked.
3. can monitor if the doors are closed or opened through IR sensors.
As the field of Home Automation through IoT is a wide application in a very wide and
challenging field due to the reasons mentioned in the previous paragraphs, I chose to work on
that field as part of this thesis, specifically in maintaining and ensuring security and safety inside
home.
IoT aims in creating a network between objects embedded with sensors, that canstore, analyze,
communicate and exchange data together over the internet. This leads to efficient industry,
manufacturing, efficient energy management, resource management, accurate health care,
smarter business decisions based on analyzed data, safer driving through smart cars that are able
to communicate together, smart home automation and countless moreapplications.
To simplify the publish/subscribe model along with the system architecture used in this Home
Automation project, here is the explanation of the steps of constructing it: Different sensors,
The subscriber in this scenario, of a user acquiring data and readings by the sensors and
monitoring devices, is the web/mobile application. The "subscription key" and "channel name" is
embedded in the web/mobile application's code. Allowing it to receive messages forwarded by
PubNub. On the other hand, in a scenario where the user wants to send a command to home
appliances, controlling the LED lights for example, the web/mobile application is the publisher
provided by the "publish key" and the "channel name".The commend is sent in the form of JSON
string to PubNub servers, while the "subscription key" and "channel name" is embedded in the
Raspberry Pi code. This allows the Raspberry Pi to receive any published strings on the channel
it is subscribed to. Upon receiving the JSON string, the Raspberry Pi take the action specified by
that string. This allows full control and monitoring of all devices connected to the Raspberry Pi
by theuser.
The Internet-of-Things (IoT) is the novel cutting-edge technology which proffers to connect
plethora of digital devices endowed with several sensing, actuation and computing capabilities
with the Internet, thus offers manifold new services in the context of a smart city. The appealing
IoT services and big data analytics are enabling smart city initiatives all over the world. These
services are transforming cities by improving infrastructure, transportation systems, reduced
traffic congestion, waste management and the quality of human life. In this paper, we devise a
taxonomy to best bring forth a generic overview of IoT paradigm for smart cities, integrated
information and communication technologies (ICT), network types, possible opportunities and
major requirements. Moreover, an overview of the up-to-date efforts from standard bodies is
presented. Later, we give an overview of existing open source IoT platforms for realizing smart
city applications followed by several exemplary case studies. In addition, we summarize the
latest synergies and initiatives worldwide taken to promote IoT in the context of smart cities.
Finally, we highlight several challenges in order to give future researchdirections.
This section presents a taxonomy of IoT based smart cities which categorizes the literature on the
basis of existing communication protocols, major service providers, network types,
standardization efforts, offered services, and crucial requirements.
Communication Protocols
IoT based smart city realization significantly relies on numerous short and wide range
communication protocols to transport data between devices and backend servers. Most
prominent short range wireless technologies include Zig-Bee, Bluetooth, Wi-Fi, Wireless
Metropolitan Area Network (WiMAX) and IEEE 802.11p which are primarily used in smart
metering, e-healthcare and vehicular communication. Wide range technologies such as Global
System for Mobile communication (GSM) and GPRS, Long-Term Evolution (LTE), LTE-
Advanced are commonly utilized in ITS such as vehicle-to infrastructure (V2I), mobile e-
healthcare, smart grid and infotainment services. Additionally, LTE-M is considered as an
evolution for cellular IoT (C-IoT). In Release 13, 3GPP plans to further improve coverage,
battery lifetime as well as device complexity [7]. Besides well-known existing protocols, LoRa
alliance standardizes the LoRaWAN protocol to support smart city applications to primarily
ensure interoperability between several operators. Moreover, SIGFOX is an ultra narrowband
radio technology with full star-based infrastructure offers a high scalable global network for
realizing smart city applications with extremely low power consumption. A comparative
summary2 of the major communicationprotocols.
Service Providers
Pike Research on smart cities estimated this market will grow to hundreds of billion dollars by
2020, with an annual growth of nearly 16 billion. IoT is recognized as a potential source to
increase revenue of service providers. Thus, well-known worldwide service providers have
already started exploring this novel cutting edge communication paradigm. Major service
providers include Telefonica, SK telecom, Nokia, Ericsson, Vodafone, NTT Docomo, Orange,
Telenor group and AT&T which offer variety of services and platforms for smart city
applications such as ITS and logistics, smart metering, home automation and e-healthcare.
Network Types
IoT based smart city applications rely on numerous network topologies to accomplish a fully
autonomous environment. The capillary IoT networks offer services over a short range.
Examples include wireless local area networks (WLANs), BANs and wireless personal area
networks (WPANs). The application areas include indoor e-healthcare services, home
automation, street lighting. On the other hand, applications such as ITS, mobile e-healthcare and
waste management use wide area networks (WANs), metropolitan area networks (MANs),and
The rapid advancements in communication technologies and the explosive growth of Internet of
Things (IoT) have enabled the physical world to invisibly interweave with actuators, sensors, and
other computational elements while maintaining continuous network connectivity. The
continuously connected physical world with computational elements forms a smart environment.
A smart environment aims to support and enhance the abilities of its dwellers in executing their
tasks, such as navigating through unfamiliar space and moving heavy objects for the elderly, to
name a few. Researchers have conducted a number of efforts to use IoT to facilitate our lives and
to investigate the effect of IoTbased smart environments on human life. This paper surveys the
state-of-the-art research efforts to enable the IoT-based smart environments. We categorize and
classify the literature by devising a taxonomy based on communication enablers, network types,
technologies, local area wireless standards, objectives, and characteristics. Moreover, the paper
highlights the unprecedented opportunities brought about by IoT-based smart environments and
their effect on human life. Some reported case studies from different enterprises are also
presented. Finally, we discuss open research challenges for enabling IoT-based smart
environments.
Communication Enablers
Communication enablers refer to wireless technologies used to communicate across the Internet.
The key wireless Internet technologies are WiFi, 3G, 4G, and satellite. WiFi is mainly used in
smart homes, smart cities, smart transportation, smart industries, and smart building
environments; whereas, 3G and 4G are mainly used in smart cities and smart grid environments.
Satellites are used in smart transportation, smart cities, and smart grid environments. Table
presents the comparative summary of the communication technologies used in IoT based smart
environments.
Network Types
IoT-based smart environments rely on different types of networks to perform the collaborative
tasks for making the lives of inhabitants more comfortable. The main networks are wireless local
area networks (WLANs), wireless personal area networks (WPANs), wide area networks
(WANs), metropolitan area networks (MANs), and wireless regional area networks (WRANs).
These networks have different characteristics in terms of size, data transfer, and supported reach
ability.
Technologies
IoT-based smart environments leverage various technologies to form a comfortable and suitable
ecosystem. These technologies are include sensing, communication, data fusion, emerging
computing, and information security. Sensing technologies are commonly used to acquire data
from various locations and transmit it using communication technologies to a central location.
The emerging computing technologies, such as cloud computing and fog computing, deployed in
the central location, leverage the data fusion technologies for integrating the data coming from
heterogeneous resources. In addition, smart environments also use information security
technologies to ensure data integrity and user privacy.