0% found this document useful (0 votes)
11 views39 pages

Iot Step Material

The document provides an overview of the Internet of Things (IoT), defining it as a network of connected physical objects that can identify and communicate with each other. It outlines various IoT protocols, applications, communication models, and deployment levels, as well as specific use cases in smart cities, environments, energy systems, and logistics. Additionally, it highlights the enabling technologies and characteristics of IoT devices, emphasizing their dynamic, self-configuring, and interoperable nature.

Uploaded by

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

Iot Step Material

The document provides an overview of the Internet of Things (IoT), defining it as a network of connected physical objects that can identify and communicate with each other. It outlines various IoT protocols, applications, communication models, and deployment levels, as well as specific use cases in smart cities, environments, energy systems, and logistics. Additionally, it highlights the enabling technologies and characteristics of IoT devices, emphasizing their dynamic, self-configuring, and interoperable nature.

Uploaded by

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

STEP MATERIAL FOR INTERNET OF THINGS

UNIT I
Short Answer
1. Define Iot?
The internet of things (IoT) is a computing concept that describes the idea of everyday physical objects being
connected to the internet and being able to identify themselves to other devices. It has 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 network and use intelligent interfaces.
2. List of Iot protocols?
 Link Layer
 802.3 – Ethernet,802.11 – WiFi ,802.16 – WiMax ,802.15.4 – LR-WPAN,2G/3G/4G
 Network/Internet Layer
 IPv4,IPv6,6LoWPAN
 Transport Layer
 TCP,UDP
 Application Layer
 HTTP, CoAP ,WebSocket ,MQTT,XMPP,DDS,AMQP

3. list the applications of Iot?


1. Smart Grids
2. Smart cities
3. Smart homes
4. Healthcare
5. Earthquake detection
6. Radiation detection/hazardous gas detection
7. Smartphone detection
8. Water flow monitoring
4. List Iot communication model?
1. Request-Response communication model
2. Publish-Subscribe communication model
3. Push-Pull communication model
4. Exclusive Pair communication model
5.Iot enabling technologies?
1. Wireless Sensor Networks
2. Cloud Computing
3. Big Data Analytics
4. Embedded Systems
Long Answer Questions
1. What is Iot? Characteristics of Iot?
The internet of things (IoT) is a computing concept that describes the idea of everyday physical objects being connected to
the internet and being able to identify themselves to other devices. It has 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 network and use intelligent interfaces.

Dynamic and Self-Adapting:- IoT devices and system may have the capability to change dynamically depending upon the
system and operating conditions or sensed environment. For example, the surveillance cameras can change their modes
based on day or night

Self-configuring:- IoT devices have self-configuring capability which allows large number of devices to work together to
work provide certain functionality they can change their networking and update the software automatically.

Interoperable Communication Protocol: - IoT devices can communicate with number of interoperable (communicate
with other devices without special effort) communication protocols.

Unique ID: - IoT devices have a unique identity differentiated with unique IP address.

Integrated into Information Network: - IoT devices are integrated into the information network that allows them to
communicate and exchange data with other devices and system.

2.Generic block diagram of an iot device?

 An IoT device may consist of several interfaces for connections to other devices, both wired and wireless.
1. I/O interfaces for sensors
2. Interfaces for Internet connectivity
3. Memory and storage interfaces

4. Audio/video interfaces
2.List Iot communication model with diagrams?
1. Request-Response communication model
2. Publish-Subscribe communication model
3. Push-Pull communication model
4. Exclusive Pair communication model
Request-response communication model
 Request-Response is a communication model in which the client sends requests to the server and the server
responds to the requests.
 When the server receives a request, it decides how to respond, fetches the data, retrieves resource
representations, prepares the response, and then sends the response to the client.

Publish-Subscribe communication model

 Publish-Subscribe is a communication model that involves publishers, brokers and consumers.


 Publishers are the source of data. Publishers send the 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
subscribed consumers

Push-Pull communication model

 Push-Pull is a 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 consumers.
 Queues help in decoupling the messaging between the producers and consumers.
 Queues also act as a buffer which helps in situations when there is a mismatch between the rate at which the
producers push data and the rate rate at which the consumers pull data
Exclusive Pair communication model

 Exclusive Pair is a bidirectional, fully duplex communication model that uses a persistent connection between
the client and server.
 Once the connection 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.

2. Iot levels & deployment templates?

1. Database: Database can be either local or in the cloud and stores the data generated by the IoT device.

2. Web Service: Web services serve as a link between the IoT device, application, database and analysis components.
Web service can be either implemented using HTTP and REST principles (REST service) or using WebSocket
protocol (Web Socket service).

3. Analysis Component: The Analysis Component is responsible for analyzing the IoT data and generate results in
a form which are easy for the user to understand.

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

level-1

1. A level-1 IoT system has a single node/device that performs sensing and/or actuation, stores data, performs
analysis and hosts the application

2. Level-1 IoT systems are suitable for modeling low-cost and low-complexity solutions where the data
involved is not big and the analysis requirements are not computationally intensive.
Iot level-2

 A 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.
 Level-2 IoT systems are suitable for solutions where the data involved is big, however, the primary analysis
requirement is not computationally intensive and can be done locally itself.

Iot level-3

 A level-3 IoT system has a single node. Data is stored and analyzed in the cloud and application is cloud-
based.
 Level-3 IoT systems are suitable for solutions where the data involved is big and the analysis requirements
are computationally intensive.
Iot level-4

 A level-4 IoT system has multiple nodes that perform local analysis. Data is stored in the cloud and application
is cloud-based.
 Level-4 contains local and cloud-based observer nodes which can subscribe to and receive information
