Iot-Notes PDF
Iot-Notes PDF
CSE I - Semester
(ELECTIVE - IV)
Course Outcomes:
1. Able to underst
understand
and the
the applicat
application
ion areas
areas of IOT
IOT
2. Abl
Ablee to rea
realiz
lizee the revoluti
revolution
on of Internet
Internet in Mobile
Mobile Devices
Devices,,
Cloud & Sensor Networks
3. Ab
Able
le to un
unde
ders
rsta
tand
nd bu
buil
ildi
ding
ng bl
bloc
ocks
ks of In
Inte
tern
rnet
et of Th
Thin
ings
gs an
and
d
characteristics.
Unit I
Characteristics of IoT
1. Dyna
Dynami
micc and
and self
self ada
adapt
ptin
ing
g
2. Self
Self conf
config
igur
urin
ing
g
3. Inter-
Inter-ope
operab
rable
le communic
communicati
ation
on protocol
protocolss
4. Uniq
Unique
ue iden
identi
tity
ty
Things of IoT
IOT Protocols
1. Link la
layer
802.3 Ethernet
802.11 WiFi
2. Self
Self conf
config
igur
urin
ing
g
3. Inter-
Inter-ope
operab
rable
le communic
communicati
ation
on protocol
protocolss
4. Uniq
Unique
ue iden
identi
tity
ty
Things of IoT
IOT Protocols
1. Link la
layer
802.3 Ethernet
802.11 WiFi
IEEE 802.11 is a set of media access control (MAC)
control (MAC) and
physical layer (PHY)
layer (PHY) specifications for implementing wireless
local area network (WLAN)
(WLAN) computer communication in the
900 MHz and 2.4, 3.6
3.6,, 5, and 60 GHz frequency bands. They
are created and maintained by the Institute of Electrical and
Electronics Engineers (IEEE)
Engineers (IEEE) LAN / MAN Standards
MAN Standards Committee
(IEEE 802).
802). The base version of the standard was released in
1997, and has had subsequent amendments. The standard and
amendments provide the basis for wireless network products
using the Wi-Fi
Wi-Fi brand.
brand. While each amendment is officially
revoked when it is incorporated in the latest version of the
standard, the corporate world tends to market to the revisions
because they concisely denote
deno te capabilities of their products. As a
result, in the market place, each revision tends to become its own
standard.
802.16 WiMax
802.15.4-LR-WPAN
2. Network/Internet Layer
IPv4
IPv6
6LoWPAN
3. Transport Layer
TCP
UDP
4. Application layer
HTTP
CoAP
WebSocket
MQTT
XMPP
DDS
AMQP
• Device
Services
Communication
Management
Security
Application
Request-Response
Publish-Subscribe
Push-Pull
Most of the business communication tools we use today are
“push” tools, where the sender of the message decides who will
receive it. Email is the classic example of this; the sender of the
message chooses who to put on the To and Cc lines. The
recipient gets no choice about whether they receive the message
or not, and anyone who is not copied on the message doesn’t
even know of its existence. The sender is firmly in control.
Instant messaging, SMS and even phone calls are all examples
of push.
Exclusive Pair
Client-Server
Cache-able
Layered system
Wireless-Sensor networks
Cloud computing
Infrastructure-as-a-Service (IaaS)
Platform-as-a-Service (PaaS)
Software-as-a-Service (SaaS)
Communication Protocols
Embedded System
IoT Levels
• Device
• Resource
• Controller Service
• Database
• Web Service
◦ Stateless/Stateful
◦ Unidirectional/Bi-directional
◦ Request-Response/Full Duplex
◦ TCP connection
◦ Header overhead
◦ Scalability
• Analysis component
• Application
IoT Level-1
At this level, the most basic level, things are given context and the ability to
make their awareness known, connecting digital and physical things together.
IoT Level-2
This is already largely used with weather systems, to track changes in the
weather and is largely used throughout the agriculture industry.
IoT Level-3
The third level of IoT is linked with remote control of environment and things,
whether someone is in a physical space or sitting in an office 5,000 miles away.
This is being seen increasingly in the automotive and smart home industry,
where people can monitor the status of their cars or homes, turn on heating, or
control the lighting and other elements.
This is also seen in large scale modern factories and even offices that have
smart heating systems, smart printers and security systems. The third level is
also about a level of intelligence within remote systems and things; where they
can tell a user or a backend system when they are developing an issue and
when they need help. At this level, it goes beyond awareness, from
communication to insight, mixed with control.
To get started with IoT consider the levels. What level are you trying to
achieve and is it logical to work through level one to three in a linear fashion?
Or is it about experimenting and learning as you go? There is an argument for
jumping straight in at level two and three, but this will depend on the current
infrastructure and capability.
IoT Level-4
A level-4 IoT system has multiple nodes that perform local analysis. Level-4
contains local and cloud-based observer nodes which can subscribe to and
receive information collected in the cloud from IoT devices.
IoT Level-5
A level-5 IoT system has multiple end nodes and one coordinator node. The
end node perform sensing and/or actuation. Coordinator node collects data
from the end nodes and sends to the cloud.
IoT Level-6
A level-6 IoT system has multiple independent end nodes that perform sensing
and/or actuation and send data to the cloud.
Questions
Home Automation
Home automation is the use and control of home appliances remotely or
automatically. Early home automation began with labour-saving machines like
washing machines. Some home automation appliances are stand alone and do
not communicate, such as a programmable light switch, while others are part of
the internet of things and are networked for remote control and data transfer.
Hardware devices can include sensors (like cameras and thermometers),
controllers, actuators (to do things), and communication systems. Remote
control can range from a simple remote control to a smartphone with
Bluetooth, to a computer on the other side of the world connected by internet.
Home automation systems are available which consist of a suite of products
designed to work together. These typically connected through Wi-Fi or power
line communication to a hub which is then accessed with a software
application. Popular applications include thermostats, security systems, blinds,
lighting, smoke/CO detectors, and door locks.[1] Popular suites of products
include X10, Z-Wave, and Zigbee all of which are incompatible with each
other. Home automation is the domestic application of building automation
• Smart Lighting
• Smart Appliances
• Intrusion detection
• Smoke/Gas detectors
Cities
• Smart parking
• Smart Lighting
• Smart roads
• Surveillance
• Emergency Response
Environment
• Weather Monitoring
Energy
Smart Grids
• Prognostics
Retail
IoT has caught the imagination of technology enthusiasts and there are many
predictions of how it might revolutionize industries and practices as we know
them today. The retail industry has already undergone a wave of disruption
with the onset of e-commerce and online retail. There is every chance that IoT
heralds the next wave of disruption along the following areas in retail:
– Supply Chain Management
– Inventory & Warehouse Management
– Marketing
– In-Store Experience
• Inventory management
• Smart payments
Logistics
• Route Generation & Scheduling
• Fleet tracking
• Shipment Monitoring
Agriculture
Agriculture has been evolving with new technology such as the Internet of
Things (IoT). For example, greenhouses are connected to each other, and their
environments are controlled automatically and optimized for the best q uality of
agricultural products. In addition, the advanced cattle sheds are built based on
the IoT technologies. These efforts enhance the quality and safety of
agricultural products and mitigate information asymmetry between producers
and consumers.
• Smart Irrigation
Industry
• Machine Diagnosis and prognosis
• Wearable electronics
Questions
1. Determine
Determine the IoT-levels
IoT-levels for designin
designing
g home automati
automation
on IoT system
systemss
including smart leghting and intrusion detection.
2. Determine
Determine the IoT-lev
IoT-levels
els for designi
designing
ng structural
structural health monitor
monitoring
ing
system.
3. Determine
Determine various
various communi
communication
cation models that can
can be used
used for weather
weather
monitoring system. What is more appropriate model for this system.
Describe the pros and cons.
4. Determine
Determine the type of data generated
generated by a forest
forest fire
fire detection
detection system
system??
Describe alternative approaches for storing the data. What type of
analysis is required for forest fire detection from the data collected.
Unit III
M2M
The aptly named IoT subset M2M initially represented closed, point-to-point
communication between physical-first objects. The explosion of mobile
devices and IP-based connectivity mechanisms has enabled data transmission
across a system of networks. M2M is more recently referred to technologies
that enable communication between machines without human intervention.
Examples include telemetry, traffic control, robotics, and other applications
involving device-to-device communications.
Difference between IOT and M2M
1. Communication protocols
5. Applications
SDN and NFV for IOT
• management Overhead
• Limited Scalability
• Automating Configuration
• Improved Reliablity
Limitations of SNMP
• SNMP is stateless
• SNMP can be used only for device monitoring and status polling.
• Ease of use
• configuration deltas
• configuration validation
• Comparing configurations
NETCONF
• Management System
• Management API
• Transaction Manager
• Rollback Manager
• Configuration Validator
• Configuration Database
• Configuration API
NETOPEER
• Netopeer-server
• Netopeer-agent
• Netopeer-cli
• Netopeer-manager
• Netopeer-configurator
Questions:
Unit IV
Features of Python
Simple
Easy to Learn
As you will see, Python is extremely easy to get started with. Python has an
extraordinarily simple syntax, as already mentioned.
High-level Language
When you write programs in Python, you never need to bother about the low-
level details such as managing the memory used by your program, etc.
Portable
Due to its open-source nature, Python has been ported (i.e. changed to make it
work on) to many platforms. All your Python programs can work on any of
these platforms without requiring any changes at all if you are careful enough
to avoid any system-dependent features.
You can use Python on Linux, Windows, FreeBSD, Macintosh, Solaris, OS/2,
Amiga, AROS, AS/400, BeOS, OS/390, z/OS, Palm OS, QNX, VMS, Psion,
Acorn RISC OS, VxWorks, PlayStation, Sharp Zaurus, Windows CE and even
PocketPC !
Interpreted
Object Oriented
data and functionality. Python has a very powerful but simplistic way of doing
OOP, especially when compared to big languages like C++ or Java.
Extensible
If you need a critical piece of code to run very fast or want to have some piece
of algorithm not to be open, you can code that part of your program in C or C+
+ and then use them from your Python program.
Embeddable
You can embed Python within your C/C++ programs to give 'scripting'
capabilities for your program's users.
Extensive Libraries
The Python Standard Library is huge indeed. It can help you do various things
involving regular expressions, documentation generation, unit testing,
threading, databases, web browsers, CGI, ftp, email, XML, XML-RPC, HTML,
WAV files, cryptography, GUI (graphical user interfaces), Tk, and other
system-dependent stuff. Remember, all this is always available wherever
Python is installed. This is called the 'Batteries Included' philosophy of Python.
Besides, the standard library, there are various other high-quality libraries such
as wxPython, Twisted, Python Imaging Library and many more.
Numbers
Number data types store numeric values. They are immutable data
types, means that changing the value of a number data type results in a
newly allocated object.
int (signed integers): They are often called just integers or ints, are
positive or negative whole numbers with no decimal point. Integers in
Python 3 are of unlimited size. Python 2 has two integer types - int and
long. There is no 'long integer' in Python 3 any more.
float (floating point real values) : Also called floats, they represent real
numbers and are written with a decimal point dividing the integer and
fractional parts. Floats may also be in scientific notation, with E or e
indicating the power of 10 (2.5e2 = 2.5 x 102 = 250).
complex (complex numbers) : are of the form a + bJ, where a and b are
floats and J (or j) represents the square root of -1 (which is an imaginary
number). The real part of the number is a, and the imaginary part is b.
Complex numbers are not used much in Python programming.
• Strings
Strings are amongst the most popular types in Python. We can create
them simply by enclosing characters in quotes. Python treats single
quotes the same as double quotes. Creating strings is as simple as
assigning a value to a variable.
#!/usr/bin/python3
Lists
list2 = [1, 2, 3, 4, 5 ];
Tuples
tup2 = (1, 2, 3, 4, 5 );
tup1 = ();
tup1 = (50,);
Like string indices, tuple indices start at 0, and they can be sliced,
concatenated, and so on.
Dictionaries
Each key is separated from its value by a colon (:), the items are
separated by commas, and the whole thing is enclosed in curly braces.
An empty dictionary without any items is written with just two curly
braces, like this: {}.
Keys are unique within a dictionary while values may not be. The
values of a dictionary can be of any type, but the keys must be of an
immutable data type such as strings, numbers, or tuples.
To access dictionary elements, you can use the familiar square brackets
along with the key to obtain its value. Following is a simple example −
#!/usr/bin/python
dict['Name']: Zara
dict['Age']: 7
Type conversion
int() int(3.141592)3
integer
Control Flow
if statement
Python provide various tools for flow control. Some of them are if ,
if .. elif .. else, if..else,while ,for , switch, pass, range, break, else,
continue, function etc. In this article I’ll be covering only if-else and
loops.
if (condition):
statements…
if … else
It’s like if have money then spend else wait for salary. I hope it’s clear
from the previous line what this statement means. It’s like if the
conditions of if block is evaluated to true then execute that block else
execute the else block. The else block is optional and one if can have
any number of else blocks.
Syntax:
if (condition):
statements…
else:
default statements…
if … elif … else
Syntax:
if (option1 condition):
option1 statements…
elif(option2 condition):
option2 statements…
elif(option3 condition):
option3 statements…
else:
for
It is used for looping over a sequence. Python doesn’t supports old for
loop or c-style for loop. In traditional style for loop we have one
variable which iterates over a sequence and we can change the value of
sequence and variable as well but in modern for loop we have iteration
variable that iterates over a fixed sequence. We can not change the
sequence as well as iteration variable during iteration.
Syntax:
…statements…
while
Syntax
while expression:
statement(s)
When the condition becomes false, program control passes to the line
immediately following the loop.
range
Syntax:
…statements…
…statements…
…statements…
•
•
break/continue
Break is used for terminating the loop abnormally. i.e that even the
sequence is not completed but loop is exited.
Note: there are two more else statement, one is for if that I already
explained and other is with try. The difference between try else block
and loop else is try else block executes when no code is executed and
loop else executes when no break is executed.
pass
Functions
As you already know, Python gives you many built-in functions like print(),
etc. but you can also create your own functions. These functions are called
user-defined functions.
Defining a Function
You can define functions to provide the required functionality. Here are simple
rules to define a function in Python.
The code block within every function starts with a colon (:) and is
indented.
Syntax
"function_docstring"
function_suite
return [expression]
By default, parameters have a positional behavior and you need to inform them
in the same order that they were defined.
Modules
A module allows you to logically organize your Python code. Grouping related
code into a module makes the code easier to understand and use. A module is a
Python object with arbitrarily named attributes that you can bind and reference.
Example
The Python code for a module named aname normally resides in a file named
aname.py. Here's an example of a simple module, support.py
return
The import Statement
You can use any Python source file as a module by executing an import
statement in some other Python source file. The import has the following
syntax:
If we create a directory called foo, which marks the package name, we can then
create a module inside that package called bar. We also must not forget to add
the __init__.py file inside the foo directory.
import foo.bar
File Handling
Until now, you have been reading and writing to the standard input and output.
Now, we will see how to use actual data files.
Before you can read or write a file, you have to open it using Python's built-in
open() function. This function creates a file object, which would be utilized to
Syntax
Modes Description
Opens a file for reading only. The file pointer is placed at the beginning
r
of the file. This is the default mode.
Opens a file for reading only in binary format. The file pointer is placed
rb
at the beginning of the file. This is the default mode.
Opens a file for both reading and writing. The file pointer placed at the
r+
beginning of the file.
rb+ Opens a file for both reading and writing in binary format. The file
pointer placed at the beginning of the file.
Opens a file for writing only. Overwrites the file if the file exists. If the
w
file does not exist, creates a new file for writing.
Opens a file for writing only in binary format. Overwrites the file if the
wb
file exists. If the file does not exist, creates a new file for writing.
Opens a file for both writing and reading. Overwrites the existing file if
w+ the file exists. If the file does not exist, creates a new file for reading
and writing.
Opens a file for both writing and reading in binary format. Overwrites
wb+ the existing file if the file exists. If the file does not exist, creates a new
file for reading and writing.
Opens a file for appending. The file pointer is at the end of the file if
a the file exists. That is, the file is in the append mode. If the file does not
exist, it creates a new file for writing.
Opens a file for appending in binary format. The file pointer is at the
ab end of the file if the file exists. That is, the file is in the append mode. If
the file does not exist, it creates a new file for writing.
Opens a file for both appending and reading. The file pointer is at the
a+ end of the file if the file exists. The file opens in the append mode. If
the file does not exist, it creates a new file for reading and writing.
Opens a file for both appending and reading in binary format. The file
pointer is at the end of the file if the file exists. The file opens in the
ab+
append mode. If the file does not exist, it creates a new file for reading
and writing.
Example
ticks = time.time()
Classes
Before you start with encoding and decoding JSON using Python, you
need to install any of the JSON modules available. For this tutorial we
have downloaded and installed Demjson as follows −
$cd demjson-1.6
JSON Functions
Syntax
#!/usr/bin/pythonimport demjson
json = demjson.encode(data)
print json
[{"a":1,"b":2,"c":3,"d":4,"e":5}]
Syntax
demjson.decode(self, txt)
Example
#!/usr/bin/pythonimport demjson
json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
text = demjson.decode(json)
print text
On executing, it will produce the following result −
XML
What is XML?
The two most basic and broadly used APIs to XML data are the SAX
and DOM interfaces.
Simple API for XML (SAX) : Here, you register callbacks for events
of interest and then let the parser proceed through the document. This
is useful when your documents are large or you have memory
limitations, it parses the file as it reads it from disk and the entire file is
never stored in memory.
SAX is read-only, while DOM allows changes to the XML file. Since
these two different APIs literally complement each other, there is no
reason why you cannot use them both for large projects.
This module defines classes which implement the client side of the
HTTP and HTTPS protocols. It is normally not used directly — the
module urllib uses it to handle URLs that use HTTP and HTTPS.
>>> r1 = conn.getresponse()
200 OK
>>> r2 = conn.getresponse()
>>> conn.close()
200 OK
>>> conn.close()
The urllib module in Python 3 allows you access websites via your
program. This opens up as many doors for your programs as the
internet opens up for you. urllib in Python 3 is slightly different than
urllib2 in Python 2, but they are mostly the same. Through urllib, you
can access websites, download data, parse data, modify your headers,
and do any GET and POST requests you might need to do.
SMTPLib
import smtplib
host: This is the host running your SMTP server. You can specifiy IP
port, where SMTP server is listening. Usually this port would be 25.
Questions:
Unit V
IoT devices and systems include sensors that track and measure
activity in the world. One example is Smartthings' open-and-close
sensors that detect whether or not a drawer, window, or door in your
home is open or closed.
Actuation
Communication
Once the embedded sensors have gathered data, they are tasked with
transmitting this data to an identified destination. This transference can
utilize different connectivity methodologies, depending on the
requirements of the corresponding device, but will most often use
wired/wireless or PAN/BAN/LAN communication links. Regardless of
the method used, the links will generally only need to transmit small
kilobytes of data, unless higher bandwidths are required.
On the older beta model B boards, 128 MB was allocated by default to the
GPU, leaving 128 MB for the CPU.[25] On the first 256 MB release model B
(and model A), three different splits were possible. The default split was
192 MB (RAM for CPU), which should be sufficient for standalone 1080p
video decoding, or for simple 3D, but probably not for both together. 224 MB
was for Linux only, with only a 1080p framebuffer, and was likely to fail for
any video or 3D. 128 MB was for heavy 3D, possibly also with video decoding
(e.g. XBMC).
USB Ports
The Raspberry Pi 3 shares the same SMSC LAN9514 chip as its predecessor,
the Raspberry Pi 2, adding 10/100 Ethernet connectivity and four USB
channels to the board.
As before, the SMSC chip connects to the SoC via a single USB channel,
acting as a USB-to-Ethernet adaptor and USB hub.
Though the model A and A+ and Zero do not have an 8P8C ("RJ45") Ethernet
port, they can be connected to a network using an external user-supplied USB
Ethernet or Wi-Fi adapter.
The Raspberry Pi 3 is equipped with 2.4 GHz WiFi 802.11n and Bluetooth 4.1
in addition to the 10/100 Ethernet port.
Ethernet Ports
The Raspberry Pi 3 is equipped with 2.4 GHz WiFi 802.11n and Bluetooth
4.1 in addition to the 10/100 Ethernet port.
GPIO Pins
Any existing GPIO hardware will work without modification; the only
change is a switch to which UART is exposed on the GPIO’s pins, but
that’s handled internally by the operating system.
Linux on Raspberry Pi
• Raspbian
• Arch
• Pidora
• RaspBMC
• OpenELEC
• RISC OS
Raspberry Pi Interfaces
• Serial
• I2C
pcDuino
The beauty of the pcDuino lies in its extraordinarily well exposed hardware
peripherals. However, using these peripherals is more complex than u sing them
on, say, an Arduino-compatible board.
This tutorial will help you sort out the various peripherals, what they can do,
and how to use them.
Before we get started, there are a few things you should be certain you’re
familiar with, to get the most out of this tutorial:
pcDuino - some familiarity with the basics of the pcDuino is needed before
you jump into this. Please review our Getting Started with pcDuino tutorial
before going any further.
Linux - the biggest thing you should be familiar with it the Linux OS.
Remember, pcDuino is not an Arduino–it is a modern microcomputer
running a fully-functional, if compact, operating system.
SPI - a synchronous (clocked) serial peripheral interface used for
communications between chips at a board level. Requires a minimum of
four wires (clock, master-out-slave-in data, master-in-slave-out data, and
slave chip select), and each additional chip added to the bus requires one
extra chip select line.
All of the code in this tutorial can be found online, in our pcDuino Github
repository. It’s not a bad idea to check there for any updates to the code since
this tutorial was written.
BeagleBone Black
The BeagleBoard is a low-power open-source hardware single-board computer
produced by Texas Instruments in
Instruments in association with Digi-Key
Digi-Key and
and Newark
element14.. The BeagleBoard was also designed with open source software
element14
development in mind, and as a way of demonstrating the Texas Instrument's
OMAP3530 system-on-a-chip
system-on-a-chip..[8]
[8] The
The board was developed by a small team of
engineers as an educational board that could be used in colleges around the
world to teach open source hardware
ha rdware and software capabilities. It is also sold to
the public under the Creative Commons share-alike
share-alike license.
license. The board was
designed using Cadence OrCAD
OrCAD for
for schematics and Cadence Allegro for PCB
manufacturing; no simulation software was used.
Cubieboard
Cubieboard is a single-board computer,
computer, made in Zhuhai, Guangdong, China.
The first short run of prototype boards were sold internationally in September
2012, and the production version started to be sold in October 2012. It can run
Android 4 ICS,
ICS, Ubuntu 12.04 desktop, Fedora
Fedora 19
19 ARM Remix desktop, Arch
Linux ARM,
ARM, a Debian-based Cubian distribution, or OpenBSD
OpenBSD..