Iot Module 4
Iot Module 4
BUILDING IoT
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, smart TV, 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.
• A home automation device that allows remotely monitoring the status of appliances and
controlling the appliances.
• An industrial machine which sends information about its operation and health monitoring
data to a server
• A wireless-enabled wearable device that measures data about a person such as the number
of steps walked and sends the data to a cloud-based service.
• Sensing
• Sensors can be either on-board the IoT device or attached to the device.
• Actuation
• IoT devices can have various types of actuators attached that allow taking
• Communication
• Communication modules are responsible for sending collected data to other devices
or cloud- based servers/storage and receiving data from other devices and commands from
remote applications.
• Analysis and processing modules are responsible for making sense of the collected
data.
• Since Raspberry Pi runs Linux operating system, it supports Python" out of the box".
• Raspberry Pi runs various flavors of Linux and can perform almost all tasks that a
normal desktop computer can do.
• Raspberry Pi also allows interfacing sensors and actuators through the general purpose
I/O pins. • Since Raspberry Pi runs Linux operating system, it supports Python" out of the
box".
Linux on Raspberry Pi
• Raspbian
• Arch
• Pidora
• RaspBMC
• OpenELEC
• RISC OS
• RISC OS is a very fast and compact operating system.
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.
• Interpreted Language
• Interactive Language
• Python provides an interactive mode in which the user can submit commands
at the Python prompt and interact with the interpreter directly
Datatypes
Every value in Python has a datatype. Since everything is an object in Python programming,
data types are actually classes and variables are instance (object) of these classes.
There are various data types in Python. Some of the important types are listed below.
Python Numbers
Script.py
1. a = 5
2. print(a, "is of type", type(a))
3. a = 2.0
4. print(a, "is of type", type(a))
5. a = 1+2j
6. print(a, "is complex number?", isinstance(1+2j,complex))
Integers can be of any length, it is only limited by the memory available. A floating point
number is accurate up to 15 decimal places. Integer and floating points are separated by
decimal points. 1 is integer, 1.0 is floating point number. Complex numbers are written in the
form, x + yj, where x is the real part and y is the imaginary part. Here are some examples.
>>> a = 1234567890123456789
>>> a
1234567890123456789
>>> b = 0.1234567890123456789
>>> b
0.12345678901234568
>>> c = 1+2j
>>> c
(1+2j)
Python List
List is an ordered sequence of items. It is one of the most used datatype in Python and is very
flexible. All the items in a list do not need to be of the same type. Declaring a list is pretty
straight forward. Items separated by commas are enclosed within brackets [].
Script.py
1. a = [5,10,15,20,25,30,35,40]
2. # a[2] = 15
>>> a = [1,2,3]
>>> a[2]=4
>>> a
[1, 2, 4]
Python Tuple
Tuple is an ordered sequences of items same as list. The only difference is that tuples are
immutable. Tuples once created cannot be modified. Tuples are used to write-protect data
and are usually faster than list as it cannot change dynamically. It is defined within
parentheses () where items are separated by commas.
Script.py
t = (5,'program', 1+3j)
# t[1] = 'program'
# Generates error
t[0] = 10
Python Strings
String is sequence of Unicode characters. We can use single quotes or double quotes to
represent strings. Multi-line strings can be denoted using triple quotes, ''' or """.
Like list and tuple, slicing operator [ ] can be used with string. Strings are immutable.
Script.py
a ={5,2,3,1,4}
# printing setvariable
print("a = ", a)
print(type(a))
We can perform set operations like union, intersection on two sets. Set have unique values.
They eliminate duplicates. Since, set are unordered collection, indexing has no meaning.
Hence the slicing operator [] does not work. It is generally used when we have a huge amount
of data. Dictionaries are optimized for retrieving data. We must know the key to retrieve the
value. In Python, dictionaries are defined within braces {} with each item being a pair in the
form key:value. Key and value can be of anytype.
>>> d = {1:'value','key':2}
>>> type(d)
<class ‘dict’>
We use key to retrieve the respective value. But not the other way around.
Script.py
d ={1:'value','key':2}
print(type(d))
print("d[1] = ",d[1]);
# Generates error
print("d[2] = ",d[2]);
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.
• An industrial machine which sends information abouts its operation and health monitoring
data to a server.
• A wireless-enabled wearable device that measures data about a person such as the number
of steps walked and sends the data to a cloud-based service.
1. Sensing: Sensors can be either on-board the IoT device or attached to thedevice.
2. Actuation: IoT devices can have various types of actuators attached that allow taking
actions upon the physical entities in the vicinity of thedevice.
4. Analysis & Processing: Analysis and processing modules are responsible for making sense
of the collected data.
• Regular Deployment
1. Square Grid
2. Triangle Grid
3. Hexagon Grid
In the random deployment scheme, sensors are deployed in a random way. Therefore, the
exact locations of nodes are not known. Random deployment is usually suitable in the
following cases:
• When the environment is harsh and therefore, deployment of nodes is exceedingly difficult.
• When the cost of sensors is not an issue. In this method, sensors are dropped form a
helicopter, an airplane or an unmanned vehicle. Uniform random deployment is random
deployment where nodes are placed in a sensing area randomly with uniform distribution.
Fig. 1a illustrates the uniform random deployment method.
Regular Deployment:
Regular deployment refers to placing sensors in a regular form in a sensing area. This type of
deployment can usually be applied in non-harsh environment and non-large-scale regions.
four regular deployment strategies are introduced.
Square Grid:
In the square grid deployment, a square sensing area is divided into small squares and the
nodes are placed at the points of grid intersection as shown in Fig. 1b.
Triangle Grid: A square sensing area in this model is divided into small triangles and the
sensors are located in the points of triangle heads as shown in Fig. 1c
Hexagon Grid: In hexagon grid deployment scheme, a sensing area is divided into
hexagons, as illustrated in Fig. 1d, and the sensors are placed at the vertices of hexagons.
IoT Sensor Deployment Challenges: The business benefits of IoT coupled with market
trends are driving rapid IoT adoption in every industry vertical like smart cities, building
automation, industrial, healthcare, etc. This growing demand for IoT connectivity is paving
the way to a plethora of sensor types for various use cases such as traffic sensors, parking
meters, pressure sensors, electricity sensors, and so on. Efficient sensor deployment is one of
the key success factors in every IoT investment and that’s where most enterprises struggle a
lot today.
NEIGHBOUR DISCOVERY FOR lot SCENARIOS :
2. Deterministic Approach
In sensor networks when the nodes are deployed, their exact location
is not known, so time synchronization is used to determine their
location. Also time stamped messages will be transmitted among the
nodes in order to determine their relative proximity to one another.
Time synchronization is used to save energy; it will allow the nodes to
sleep for a given time and then awaken periodically to receive a
beacon signal. Many wireless nodes are battery powered, so energy
efficient protocols are necessary. Lastly, having common timing
between nodes will allow for the determination of the speed of a
moving node.
This protocol has two slots - Active slots and probe slots.
The nodes decide to remain awake during active slots, and
sleep during the remaining slots.
During an active slot, the node may send or receive or do both.
Successful discovery takes place between two neighboring
nodes whenever their active slots overlap.
When a discovery scheme uses few active slots to discover
neighbors within a reasonable time limit, then it is said to be
efficient.
In Searchlight, each node has two active slots in t.
The first active slot, called the anchor slot, is the first slot in
the period.
In the symmetric case, since the position of this anchor slot is
fixed in t but the start times for the t vary for different nodes,
the anchor slots for two nodes overlap only if the difference
between the start times of the two periods is less than a timeslot.
Searchlight introduces a second active slot in t called the probe
slot, which searches for the anchor slot of the other node.
After the completion of the learning phase, the framework enters the experimental phase. In
this phase, the framework is tested with the real world data and optimal decisions are taken.
Data Aggregation is the process of one or more sensor nodes and detects the information
result from the other sensor nodes. The aim of the data aggregation is removes data
redundancy and improves the energy lifetime in wireless sensor network. Therefore reducing
the number of data packets transmitted over the network because aggregation need less power
as compare to multiple packets sending having same data
Data Aggregation Approaches: Data aggregation is further divided into four basic
approaches.
c) Multipath approach
d) Hybrid approach
Cluster Based Approach: Cluster Based Approach is defined as the hierarchical approach in
which whole network is separated into various cluster. Each cluster has cluster heads. The
main role of cluster head is to aggregate data received from cluster members locally and
then transmits the result to base station. The cluster head can share information with the
sink directly via long range transmissions or multi hopping using other cluster heads.
Tree Based Approach: The Tree Based Approach is actually defining aggregation concept
which is used to make aggregation tree. This tree define as minimum spanning tree in which
sink node act as root and source node act as leaves. Data start flowing from leave nodes up
to root nodes. The main disadvantage of this approach is data packet loss at any level of
tree which may cause failure of whole network.
Multipath Approach: This approach is used to overcome the drawbacks of tree based
approach. Accordingly to this approach each and every node could send data packets over
multiple paths using multiple neighbors in aggregation tree. So a data packet sends from
source to destination using multiple paths with the help of intermediate nodes. The example
of this approach like ring topology. Overhead is the disadvantage of this approach
Hybrid Approach: The Hybrid Approach is the mixture of cluster based approach, multipath
approach and tree based approach. This approach is mainly used for adaptively for optimal
performance of their data aggregation
Data Dissemination is the process in which sensor nodes is collecting the data and
communicate to the base station or any other interested node. The source node is generating
the data and the information to be reported is known as event. Those nodes which are
interested in event and seek information are known as sink. So in this whole process data
are routed in sensor network. It is two steps process; in first step interested nodes broadcast
to their neighbor nodes in the network and in second step nodes after receiving the request
sends requesting data.
There are many data dissemination methods or approaches which are following as:
Flooding: If the destination node not received the data packet or specified number of hops is
not reached, then each node broadcast the gathered data until the packet reached to their
destination node. The main advantage of flooding is not requires costly topology maintain or
route discovery but it face several problems like implosion, overlap and resource blindness.
Gossiping: The gossiping is the version of flooding approach .In this approach the packet is
sent to a single neighbor chosen from neighbour table randomly instead of broadcasting
each packet to the entire neighbor. This process can take long time from completion.
Gossiping avoids the problem faced in flooding approach like implosion.
SPIN: (Sensor Protocol for Information via Negotiation) this is the enhancement of flooding
protocols based on data centric routing. Flooding has mainly three problems like:
The nodes which are interested in the event transmit REQ message for DATA.
After receiving REQ message source node sends DATA message to interested node.
In this way data can reach to all interested node in entire network.
This technique prevents the problems implosion, overlap and resource blindness which is
faced by flooding. Wireless Sensor Network is the important in the field networking. A
WSN is basically made up of number of several sensor nodes which work together.