collected in the cloud from IoT devices.
 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.

Iot level-5

 A level-5 IoT system has multiple end nodes and one coordinator node.
 The end nodes that perform sensing and/or actuation.
 Coordinator node collects data from the end nodes and sends to the cloud.
 Data is stored and analyzed in the cloud and application is cloud-based.
 Level-5 IoT systems are suitable for solutions based on wireless sensor networks, in which the data involved
is big and the analysis requirements are computationally intensive.
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.
 Data is stored in the cloud and application is cloud-based.
 The analytics component analyzes the data and stores 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 nodes and sends control commands to the nodes.

3.Explain about Domains of IOT?


o Smart Lighting
o Smart Appliances
o Intrusion Detection o Smoke / Gas Detectors

Home Automation Smart Lighting : Smart lighting achieve energy savings by sensing the human movements
and their environments and controlling the lights accordingly.
Key enabling technologies for smart lighting include :
- Solid state lighting (such as LED lights) - IP-enabled lights  Wireless-enabled and Internet connected lights can
be controlled remotely from IoT applications such as a mobile or web application.
Home Automation Smart Appliances :
Smart appliances make the management easier and provide status information of appliances to the users remotely.
E.g: smart washer/dryer that can be controlled remotely and notify when the washing/drying cycle is complete. •
OpenRemote is an open source automation platform for smart home and building that can control various
appliances using mobile and web applications.
It comprises of three components: - a Controller  manages scheduling and runtime integration between
devices. - a Designer  allows to create both configuration for the controller and user interface designs. - Control
Panel  allows to interact with devices and control them.
Home Automation Intrusion Detection : Home intrusion detection systems use security cameras and sensors to
detect intrusions and raise alerts. The form of the alerts can be in form: - SMS - Email - Image grab or a short
video clip as an email attachment .
Home Automation Smoke / Gas Detectors : Smoke detectors are installed in homes and buildings to detect
smoke that is typically an early sign of fire. It uses optical detection, ionization or air sampling techniques to
detect smoke .
The form of the alert can be in form : Signals that send to a fire alarm system .Gas detector can detect the presence
of harmful gases such as carbon monoxide (CO), liquid petroleum gas (LPG), etc. . Cities IoT applications for
smart cities:
1. Smart Parking
2. Smart Lighting for Road
3. Smart Road
4. Structural Health Monitoring
5. Surveillance
6. Emergency Response
Cities Smart Parking :
Finding the parking space in the crowded city can be time consuming and frustrating • Smart parking makes the
search for parking space easier and convenient for driver. • It can detect the number of empty parking slots and
send the information over the Internet to the smart parking applications which can be accessed by the drivers using
their smartphones, tablets, and in car navigation systems. Sensors are used for each parking slot to detect whether
the slot is empty or not, and this information is aggregated by local controller and then sent over the Internet to
database.
Cities Smart Lighting for Roads :
It can help in saving energy Smart lighting for roads allows lighting to be dynamically controlled and also
adaptive to ambient conditions. Smart light connected to the Internet can be controlled remotely to configure
lighting schedules and lighting intensity. Custom lighting configurations can be set for different situations such as
a foggy day, a festival, etc.
Cities Smart Roads : Smart Roads provides 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
safer and help in reducing traffic jams . Information sensed from the roads can be communicated via internet to
cloud-based applications and social media and disseminated to the drivers who subscribe to such applications.
Cities Structural Health Monitoring :
It uses a network of sensors to monitor the vibration levels in the structures such as bridges and buildings. The
data collected from these sensors is analyzed to assess the health of the structures. By analyzing the data it is
possible to detect cracks and mechanical breakdowns, locate the damages to a structure and also calculate the
remaining life of the structure. Using such systems, advance warnings can be given in the case of imminent failure
of the structure
Cities Surveillance:
Surveillance of infrastructure, public transport and events 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
scalable storage solutions. Cloud-based video analytics applications can be developed to search for patterns of
specific events from the video feeds.
Cities Emergency Response : IoT systems can be used for monitoring the critical infrastructure cities such as
buildings, gas, and water pipelines, public transport and power substations. IoT systems for critical infrastructure
monitoring enable aggregation and sharing of information collected from lager number of sensors. Using cloud-
based architectures, multi-modal information such as sensor data, audio, video feeds can be analyzed I near real-
time to detect adverse events. The alert can be in the form : Alerts sent to the public. Re-rerouting of traffic
.Evacuations of the affected area.
Environment IoT applications for smart environments:
1. Weather Monitoring
2. Air Pollution Monitoring
3. Noise Pollution Monitoring
4. Forest Fire Detection
5. River Flood Detection

Environment Weather Monitoring :


It collects data from a number of sensor attached such as temperature, humidity, pressure, etc and send the data to
cloud-based applications and store back-ends. The data collected in the cloud can then be analyzed and visualized
by cloud-based applications. Weather alert can be sent to the subscribed users from such applications. AirPi is a
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.
Environment Air Pollution Monitoring. IoT based air pollution monitoring system can monitor emission of
harmful gases by factories and automobiles using gaseous and meteorological sensors. The collected data can be
analyzed to make informed decisions on pollutions control approaches.
Environment Noise Pollution Monitoring :
Noise pollution monitoring can help in generating noise maps for cities. It can help the policy maker in making
policies to control noise levels near residential areas, school and parks. It uses a number of noise monitoring
stations that are deployed at different places in a city. The data on noise levels from the stations is collected on
servers or in the cloud and then the collected data is aggregate to generate noise maps.
Environment Forest Fire Detection: IoT based forest fire detection system use a number of monitoring nodes
deployed at different location in a forest. • Each monitoring node collects measurements on ambient condition
including temperature, humidity, light levels, etc. • Early detection of forest fires can help in minimizing the
damage.
Environment River Flood Detection : IoT based river flood monitoring system uses a number of sensor nodes
that monitor the water level using ultrasonic sensors and flow rate using velocity sensors. • Data from these
sensors is aggregated in a server or in the cloud, monitoring applications raise alerts when rapid increase in water
level and flow rate is detected.
Energy IoT applications for smart energy systems:
1. Smart Grid
2. Renewable Energy Systems
3. Prognostics
4.Energy Smart Grids
Smart grid:
It technology provides predictive information and recommendation s to utilize, their suppliers, and their customers
on how best to manage power. Smart grid collect the data regarding : - Electricity generation - Electricity
consumption - Storage - Distribution and equipment health data By analyzing the data on power generation,
transmission and consumption of smart grids can improve efficiency throughout the electric system. Storage
collection and analysis of smarts grids data in the cloud can help in dynamic optimization of system operations,
maintenance, and planning. Cloud-based monitoring of smart grids data can improve energy usage usage levels via
energy feedback to users coupled with real-time pricing information. Condition monitoring data collected from
power generation and transmission systems can help in detecting faults and predicting outages.
Energy 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.
IoT based systems integrated with the transformer at the point of interconnection measure the electrical variables
and how much power is fed into the grid . To ensure the grid stability, one solution is to simply cut off the
overproductions.
Energy Prognostics: IoT based prognostic real-time health management systems can predict performance of
machines of energy systems by analyzing the extent of deviation of a system from its normal operating profiles. In
the system such as power grids, real time information is collected using specialized electrical sensors called Phasor
Measurement Units (PMU) Analyzing massive amounts of maintenance data collected from sensors in energy
systems and equipment can provide predictions for impending failures. OpenPDC is a set of applications for
processing of streaming time-series data collected from Phasor Measurements Units (PMUs) in real-time.
Logistic IoT applications for smart logistic systems:
1. Fleet Tracking
2. Shipment Monitoring
3. Remote Vehicle Diagnostics
1. Logistics Fleet Tracking - Vehicle fleet tracking systems use GPS technology to track the locations of the
vehicles in the real- time. - Cloud-based fleet tracking systems can be scaled up on demand to handle large number
of vehicles, - The vehicle locations and routers data can be aggregated and analyzed for detecting bottlenecks I the
supply chain such as traffic congestions on routes, assignments and generation of alternative routes, and supply
chain optimization - Paper: - A Fleet Monitoring System for Advanced Tracking of commercial Vehicles [IEEE
International Conference in Systems, Man and Cybernetics, 2006]  provided a system that can analyze messages
sent from the vehicles to identify unexpected incidents and discrepancies between actual and planned data, so that
remedial actions can be taken.
Logistics Shipment Monitoring : Shipment monitoring solutions for transportation systems allow monitoring the
conditions inside containers. - E.g : Containers carrying fresh food produce can be monitored to prevent spoilage
of food. IoT based shipment monitoring systems use sensors such as temperature, pressure, humidity, for instance,
to monitor the conditions inside the containers and send the data to the cloud, where it can be analyzed to detect
food spoilage.
Logistics Remote Vehicle Diagnostics : It can detect faults in the vehicles or warn of impending faults. - These
diagnostic systems use on-board IoT devices for collecting data on vehicle operation such as speed, engine RPM,
coolent temperature, fault code number and status of various vehicle sub- system. - Modern commercial vehicles
support on-board diagnostic (OBD) standard such as OBD-II - OBD systems provide real-time data on the status
of vehicle sub-systems and diagnostic trouble codes which allow rapidly identifying the faults in the vehicle. - IoT
based vehicle diagnostic systems can send the vehicle data to centralized servers or the cloud where it can be
analyzed to generate alerts and suggest remedial actions.
Agriculture IoT applications for smart agriculture:
1. Smart Irrigation
2. Green House Control
Agriculture Smart Irrigation - Smart irrigation system can improve crop yields while saving water. - Smart
irrigation systems use IoT devices with soil moisture sensors to determined the amount of moisture on the soil and
release the flow of the water through the irrigation pipes only when the moisture levels go below a predefined
threshold. - It also collect moisture level measurements on the server on in the cloud where the collected data can
be analyzed to plan watering schedules. - Cultivar’s RainCould is a device for smart irrigation that uses water
valves, soil sensors, and a WiFi enabled programmable computer.
Agriculture Green House Control - It controls temperature, humidity, soil, moisture, light, and
carbon dioxide level that are monitored by sensors and climatological conditions that are controlled automatically
using actuation devices. - IoT systems play an importance role in green house control 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.

UNIT-II

2 Mark Questions
1.What is M2M?
Machine-to-Machine (M2M) • An M2M area network comprises of machines (or M2M nodes) which have
embedded hardware modules for sensing, actuation and communication. Various communication protocols can be
used for M2M local area networks such as ZigBee, Bluetooh, ModBus, M-Bus, Wirless M-Bus, Power Line
Communication (PLC), 6LoWPAN, IEEE 802.15.4, etc.
2.Difference between M2M and Iot?
Difference between IoT and M2M :
Hardware vs Software Emphasis
• While the emphasis of M2M is more on hardware with embedded modules, the emphasis of IoT is more on software.
• Data Collection & Analysis :
M2M data is collected in point solutions and often in on-premises storage infrastructure. In contrast to M2M, the data
in IoT is collected in the cloud (can be public, private or hybrid cloud).
Applications: M2M data is collected in point solutions and can be accessed by on-premises applications such as
diagnosis applications, service management applications, and on- premisis enterprise applications.
• IoT data is collected in the cloud and can be accessed by cloud applications such as analytics applications, enterprise
applications, remote diagnosis and management applications, etc.
3.What are the two types of networking software?
1. SDN- Software-Defined Networking
2. NFV- Network Function Virtualization.
4. Need for IoT Systems Management?
• Automating Configuration
• Monitoring Operational & Statistical Data
• Improved Reliability
• System Wide Configurations
• Multiple System Configurations
• Retrieving & Reusing Configurations
5.Discuss about SNMP?
Simple Network Management Protocol (SNMP) • SNMP is a well-known and widely used network management
protocol that allows monitoring and configuring network devices such as routers, switches, servers, printers, etc.
6.Network Operator Requirements ?

• Ease of use • Distinction between configuration and state data • Fetch configuration and state data separately •
Configuration of the network as a whole • Configuration transactions across devices • Configuration deltas • Dump and restore
configurations • Configuration validation • Configuration database schemas • Comparing configurations • Role-based access
control • Consistency of access control lists: • Multiple configuration sets • Support for both data-oriented and task- oriented
access control.

7.About NETCONF ?

• Network Configuration Protocol (NETCONF) is a session-based network management protocol. NETCONF


allows retrieving state or configuration data and manipulating configuration data on network devices .

8.About YANG ?

YANG is a data modeling language used to model configuration and state data manipulated by the NETCONF
protocol ,YANG modules contain the definitions of the configuration data, state data, RPC calls that can be issued and the
format of the notifications.

Long Answers

1..Explain about SDN and NFV in detail with diagram?

• Software-Defined Networking (SDN) is a networking architecture that separates the control plane from the data
plane and centralizes the network controller.

• Software-based SDN controllers maintain a unified view of the network and make confi guration, management
and provisioning simpler. • The underlying infrastructure in SDN uses simple packet forwarding hardware as
opposed to specialized hardware in conventional networks.
Key elements of SDN : Centralized Network Controller With decoupled control and data planes and centralized
network controller, the network administrators can rapidly configure the network. , Programmable Open APIs

• SDN architecture supports programmable open APIs for interface between the SDN application and control layers
(Northbound interface). Standard Communication Interface (OpenFlow) SDN architecture uses a standard
communication interface between the control and infrastructure layers (Southbound interface). • OpenFlow, which
is defined by the Open Networking Foundation (ONF) is the broadly accepted SDN protocol for the Southbound
interface.

NFV:

NFV • Network Function Virtualization (NFV) is a technology that leverages virtualization to consolidate the
heterogeneous network devices onto industry standard high volume servers, switches and storage. • NFV is
complementary to SDN as NFV can provide the infrastructure on which SDN can run.

Key elements of NFV • Virtualized Network Function (VNF): • VNF is a software implementation of a network
function which is capable of running over the NFV Infrastructure (NFVI). •

NFV Infrastructure (NFVI): • NFVI includes compute, network and storage resources that are virtualized. • NFV
Management and Orchestration: • NFV Management and Orchestration focuses on all virtualization-specific
management tasks and covers the orchestration and life-cycle management of physical and/or software resources
that support the infrastructure virtualization, and the life-cycle management of VNFs.
3. Explain about NETCONF in detail with diagram?

• Network Configuration Protocol (NETCONF) is a session-based network management protocol. NETCONF


allows retrieving state or configuration data and manipulating configuration data on network devices .

NETCONF • NETCONF works on SSH transport protocol. • Transport layer provides end-to-end connectivity and
ensure reliable delivery of messages. • NETCONF uses XML-encoded Remote Procedure Calls (RPCs) for framing
request and response messages. • The RPC layer provides mechanism for encoding of RPC calls and notifications. •
NETCONF provides various operations to retrieve and edit configuration data from network devices. • The Content
Layer consists of configuration and state data which is XML-encoded. • The schema of the configuration and state
data is defined in a data modeling language called YANG. • NETCONF provides a clear separation of the
configuration and state data. • The configuration data resides within a NETCONF configuration datastore on the
server.

3. Explain about YANG in detail with diagram?

YANG is a data modeling language used to model configuration and state data manipulated by the NETCONF
protocol • YANG modules contain the definitions of the configuration data, state data, RPC calls that can be issued
and the format of the notifications. • YANG modules defines the data exchanged between the NETCONF client
and server. • A module comprises of a number of 'leaf' nodes which are organized into a hierarchical tree structure.
• The 'leaf' nodes are specified using the 'leaf' or 'leaf-list' constructs. • Leaf nodes are organized using 'container'
or 'list' constructs. • A YANG module can import definitions from other modules. • Constraints can be defined on
the data nodes, e.g. allowed values. • YANG can model both configuration data and state data using the 'config'
statement.

YANG Module Example : This YANG module is a YANG version of the toaster MIB • The toaster YANG
module begins with the header information followed by identity declarations which define various bread types. •
The leaf nodes (‘toasterManufacturer’, ‘toasterModelNumber’ and oasterStatus’) are defined in the ‘toaster’
container. • Each leaf node definition has a type and optionally a description and default value. • The module has
make-toast’ and ‘cancel-toast’.

4. IOT System Management with NETCONG_YANG?

IoT Systems Management with NETCONF -YANG are :

Management System , Management API , Transaction Manager, Rollback Manager

Data Model Manager, Configuration Validator, Configuration Database

Configuration API, Data Provider API.


.

Unit-3

Short Answers

1. Brief about Python?

Python is a general-purpose high level programming language and suitable for providing a solid foundation to
thereader in the area of cloud computing.

The main characteristics of Python are:

Multi-paradigm programming language , Python supports more than one programming paradigms including object-
oriented programming and structured programming , Interpreted Language , Python is an interpreted language and
does not require an explicit compilation step. The Python interpreter executes the program source code directly,
statement by statement, as a processor or scripting engine does. , Interactive Language , Python provides an
interactive mode in which the user can submit commands at the Python prompt and interact with the interpreter
directly.
2. List the benefits of python?

• Easy-to-learn, read and maintain , Python is a minimalistic language with relatively few keywords, uses English
keywords and has fewer syntactical constructions as compared to other languages. Reading Python programs feels
like English with pseudo-code like constructs. Python is easy to learn yet an extremely powerful language for a
wide range of applications. , Object and Procedure Oriented , Python supports both procedure-oriented
programming and object-oriented programming. Procedure oriented paradigm allows programs to be written around
procedures or functions that allow reuse of code.

3. What are the ways to download python?

1)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

2) Linux #Install Dependencies

sudo apt-get install build-essential

sudo apt-get install libreadline-gplv2-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

4.Type conversion with examples in python?

Type Conversions :Convert one data type to another data type is called Type conversion.

#Convert to string

>>>a=10000 >>>

str(a) ’10000’

#Convert to int

>>>b="2013"

>>>int(b) 2013

#Convert to float
>>>float(b) 2013.0

#Convert to long

>>>long(b) 2013L

#Convert to list

>>>s="aeiou"

>>>list(s) [’a’, ’e’, ’i’, ’o’, ’u’]

#Convert to set

>>>x=[’mango’,’apple’,’banana’,’mango’,’banana’] >>>set(x) set([’mango’, ’apple’, ’banana’]) •

5. What is Modules in python?

• Python allows organizing the program code into different modules which improves the code readability and
management. A module is a Python file that defines some functionality in the form of functions or classes.
Modules can be imported using the import keyword.

3.List the data types used in python with examples?

1)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

>>>a=5

>>>type(a) <type ’int’>

#Floating Point

>>>b=2.5 >>>

type(b) <type ’float’>

#Long

>>>x=9898878787676L

>>>type(x) <type ’long’>

#Complex

>>>y=2+5j >>>y (2+5j)

>>>type(y) <type ’complex’>

>>>y.real 2 >>>y.imag 5
#Addition

>>>c=a+b

>>>c 7.5

>>>type(c)

<type ’float’>

#Subtraction

>>>d=a-b >>>d 2.5

>>>type(d)

<type ’float’>

#Multiplication

>>>e=a*b

>>>e 12.5

>>>type(e)

<type ’float’>

#Division

>>>f=b/a >>>f 0.5

>>>type(f)

<type float’>

#Power

>>>g=a**2

>>>g 25

2.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

>>>s="Hello World!"

>>>type(s) <type ’str’>

#String concatenation

>>>t="This is sample program."


>>>r = s+t

>>>r ’Hello World!This is sample program.’

#Get length of string

>>>len(s) 12

#Convert string to integer

>>>x="100"

>>>type(s)

<type ’str’>

>>>y=int(x)

>>>y 100

#Print string

>>>print s Hello World!

#Formatting output

>>>print "The string (The string (Hello World!) has 12 characters

#Convert to upper/lower case

>>>s.upper() ’HELLO WORLD!’

>>>s.lower() ’hello world!’

#Accessing sub-strings

>>>s[0] ’H’ >>>s[6:] ’World!’

>>>s[6:-1] ’World’

#strip:

Returns a copy of the string with the

#leading and trailing characters removed.

>>>s.strip("!") ’Hello World’

3.Lists

List a compound data type used to group together other values. List items need not all have the
same type. A list contains items separated by commas and enclosed within square brackets

. #Create List

>>>fruits=[’apple’,’orange’,’banana’,’mango’]
>>>type(fruits) <type ’list’>

#Get Length of List

>>>len(fruits) 4

#Access List Elements

>>>fruits[1] ’orange’

>>>fruits[1:3] [’orange’, ’banana’]

>>>fruits[1:] [’orange’, ’banana’, ’mango’]

#Appending an item to a list

>>>fruits.append(’pear’)

>>>fruits [’apple’, ’orange’, ’banana’, ’mango’, ’pear’]

#Removing an item from a list

>>>fruits.remove(’mango’)

>>>fruits [’apple’, ’orange’, ’banana’, ’pear’]

#Inserting an item to a list

>>>fruits.insert(1,’mango’)

>>>fruits [’apple’, ’mango’, ’orange’, ’banana’, ’pear’]

#Combining lists

>>>vegetables=[’potato’,’carrot’,’onion’,’beans’,’r adish’]

>>>vegetables [’potato’, ’carrot’, ’onion’, ’beans’, ’radish’]

>>>eatables=fruits+vegetables

>>>eatables [’appl e’, ’mang o’, ’orang e’, ’banan a’, ’pear’, ’potato’, ’carrot’, ’onion’, ’beans’,
’radish’]

#Mixed data types in a list

>>>mixed=[’data’,5,100.1,8287398L]

>>>type(mixed) <type ’list’>

>>>type(mixed[0]) <type ’str’>

>>>type(mixed[1]) <type ’int’>

>>>type(mixed[2])

<type ’float’>
>>>type(mixed[3]) <type ’long’>

#Change individual elements of a list

>>>mixed[0]=mixed[0]+" items"

>>>mixed[1]=mixed[1]+1

>>>mixed[2]=mixed[2]+0.05

>>>mixed [’data items’, 6, 100.14999999999999, 8287398L]

#Lists can be nested

>>>nested=[fruits,vegetables]

>>>nested [[’apple’, ’mango’, ’orange’, ’banana’, ’pear’],

[’potato’, ’carrot’, ’onion’, ’beans’, ’radish’]]

4.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.

#Create a Tuple

>>>fruits=("apple","mango","banana","pineapple")

>>>fruits (’apple’, ’mango’, ’banana’, ’pineapple’)

>>>type(fruits) <type ’tuple’>

#Get length of tuple

>>>len(fruits) 4

#Get an element from a tuple

>>>fruits[0] ’apple’

>>>fruits[:2] (’apple’, ’mango’)

#Combining tuples

>>>vegetables=(’potato’,’carrot’,’onion’,’radish’)

>>>eatables=fruits+vegetables

>>>eatables (’apple’, ’mango’, ’banana’, ’pineapple’, ’potato’, ’carrot’, ’onion’, ’radish’)

4.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
>>>student={’name’:’Mary’,’id’:’8776’,’major’:’CS’}

>>>student {’major’: ’CS’, ’name’: ’Mary’, ’id’: ’8776’}

>>>type(student) <type ’dict’>

#Get length of a dictionary

>>>len(student) 3

#Get the value of a key in dictionary

>>>student[’name’] ’Mary’

#Get all items in a dictionary

>>>student.items() [(’gender’, ’female’), (’major’, ’CS’), (’name’, ’Mary’), (’id’, ’8776’)] #Get all
keys in a dictionary

>>>student.keys() [’gender’, ’major’, ’name’, ’id’]

#Get all values in a dictionary

>>>student.values() [’female’, ’CS’, ’Mary’, ’8776’]

#Add new key-value pair

>>>student[’gender’]=’female’

>>>student {’gende r’: ’female’, ’major’: ’CS’, ’name’: ’Mary’, ’id’: ’8776’}

#A value in a dictionary can be another dictionary


>>>student1={’name’:’David’,’id’:’9876’,’major’:’ECE’}

>>>students={’1’: student,’2’:student1}

>>>students {’1’: {’gende r’: ’female’, ’major’: ’CS’, ’name’: ’Mary’, ’id’: ’8776’}, ’2’: {’
major’: ’ECE’, ’name’: ’David’, ’id’: ’9876’}}

#Check if dictionary has a key

>>>student.has_key(’name’) True

>>>student.has_key(’grade’) False

4.Explain in detail about modules with examples?

Modules :

• Python allows organizing the program code into different modules which improves the code readability and
management. A module is a Python file that defines some functionality in the form of functions or classes. Modules
can be imported using the import keyword. Modules to be imported must be present in the search path.

#student module - saved as student.py


def average Grade(students):
sum = 0.0 for key in students: sum = sum + students[key]['grade']
average = sum/len(students) return average
def print Records(students):
print "There are %d students" %(len(students))
i=1 for key in students:
print "Student-%d: " % (i)
print "Name: " + students[key]['name']
print "Grade: " + str(students[key]['grade']) i = i+1

#Using student module

>>>import student
>>>students = '1': 'name': 'Bob', 'grade': 2.5, '2': 'name': 'Mary', 'grade': 3.5, '3': 'name': 'David', 'grade': 4.2, '4':
'name': 'John', 'grade': 4.1, '5': 'name': 'Alex', 'grade': 3.8
>>>student.print Records(students)
There are 5 students Student-1: Name: Bob Grade: 2.5 Student-2: Name: David Grade: 4.2 Student-3: Name: Mary
Grade: 3.5 Student-4: Name: Alex Grade: 3.8 Student-5: Name: John Grade: 4.1
>>>avg = student. Average Grade(students)
>>>print "The average garde is: %0.2f" % (avg) 3.62
# Importing a specific function from a module
>>>from student import average Grade
# Listing all names defines in a module
>>>dir(student)

5. Explain about File Handling in python?

File Handling :
Python allows reading and writing to files using the file object.
The open(filename, mode) function is used to get a file object.
The mode can be read (r), write (w), append (a), read and write (r+ or w+), read-binary (rb), write-binary (wb), etc.
After the file contents have been read the close function is called which closes the file object.

# Example of reading line by line


>>>fp = open('file1.txt','r')
>>>print "Line-1: " + fp.readline()
Line-1: Python supports more than one programming paradigms.
>>>print "Line-2: " + fp.readline()
Line-2: Python is an interpreted language.
>>>fp.close() # Example of reading an entire file
>>>fp = open('file.txt','r')
>>>content = fp.read()
>>>print content This is a test file.
>>>fp.close()

# Example of reading lines in a loop


>>>fp = open(’file1.txt’,’r’)
>>>lines = fp.readlines()
>>>for line in lines: print line Python supports more than one programming paradigms
# Example of seeking to a certain position
>>>fp = open('file.txt','r')
>>>fp.seek(10,0)
>>>content = fp.read(10)
>>>print content ports more
>>>fp.close()

# Example of reading a certain number of bytes


>>>fp = open('file.txt','r')
>>>fp.read(10) 'Python sup'
>>>fp.close()

# Example of getting the current position of read


>>>fp = open('file.txt','r')
>>>fp.read(10) 'Python sup'
>>>currentpos = fp.tell >>>
print currentpos <built-in method tell of file object at 0x0000000002391390>
>>>fp.close()

# Example of writing to a file


>>>fo = open('file1.txt','w')
>>>content='This is an example of writing to a file in Python.' >>>
fo.write(content)
>>>fo.close()

6.List the python packages?


Python Packages of Interest

• JSON :
JavaScript Object Notation (JSON) is an easy to read and write data-interchange format.
JSON is used as an alternative to XML and is is easy for machines to parse and generate.
JSON is built on two structures - a collection of name-value pairs (e.g. a Python dictionary) and ordered lists of
values (e.g.. a Python list).

• XML :
XML (Extensible Markup Language) is a data format for structured document interchange.
The Python minidom library provides a minimal implementation of the Document Object Model interface and has
an API similar to that in other languages.

HTTPLib & URLLib


HTTPLib2 and URLLib2 are Python libraries used in network/internet programming

SMTPLib : Simple Mail Transfer Protocol (SMTP) is a protocol which handles sending email and routing e-mail
between mail servers.
The Python smtplib module provides an SMTP client session object that can be used to send email.

NumPy :
NumPy is a package for scientific computing in Python. NumPy provides support for large multi-dimensional
arrays and matrices • Scikit-learn • Scikit-learn is an open source machine learning library for Python that provides
implementations of various machine learning algorithms for classification, clustering, regression and dimension
reduction problems.

Unit-4

Short Questions

1.What is an 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.
2. Basic building blocks of an IoT Device ?

• 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 • actions upon the physical entities in the vicinity of the
device. • 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 & Processing • Analysis and processing modules are responsible for making sense of the collected data.

3. Brief about Raspberry pi?

Raspberry Pi is a low-cost mini-computer with the physical size of a credit card. 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.

4. Explain about Raspberry Pi Interfaces?

The serial interface on Raspberry Pi has receive (Rx) and transmit (Tx) pins for communication with serial
peripherals. • SPI • Serial Peripheral Interface (SPI) is a synchronous serial data protocol used for communicating
with one or more peripheral devices. • I2C • The I2C interface pins on Raspberry Pi allow you to connect hardware
modules. I2C interface allows synchronous data transfer with just two pins - SDA (data line) and SCL (clock line).

Long questions
1. Raspberry Pi is a low-cost mini-computer with the physical size of a credit card. 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.

Here are the various components on the Raspberry Pi board:

• ARM CPU/GPU -- This is a Broadcom BCM2835 System on a Chip (SoC) that's made up of an ARM
central processing unit (CPU) and a Videocore 4 graphics processing unit (GPU). The CPU handles all the
computations that make a computer work (taking input, doing calculations and producing output), and the
GPU handles graphics output.

• GPIO -- These are exposed general-purpose input/output connection points that will allow the real
hardware hobbyists the opportunity to tinker.

• RCA -- An RCA jack allows connection of analog TVs and other similar output devices.

• Audio out -- This is a standard 3.55-millimeter jack for connection of audio output devices such as
headphones or speakers. There is no audio in.

• LEDs -- Light-emitting diodes, for all of your indicator light needs.

• USB -- This is a common connection port for peripheral devices of all types (including your mouse and
keyboard). Model A has one, and Model B has two. You can use a USB hub to expand the number of ports
or plug your mouse into your keyboard if it has its own USB port.
• HDMI -- This connector allows you to hook up a high-definition television or other compatible device
using an HDMI cable.

• Power -- This is a 5v Micro USB power connector into which you can plug your compatible power supply.

• SD cardslot -- This is a full-sized SD card slot. An SD card with an operating system (OS) installed is
required for booting the device. They are available for purchase from the manufacturers, but you can also
download an OS and save it to the card yourself if you have a Linux machine and the wherewithal.

• Ethernet -- This connector allows for wired network access and is only available on the Model B.

2. Write a python program Interfacing LED and switch with Raspberry Pi?

from time import sleep


import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
#Switch Pin GPIO.setup(25, GPIO.IN)
#LED Pin GPIO.setup(18, GPIO.OUT) state=false
def toggleLED(pin): state = not state
GPIO.output(pin, state)
while True: try: if (GPIO.input(25) == True): toggleLED(pin)
sleep(.01)
except KeyboardInterrupt: exit()

3. Blinking of led python program?

import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library


from time import sleep # Import the sleep function from the time module
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW) # Set pin 8 to be an output pin and set initial value to low (off)
while True: # Run forever
GPIO.output(8, GPIO.HIGH) # Turn on
sleep(1) # Sleep for 1 second
GPIO.output(8, GPIO.LOW) # Turn off
sleep(1) # Sleep for 1 second

4.Explain about the raspberry pi pins with diagram?

Note that each of the 40 pins has a "physical" pin number: 1, 2, 3, 4 . . . as well as a "BCM" designator like: GPI02,
GPI027, ID_SD . . . BCM refers to the Broadcom processor chip. As you will see, you can use the pins by their
physical board number or the BCM number. There are also a few specific pins reserved exclusively for power: +5v,
+3.3v and Ground (and not programmable).

The programmable pins may be referenced by either the physical pin number on the board or by the BCM number
(or simply GPIO number) at the end of the designator name (i.e. GPIO27). This choice is made in the initial
configuration during program setup.
Board vs BCM Numbering
Some examples of board vs BCM/GPIO numbering

Board Pin Number BCM/GPIO Name BCM Pin Number

3 GPIO2 2

5 GPIO3 3

7 GPIO4 4

8 GPIO14 14

The programmable pins may be referenced by either the physical pin number on the board or by the BCM number
(or simply GPIO number) at the end of the designator name (i.e. GPIO27). This choice is made in the initial
configuration during program setup.

It is important to understand that board numbering and BCM numbering use the same physical set of pins, but they
are numbered differently. For example, board pin number 3 is the same physical pin as BCM pin number 2 (GPIO2)
- see the GPIO Pinout image above.

Unit-5

Short Answers

1.What is WAMP for IoT?


• Web Application Messaging Protocol (WAMP) is a sub-protocol of Websocket which provides publish-subscribe
and remote procedure call (RPC) messaging patterns.

• 2. List of Amazon Web Services?


• Amazon EC2
• Amazon RDS
• Amazon S3
• Amazon Cloud Front
• Amazon VPC
• Amazon SNS
• Amazon Elastic Beanstalk
• Amazon Lambda.

• 3.what is cloud services?


A cloud service is any service made available to users on demand via the Internet from a cloud
computing provider's servers as opposed to being provided from a company's own on-premises servers. Cloud
services are designed to provide easy, scalable access to applications, resources and services, and are fully managed
by a cloud services provider.

• 4.Essential characteristics of cloud services?


• On-demand self-service
• Broad network access
• Resource pooling
• Rapid elasticity
• Measured service.

5. What is API?
An API is a set of definitions and protocols for building and integrating application software. API stands for
application programming interface. APIs let your product or service communicate with other products and services
without having to know how they're implemented.

6.What is cloud computing?

cloud computing means storing and accessing data and programs over the Internet instead of your computer's hard
drive. The cloud is just a metaphor for the Internet. When you store data on or run programs from the hard drive,
that's called local storage and computing.

Long questions
1.Explain in detail about WAMP with Diagram?

WAMP –
Transport: Transport is channel that connects two peers.

Session: Session is a conversation between two peers that runs over a transport.

Client: Clients are peers that can have one or more roles.

In publish-subscribe model client can have following roles

Publisher: Publisher publishes events (including payload) to the topic maintained by the Broker.

Subscriber: Subscriber subscribes to the topics and receives the events including the payload.
In RPC model client can have following roles.
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 :


Broker: – Broker: Broker acts as a router and routes messages published to a topic to all subscribers subscribed to
the topic.

In RPC model Router has the role of a Broker:


Dealer: Dealer acts a router and routes RPC calls from the Caller to the Callee and routes results from Callee to
Caller.

Application Code: Application code runs on the Clients (Publisher, Subscriber, Callee or Caller.

WAMP FOR IOT

2.Explain about Django Architecture ?

• Django is Model-Template-View (MTV) framework. 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 of data.

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.) • 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
.
Refer book examples add more screenshot diagrams

3.Explain the Amazon Web Services?

Amazon EC2

Python Example

Boto is a Python package that provides interfaces to Amazon Web Services (AWS)

#Python program for launching an EC2 instance

import boto.ec2 from time

import sleep ACCESS_KEY="<enter access key>"

SECRET_KEY="<enter secret key>"

REGION="us-east-1" AMI_ID = "ami-d0f89fb9"


EC2_KEY_HANDLE = "<enter key handle>" INSTANCE_TYPE="t1.micro"
SECGROUP_HANDLE="default"

conn = boto.ec2.connect_to_region(REGION, aws_access_key_id=ACCESS_KEY,


aws_secret_access_key=SECRET_KEY)

reservation = conn.run_instances(image_id=AMI_ID, key_name=EC2_KEY_HANDLE,


instance_type=INSTANCE_TYPE, security_groups = [ SECGROUP_HANDLE, ] )

connection to EC2 service is fi rst established by calling boto.ec2.connect_to_region.

The EC2 region, AWS access key and AWS secret key are passed to this function.

After connecting to EC2 , a new instance is launched using the conn.run_instances function.

The AMI-ID, instance type, EC2 key handle and security group are passed to this function

2. Amazon AutoScaling

Python Example

#Python program for creating an AutoScaling group (code excerpt)

import boto.ec2.autoscale :

print "Connecting to Autoscaling Service" conn =boto.ec2.autoscale.connect_to_region(REGION,


aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY)

print "Creating launch configuration"

lc = LaunchConfiguration(name='My -Launch-Config-2', image_id=AMI_ID,


key_name=EC2_KEY_HANDLE, instance_type=INSTANCE_TYPE, security_groups = [
SECGROUP_HANDLE, ])

conn.create_launch_configuration(lc)

print "Creating auto-scaling group"

ag = AutoScalingGroup(group_name='My -Group', availability_zones=['us -east-1b'],


launch_config=lc, min_size=1, max_size=2, connection=conn)

conn.create_auto_scaling_group(ag)

• AutoScaling Service

A connection to AutoScaling service is first established by calling


boto.ec2.autoscale.connect_to_region function.

Launch Configuration : After connecting to AutoScaling service, a new launch configuration is


created by calling conn.create_launch_con f iguration.
Launch configuration contains instructions on how to launch new instances including the AMI -ID,
instance type, security groups, etc.

AutoScaling Group

After creating a launch configuration, it is then associated with a new AutoScaling group.
AutoScaling group is created by calling conn.create_auto_scaling_group. The settings for
AutoScaling group such as the maximum and minimum number of instances in th e group, the
launch configuration, availability zones, optional load balancer to use with the group, etc.

3.Amazon S3

Python Example

# Python program for uploading a file to an S3 bucket

import boto.s3 conn = boto.connect_s3(aws_access_key_id='<enter>',


aws_secret_access_key='<enter>')

def percent_cb(complete, total):

print ('.') def upload_to_s3_bucket_path(bucketname, path, filename):

mybucket = conn.get_bucket(bucketname)

fullkeyname=os.path.join(path,filename)

key = mybucket.new_key(fullkeyname)

key.set_contents_from_filename(filename, cb=percent_cb, num_cb=10)

In this example, a connection to S3 service is first established by calling boto.connect_s3


function.
Previous year question paper

You might also like