2. 20EC503PE - INTERNET OF THINGS
Unit-1
INTRODUCTION TO IoT
Internet of Things – characteristics- Physical
Design- Logical Design - IoT Enabling
Technologies - IoT Levels & Deployment
Templates - IoT Platforms Design Methodology.
IOT-T.YUVARAJA 2
3. Internet of Things
• Kevin Ashton Invented the Term
"Internet of Things"
3
IOT-T.YUVARAJA
4. Internet of Things(Definition)
• The Internet of Things (IoT) describes the
network of physical objects—―things‖—that
are embedded with sensors, software, and
other technologies for the purpose of
connecting and exchanging data with
other devices and systems over the
internet.
4
IOT-T.YUVARAJA
6. Characteristics of IoT
1) Dynamic & Self-Adapting
2) Self-Configuring
3) Interoperable Communication Protocols
4) Unique Identity
5) Integrated into Information Network
6
IOT-T.YUVARAJA
7. Characteristics of IoT
1)Dynamic & Self-Adapting
• surveillance camera
• It should be adaptable to work in different
conditions(Normal & Infrared)
• Different(dynamic) light situations (Day &
Night).
7
IOT-T.YUVARAJA
9. Characteristics of IoT
3)Interoperable Communication Protocols
• IoT allows different devices (different in architecture) to
communicate with each other as well as with different
network.
• For ex: MI Phone is able to control the smart AC and
smart TV of different manufacturer.
9
IOT-T.YUVARAJA
10. Characteristics of IoT
4)Unique Identity
• The devices which are connected to the
internet have unique identities
• i.e. IP address
10
IOT-T.YUVARAJA
11. Characteristics of IoT
5)Integrated into Information Network
• The IoT devices are connected to the network to
share some information with other connected
devices.
• The devices can be discovered dynamically in
the network by other devices.
• Eg: If a device has wifi connectivity then that will
be shown to other nearby devices having wifi
connectivity
11
IOT-T.YUVARAJA
13. Physical Design of IoT
• Things/Devices and protocols that are used to
build an IoT system.
• Things/Devices are called Node Devices and
every device has a unique identity that performs
remote sensing, actuating and monitoring work.
• Protocolsestablish communication between
the Node devices and servers over the internet.
13
IOT-T.YUVARAJA
14. Physical Design of IoT
• Things in IoT
• IoT Protocols
14
IOT-T.YUVARAJA
15. Things in IoT
Generic block diagram of an IoT Device
• An IoT device may consist of several
interfaces for connections to other
devices,both wired and wireless. 15
IOT-T.YUVARAJA
16. Things in IoT
IoT Device
Connectivity
Processor
Audio/Video Interfaces
Input/Output interface
Memory Interfaces
Storage Interfaces
Graphics
16
IOT-T.YUVARAJA
20. IoT Protocols
1)Link Layer Protocols:
802.3-Ethernet: IEEE802.3 is collection of wired Ethernet standards
802.3 co-axial cable
802.3i copper twisted pair
802.3j fiber optic
802.3ae Ethernet over fiber
802.11-WiFi: IEEE802.11 is a collection of wireless LAN(WLAN)
communication standards.
802.11a 5GHz band
802.11b 2.4GHz band
802.11g 2.4GHz band
802.11n 2.4/5GHz band
802.11ac 5GHz band
802.11ad 60Ghzband
20
IOT-T.YUVARAJA
21. IoT Protocols
1) Link Layer Protocols:
802.16 - WiMax:
IEEE802.16 is a collection of wireless broadband
standards.
WiMax provide data rates from 1.5 Mb/s to 1Gb/s.
802.15.4- LR-WPAN:
IEEE802.15.4 is a collection of standards for Low
Rate Wireless Personal Area Network(LR-WPAN).
ZigBee
Provides data rate from 40kb/s to250kb/s.
2G/3G/4G-Mobile Communication:
Data rates from 9.6kb/s(2G) to up to100Mb/s(4G) 21
IOT-T.YUVARAJA
22. IoT Protocols
2)Network/Internet Layer Protocols:
• IPv4:
Internet Protocol version 4
32 bit address.
Total= 232addresses
• IPv6:
Internet Protocol version6
uses 128 bit address
Total= 2128 addresses
• 6LOWPAN:
IPv6 over Low power Wireless Personal Area Network
Operates in 2.4 GHz frequency range
Data transfer 250 kb/s.
22
IOT-T.YUVARAJA
24. IoT Protocols
4)Application Layer Protocols:
HTTP:
Hyper Text Transfer Protocol
Follow request- response model
Stateless protocol.
CoAP:
Constrained Application Protocol
M2M applications
Uses client- server architecture.
WebSocket:
Allows full duplex communication over a single socket connection.
MQTT:
Message Queue Telemetry Transport
light weight messaging protocol
publish-subscribe model.
Uses client server architecture.
24
IOT-T.YUVARAJA
25. IoT Protocols
4)Application Layer Protocols:
XMPP:
Extensible Message and Presence Protocol
real time communication and streaming XML data between
network entities.
Support client-server and server-server communication.
DDS:
Data Distribution Service
Device-to-device or machine-to-machine communication.
Uses publish-subscribe model.
AMQP:
Advanced Message Queuing Protocol
Supports both point-to-point and publish-subscribe model.
25
IOT-T.YUVARAJA
26. Logical Design of IoT
1) IoT Functional Blocks
2) IoT Communication Models
3) IoT Communication APIs
26
IOT-T.YUVARAJA
29. IoT functional Blocks
Device :
An IoT system comprises of devices
provide sensing, actuation, monitoring and control
functions.
Communication:
Handles the communication for the IoT system.
Services:
Device monitoring services
Device control services
Data publishing services
Device discovery services
29
IOT-T.YUVARAJA
30. IoT functional Blocks
Management:
provides various functions to govern the IoT system.
Security:
secures the IoT system
providing functions such as
Authentication
Authorization
Message and content integrity
Data security
Application:
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 or
analyze the processed data. 30
IOT-T.YUVARAJA
31. IoT communication models
1) Request-Response communication model
2) Publish-subscribe communication model
3) Push-pull communication model
4) Exclusive-pair communication model
31
IOT-T.YUVARAJA
34. IoT communication models
2)Publish-subscribe communication model
It 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.
34
IOT-T.YUVARAJA
36. IoT communication models
3)Push-pull communication model
Publishers push the data to queues and the consumers
pull the data from the queues.
Publishers do not need to be aware of the consumers.
Queues also act as a buffer
36
IOT-T.YUVARAJA
38. IoT communication models
4)Exclusive-pair communication model
Bi-directional, fully duplex communication model
Once connection is set up it remains open until
the client send a request to close the connection.
Client and server can send messages to each
other after connection setup.
38
IOT-T.YUVARAJA
39. IOT Communication APIs
1) REST-based Communication API
2) Web Socket based communication API
39
IOT-T.YUVARAJA
40. IOT Communication APIs
1)REST-based Communication API
Representational State Transfer (REST)
Request -Response communication model
40
IOT-T.YUVARAJA
41. IOT Communication APIs
1)REST-based Communication API
Client-server
Stateless
Cacheable
Layered system
Uniform interface
Code on demand
41
IOT-T.YUVARAJA
43. IOT Communication APIs
1)REST-based Communication API
• Representational State Transfer (REST) is
a set of architectural principles by which
you can design web services and web
APIs.
• REST APIs follow the request –response
communication model.
43
IOT-T.YUVARAJA
45. IOT Communication APIs
2)Web Socket based communication API
• WebSocket APIs allow bidirectional, full duplex
communication between clients and servers.
• WebSocket APIs follow the exclusive pair
communication model.
Websocket handshake
WebSocket APIs reduce the network traffic and latency
WebSocket is suitable for IoT applications that have low
latency or high throughput requirements.
45
IOT-T.YUVARAJA
47. IoT Enabling Technologies
1) Wireless sensor networks
2) Cloud computing
3) Big Data analytics
4) Embedded systems
5) Communication protocols
47
IOT-T.YUVARAJA
48. IoT Enabling Technologies
1) Wireless Sensor Networks(WSN)
WSN consists of a number of
1)End-nodes
2)Routers
3)coordinator
48
IOT-T.YUVARAJA
49. IoT Enabling Technologies
1) Wireless Sensor Networks(WSN)
• End Nodes sensors attached to them
• RouterRouting the data packets from end-
nodes to the coordinator.
• Coordinator collects the data from all the nodes.
• Coordinator also act as a gateway that connects
the WSN to the internet.
• ProtocolZigbee
49
IOT-T.YUVARAJA
51. IoT Enabling Technologies
Example of WSNs:
Weather Monitoring system
Indoor Air Quality monitoring system
Soil Moisture Monitoring system
Surveillance systems
Health Monitoring systems
51
IOT-T.YUVARAJA
52. IoT Enabling Technologies
1) Wireless sensor networks
2) Cloud computing
3) Big Data analytics
4) Embedded systems
5) Communication protocols
52
IOT-T.YUVARAJA
53. IoT Enabling Technologies
2)Cloud Computing
cloud computing is the delivery of
computing services—including servers,
storage, databases, networking, software,
analytics, and intelligence—over the
Internet (―the cloud‖) to offer faster
innovation, flexible resources, and
economies of scale.
53
IOT-T.YUVARAJA
55. IoT Enabling Technologies
2)Cloud computing
Cloud computing is the delivery of different
services through the Internet, including
data storage, servers, databases,
networking, and software.
Cloud-based storage makes it possible to
save files to a remote database and
retrieve them on demand.
55
IOT-T.YUVARAJA
57. IoT Enabling Technologies
1) Wireless sensor networks
2) Cloud computing
3) Big Data analytics
4) Embedded systems
5) Communication protocols
57
IOT-T.YUVARAJA
58. IoT Enabling Technologies
3)Big Data analytics
Big data refers to large amount of data.
It cannot be stored, processed and
analyzed using traditional database like
(Oracle, MySQL).
58
IOT-T.YUVARAJA
59. IoT Enabling Technologies
3)Big Data analytics
It involve several steps starting from
Data cleaning
Data munging
Data processing
Data visualization
59
IOT-T.YUVARAJA
60. IoT Enabling Technologies
3)Big Data analytics
• Sensor data weather monitoring stations.
• Machine sensor data Industrial and energy
systems
• Health and fitness data
• Data location and tracking of vehicles.
• Data retail inventory monitoring systems.
60
IOT-T.YUVARAJA
62. IoT Enabling Technologies
1) Wireless sensor networks
2) Cloud computing
3) Big Data analytics
4) Embedded systems
5) Communication protocols
62
IOT-T.YUVARAJA
63. IoT Enabling Technologies
4)Embedded systems
Embedded system =Hardware + Software
To perform Specific task
Key components are
Microprocessor or microcontroller
Memory (RAM, ROM, Cache),
Networking units (Ethernet, Wi-Fi adapter),
Input/output units (Display, Keyboard, etc)
storage (flash memory)
They use some special types of processor such as
digital signal processor, graphics processor and
application specific processor). 63
IOT-T.YUVARAJA
64. IoT Enabling Technologies
5)Communication protocols
• Protocol is nothing but rules and
regulations.
• Backbone of the IoT system
• It allow devices to exchange data over
the network.
64
IOT-T.YUVARAJA
67. IoT Levels & Deployment
Templates
• Based upon the number of monitoring
nodes used, type of data base used,
complexity/ simplicity of analysis,
computation there are 6 levels of IoT.
67
IOT-T.YUVARAJA
68. IoT Levels & Deployment
Templates
• Device
• Resources
• Controller Service
• Database
• Web Service
• Analysis Component
• Application
68
IOT-T.YUVARAJA
71. IoT Level-1
• It has single node/device
• Data involved is not big. So, data is stored in
local database.
• It is suitable for modelling design low cost and
low complexity solution.
• Analysis locally.
Eg: Home automation
71
IOT-T.YUVARAJA
73. IoT Level-2
• It has single node/device.
• Data involved is big. So data is stored in cloud.
• It uses cloud based application to visualize data.
• Analysis locally.
Eg: smart irrigation
73
IOT-T.YUVARAJA
75. IoT Level-3
• It has single node/device.
• Data involved is big. So data is stored in
cloud.
• It uses cloud based application to
visualize data.
• Analysis cloud.
Eg:Tracking package handling
75
IOT-T.YUVARAJA
77. IoT Level-4
• It has multiple nodes/devices
• Data involved is big. So data is stored in cloud.
• It uses cloud based application to visualize data.
• Analysis cloud.
• It has two observer nodes i.e local and cloud based.
They can subscribe to and receive information collected
in cloud from IoT device.
• They can process and use those information for various
applications
• Observer node does not perform any control function.
• Analysis cloud.
Eg: Noise monitoring
77
IOT-T.YUVARAJA
79. IoT Level-5
• It has multiple nodes/devices
• One coordinator node for collecting and sending the data
to cloud by controller service.
• Data involved is big. So data is stored in cloud.
• It uses cloud based application to visualize data.
• Suitable for wireless sensor network.
• Analysis cloud.
Eg: Forest Fire Detection
79
IOT-T.YUVARAJA
81. IoT Level-6
• It has multiple independent nodes/devices.
• It has centralized controller which is aware of the status
of all the end nodes and sends control command to the
nodes.
• Data involved is big. So data is stored in cloud.
• It uses cloud based application to visualize data.
• Analysis cloud.
Eg: Weather monitoring and structural health monitoring
81
IOT-T.YUVARAJA
82. 20EC503PE - INTERNET OF THINGS
Unit-2
DOMAIN SPECIFIC IoTs & M2M
Domain Specific IoTs- M2M- Difference
between IoT & M2M- Software Defined
Networking-Network Function Virtualization.
07.08.2023 IOT-T.YUVARAJA 82
83. Domain Specific IoTs
• Home
• Cities
• Environment
• Energy Systems
• Retail
• Logistics
• Industry
• Agriculture
• Health & Lifestyle
83
84. Home Automation
IoT applications for smart homes:
• Smart Lighting
• Smart Appliances
• Intrusion Detection
• Smoke / Gas Detectors
84
122. M2M
• M2M Machine to Machine
• M2M is a direct communication between
devices using wired or wireless
communication channels.
• Two machines ―communicating‖ or
exchanging data, without human
interfacing or interaction.
122
132. Software-Defined Networking
(SDN)
• SDN enables the control and management
of network using software applications.
• Devices are programmed in centrally
controlled manner.
132
141. Network Function Virtualization
(NFV)
• NFV is an approach to networking where
the network entities that traditionally used
dedicated hardware items are now
replaced with computers on which
software runs to provide the same
functionality.
141
142. Network Function Virtualization
(NFV)
• Traditional physical network hardware has
always been difficult to change and
upgrade.
• NFV is a concept that virtualizes major
elements of a network.
• In this way, rather than having a
dedicated item of hardware to provide a
given function, software running on a
computer / server is used.
142
144. Network Function Virtualization
(NFV)
Key elements of NFV:
1)Virtualized Network Function(VNF)
2)NFV Infrastructure(NFVI)
3)NFV Management and Orchestration(NFV-MANO)
144
147. 20EC503PE - INTERNET OF THINGS
Unit-3
IoT LOGICAL DESIGN USING PYTHON
Introduction –Python Data types & Data
structures-Control Flow-Functions-Modules-
Packages-File Handling Classes-Python
Packages of Interest for IoT.
147
148. Python is a general-purpose, high level
and object-oriented programming
language.
Python is an interpreted scripting language
also.
Python is a case-sensitive language
Variable and variable are not the same.
148
149. Characteristics of Python
• Multi-paradigm programming language
• Interpreted Language
• Interactive Language
• Easy-to-learn, read and maintain
• Object and Procedure Oriented
• Extendable
• Scalable
• Portable
• Broad Library Support
149
158. Arithmetic operators
Operator Meaning Example
+ Addition x + y
- Subtraction x - y
* Multiplication x * y
/ Division x / y
% Modulus x % y
// Floor division x // y
** Exponent x ** y
158
159. Arithmetic operators
Example:
x = 15
y = 4
print('x + y =',x+y)
print('x - y =',x-y)
print('x * y =',x*y)
print('x / y =',x/y)
print('x // y =',x//y)
print('x ** y =',x**y)
159
160. Arithmetic operators
Example:
x = 15
y = 4
print('x + y =',x+y)
print('x - y =',x-y)
print('x * y =',x*y)
print('x / y =',x/y)
print('x // y =',x//y)
print('x ** y =',x**y)
160
Output:
x + y =
x - y =
x * y =
x / y =
x // y =
x ** y =
161. Arithmetic operators
Example:
x = 15
y = 4
print('x + y =',x+y)
print('x - y =',x-y)
print('x * y =',x*y)
print('x / y =',x/y)
print('x // y =',x//y)
print('x ** y =',x**y)
161
Output:
x + y = 19
x - y = 11
x * y = 60
x / y = 3.75
x // y = 3
x ** y = 50625
162. Comparison operators
162
Operator Name Example
> Greater than x > y
< Less than x < y
== Equal x == y
!= Not equal x != y
>= Greater than
or equal to
x >= y
<= Less than or
equal to
x <= y
163. Comparison operators
Example:
x = 10
y = 12
print('x > y is',x>y)
print('x < y is',x<y)
print('x == y is',x==y)
print('x != y is',x!=y)
print('x >= y is',x>=y)
print('x <= y is',x<=y)
163
164. Comparison operators
Example:
x = 10
y = 12
print('x > y is',x>y)
print('x < y is',x<y)
print('x == y is',x==y)
print('x != y is',x!=y)
print('x >= y is',x>=y)
print('x <= y is',x<=y)
164
Output:
165. Comparison operators
Example:
x = 10
y = 12
print('x > y is',x>y)
print('x < y is',x<y)
print('x == y is',x==y)
print('x != y is',x!=y)
print('x >= y is',x>=y)
print('x <= y is',x<=y)
165
Output:
x > y is
x < y is
x == y is
x != y is
x >= y is
x <= y is
166. Comparison operators
Example:
x = 10
y = 12
print('x > y is',x>y)
print('x < y is',x<y)
print('x == y is',x==y)
print('x != y is',x!=y)
print('x >= y is',x>=y)
print('x <= y is',x<=y)
166
Output:
x > y is False
x < y is True
x == y is False
x != y is True
x >= y is False
x <= y is True
167. Logical operators
Operator Meaning Example
and True if both the operands are true x and y
or True if either of the operands is true x or y
not
True if operand is false
(complements the operand)
not x
167
168. Logical operators
Example:
x = 5
print('x and y is',x > 3 and x < 10)
print('x or y is',x > 3 or x < 4)
print('not x is',not(x > 3))
168
169. Logical operators
Example:
x = 5
print('x and y is',x > 3 and x < 10)
print('x or y is',x > 3 or x < 4)
print('not x is',not(x > 3))
169
Output:
170. Logical operators
Example:
x = 5
print('x and y is',x > 3 and x < 10)
print('x or y is',x > 3 or x < 4)
print('not x is',not(x > 3))
170
Output:
x and y is
x or y is
not x is
171. Logical operators
Example:
x = 5
print('x and y is',x > 3 and x < 10)
print('x or y is',x > 3 or x < 4)
print('not x is',not(x > 3))
171
Output:
x and y is True
x or y is True
not x is False
172. Logical operators
Example:
x = 15
print('x and y is',x > 3 and x < 10)
print('x or y is',x > 3 or x < 4)
print('not x is',not(x > 3))
172
Output:
x and y is
x or y is
not x is
173. Logical operators
Example:
x = 15
print('x and y is',x > 3 and x < 10)
print('x or y is',x > 3 or x < 4)
print('not x is',not(x > 3))
173
Output:
x and y is False
x or y is True
not x is False
174. Logical operators
Example:
x = 5
print(x > 3 and x < 10)
print(x > 3 or x < 4)
print(not(x > 3))
174
Output:
True
True
False
175. Bitwise Operators
Operator Meaning Example
& Bitwise AND x & y
| Bitwise OR x | y
~ Bitwise NOT ~x
^ Bitwise XOR x ^ y
>>
Bitwise right
shift
x >> 2
<<
Bitwise left
shift
x << 2
175
176. Bitwise Operators
Example:
x = 10
y = 4
print('x & y is', x & y)
print('x | y is ', x | y)
print('~x is', ~x)
print('x ^ y is ', x ^ y)
print('x >> 2 is',x >> 2 )
print('x << 2 is',x << 2)
176
177. Example:
x = 10
y = 4
print('x & y is', x & y)
print('x | y is ', x | y)
print('~x is', ~x)
print('x ^ y is ', x ^ y)
print('x >> 2 is',x >> 2 )
print('x << 2 is',x << 2)
177
Output:
x & y is
x | y is
~x is
x ^ y is
x >> 2 is
x << 2 is
178. Example:
x = 10
y = 4
print('x & y is', x & y)
print('x | y is ', x | y)
print('~x is', ~x)
print('x ^ y is ', x ^ y)
print('x >> 2 is',x >> 2 )
print('x << 2 is',x << 2)
178
Output:
x & y is 0
x | y is 14
~x is -11
x ^ y is 14
x >> 2 is 2
x << 2 is 40
179. Example:
x = 10
y = 4
print('x & y is', x & y)
print('x | y is ', x | y)
print('~x is', ~x)
print('x ^ y is ', x ^ y)
print('x >> 2 is',x >> 2 )
print('x << 2 is',x << 2)
179
Output:
x & y is 0
x | y is 14
~x is -11
x ^ y is 14
x >> 2 is 2
x << 2 is 40
180. Output:
x & y is 0
x | y is 14
~x is -11
x ^ y is 14
x >> 2 is 2
x << 2 is 40
180
181. x & y =
x | y =
~x =
x ^ y =
x >> 2 =
x << 2 =
181
Example:
x = 100000 1010
y = 4 0000 0100
182. x & y = 0000 0000
x | y =
~x =
x ^ y =
x >> 2 =
x << 2 =
182
Example:
x = 100000 1010
y = 4 0000 0100
183. x & y = 0000 0000
x | y = 0000 1110
~x =
x ^ y =
x >> 2 =
x << 2 =
183
Example:
x = 100000 1010
y = 4 0000 0100
184. x & y = 0000 0000
x | y = 0000 1110
~x = 1111 0101
x ^ y =
x >> 2 =
x << 2 =
184
Example:
x = 100000 1010
y = 4 0000 0100
185. x & y = 0000 0000
x | y = 0000 1110
~x = 1111 0101
x ^ y = 0000 1110
x >> 2 =
x << 2 =
185
Example:
x = 100000 1010
y = 4 0000 0100
186. x & y = 0000 0000
x | y = 0000 1110
~x = 1111 0101
x ^ y = 0000 1110
x >> 2 = 0000 0010
x << 2 =
186
Example:
x = 100000 1010
y = 4 0000 0100
187. x & y = 0000 0000
x | y = 0000 1110
~x = 1111 0101
x ^ y = 0000 1110
x >> 2 = 0000 0010
x << 2 = 0010 1000
187
Example:
x = 10 (0000 1010)
y = 4 (0000 0100 )
188. x & y = 0000 0000 0
x | y = 0000 1110 14
~x = 1111 0101-11
x ^ y = 0000 111014
x >> 2 = 0000 00102
x << 2 = 0010 100040
188
Example:
x = 10 (0000 1010)
y = 4 (0000 0100 )
191. Assignment operators
Operator Example Equivalent to
= x = 5 x = 5
+= x += 5 x = x + 5
-= x -= 5 x = x - 5
*= x *= 5 x = x * 5
/= x /= 5 x = x / 5
%= x %= 5 x = x % 5
//= x //= 5 x = x // 5
**= x **= 5 x = x ** 5
&= x &= 5 x = x & 5
|= x |= 5 x = x | 5
^= x ^= 5 x = x ^ 5
>>= x >>= 5 x = x >> 5
<<= x <<= 5 x = x << 5
191
192. Membership operators
Operator Description Example
in True if value/variable is
found in the sequence
x in y
not in True if value/variable is
not found in the sequence
x not in y
192
199. Identity operators
Operator Description Example
is True if both variables are the same object x is y
is not True if both variables are not the same
object
X is not y
199
202. Identity operators
Example:
x1 = 5
y1 = 5
x2 = "Hello"
y2 = "Hello"
print(x1 is not y1)
print(x2 is y2)
Output:
False
True
202
False True
203. Python Data Types & Data
Structures
• Variables can hold values, and every value
has a data-type.
• Python is a dynamically typed language;
hence we do not need to define the type of
the variable while declaring it.
• Python provides us the type() function,
which returns the type of the variable
passed.
203
204. Python Data Types & Data
Structures
Example:
a=10
b="Hi Python"
c = 10.5
print(type(a))
print(type(b))
print(type(c))
204
205. NOTE:
However, in Python 3, the long data type
was removed; no matter how big the integer
is, it will be an int.
205
206. Python Data Types & Data
Structures
• Numbers
• Strings
• Lists
• Tuples
• Dictionaries
• Type Conversion
206
207. Python Data Types & Data
Structures
• Numbers
• Strings
• Lists
• Tuples
• Dictionaries
• Type Conversion
207
208. Numbers
• Number data type is used to store numeric
values.
1)int
2)float
3)complex
208
209. Numbers
Example:
a = 5
b = 2.5
c = 2+5j
print(type(a))
print(type(b))
print(type(c))
209
Output:
<class 'int'>
<class 'float'>
<class 'complex'>
220. 220
Welcome! type is <class 'str'> Length is 8 The string(Welcome!)has 8 characters Upper case is WELCOME! Lower case is welcome
Output:
Welcome!
type is <class 'str'>
Length is 8
The string(Welcome!)has 8 characters
Upper case is WELCOME!
Lower case is welcome!
W
l
come!
come
232. 20EC503PE - INTERNET OF THINGS
Unit-4
IoT PHYSICAL DEVICES AND ENDPOINTS
IoT Device -Building blocks -Raspberry Pi -
Board - Linux on Raspberry Pi - Raspberry Pi
Interfaces -Programming Raspberry Pi with
Python - Other IoT Devices - Arduino.
232
235. Raspberry Pi Interfaces
Serial :
•2 Pins
1) Receive (Rx) Pin
2) Transmit (Tx) Pin
•Communication with serial peripherals.
SPI :
•Serial Peripheral Interface (SPI) is a synchronous serial data protocol used for
communicating with one or more peripheral devices.
•5 Pins
1)MISO (Master in slave out) – Master line for sending data to the peripherals.
2)MOSI (Master out slave in) – Slave line for sending data to the master.
3)SCK (Serial Clock) – Clock generated by master to synchronize data transmission
4)CE0 (Chip Enable 0) – To enable or disable devices
5)CE0 (Chip Enable 1) – To enable or disable devices
235
236. Raspberry Pi Interfaces
I2C :
• I2C Inter Integrated Circuit
• The I2C interface pins on Raspberry Pi allow you to
connect hardware modules.
• I2C interface allows synchronous data transfer with just
two pins.
1)SDA (Serial Data)
2)SCL (Serial Clock)
236
239. pcDuino
• pcDuino is an Arduino-pin compatible single
board mini-computer
• ARM Cortex-A8 processor
• 1 GHz
• Runs PC like OS such as Ubuntu and Android
ICS.
• HDMI video/audio interface.
• C, C++ ,Java and Python.
239
241. BeagleBone Black
• BeagleBone Black is similar to Raspberry
Pi.
• 1 GHz
• ARM Cortex-A8 processor
• supports both Linux and Android operating
systems.
• HDMI video/audio interface.
• USB and Ethernet ports.
241
243. Cubieboard
• Dual core ARM Cortex A7 processor
• USB, HDMI, IR, serial, Ethernet, SATA,
and a 96 pin extended interface.
• runs both Linux and Android operating
systems.
243
245. Arduino
• UNO means ‗one‘.
• first release of Arduino Software.
• ATmega328P microcontroller.
• Arduino UNO includes
* 6 analog pin inputs
* 14 digital I/O pins (6-PWM outputs)
* USB connector,
* power jack,
* ICSP (In-Circuit Serial Programming) header.
245
246. Arduino
• ATmega328 Microcontroller- It is a single chip Microcontroller of the
ATmel family. The processor code inside it is of 8-bit. It combines
Memory (SRAM, EEPROM, and Flash), Analog to Digital Converter,
SPI serial ports, I/O lines, registers, timer, external and internal
interrupts, and oscillator.
• ICSP pin - The In-Circuit Serial Programming pin allows the user to
program using the firmware of the Arduino board.
• Power LED Indicator- The ON status of LED shows the power is
activated. When the power is OFF, the LED will not light up.
• Digital I/O pins- The digital pins have the value HIGH or LOW. The
pins numbered from D0 to D13 are digital pins.
• TX and RX LED's- The successful flow of data is represented by the
lighting of these LED's.
246
247. Arduino
• AREF- The Analog Reference (AREF) pin is used to feed a
reference voltage to the Arduino UNO board from the external power
supply.
• Reset button- It is used to add a Reset button to the connection.
• USB- It allows the board to connect to the computer. It is essential
for the programming of the Arduino UNO board.
• Crystal Oscillator- The Crystal oscillator has a frequency of 16MHz,
which makes the Arduino UNO a powerful board.
• Voltage Regulator- The voltage regulator converts the input voltage
to 5V.
• GND- Ground pins. The ground pin acts as a pin with zero voltage.
• Vin- It is the input voltage.
• Analog Pins- The pins numbered from A0 to A5 are analog pins. The
function of Analog pins is to read the analog sensor used in the
connection. It can also act as GPIO (General Purpose Input Output)
pins. 247
252. void setup()
{ // initialize digital pin 13 as an output.
pinMode(2, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(2, HIGH); // turn the LED on (HIGH is the
voltage level)
delay(1000); // wait for a second
digitalWrite(2, LOW); // turn the LED off by making the
voltage LOW
delay(1000); // wait for a second 252
254. Interfacing LED and switch with
Raspberry Pi
• In this example the LED is connected to GPIO
pin 18 and switch is connected to pin 25. In the
infinite while loop the value of pin 25 is checked
and the state of LED is toggled if the switch is
pressed. This example shows how to get input
from GPIO pins and process the input and take
some action. The action in this example is
toggling the state of an LED.
254
255. 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)
255
257. Interfacing a Light Sensor (LDR)
with Raspberry Pi
import RPi.GPIO as GPIO
import time
GPIO.setmode (GPIO.BCM)
ldr_threshold = 1000
LDR PIN = 18
LIGHT_PIN = 25
def readLDR (PIN):
reading=0
GPIO. setup (LIGHT_PIN, GPIO.OUT)
GPIO.output (PIN, False)
time.sleep (0.1)
GPIO. setup (PIN, GPIO.IN)
257
258. Interfacing a Light Sensor (LDR) with
Raspberry Pi
while (GPIO.input (PIN) == False):
reading=reading+1
return reading
def switchOnLight (PIN) :
GPIO. setup (PIN, GP10.OUT)
GPIO.output (PIN, True)
def switchOffLight (PIN):
GPIO.setup (PIN, GPI0.OUT)
GPIO.out put (PIN, False)
while True:
ldr_reading = readLDR (LDR_PIN)
if ldr_reading < ldr_threshold :
switchOnLight (LIGHT_PIN)
else:
switchof fLi ght (LIGHT_PIN)
time.sleep (1) 258
259. Programming Raspberry Pi with
Python
• Controlling an LED (Blinking an LED)
• Controlling an LED with Switch
• Interfacing a Light Sensor (LDR)
259
264. Python program for blinking LED
import RPi.GP10 as GPIO
import time
GPIO. setmode (GPIO.BCM)
GPIO.set up (18, GPIO.OUT)
while True:
GPIO.output (18, True)
time.sleep (1)
GPIO.output (18, False)
time.sleep (1)
264
265. Python program for blinking LED
import RPi.GP10 as GPIO
import time
Ledpin =18
GPIO. setmode (GPIO.BCM)
GPIO.set up (Ledpin, GPIO.OUT)
while True:
GPIO.output (Ledpin, True)
time.sleep (1)
GPIO.output (Ledpin, False)
time.sleep (1)
265
266. Python program for blinking LED
import RPi.GP10 as GPIO
from time import sleep
GPIO. setmode (GPIO.BCM)
GPIO.set up (18, GPIO.OUT)
while True:
GPIO.output (18, True)
sleep (1)
GPIO.output (18, False)
sleep (1)
266
269. Interfacing LED and switch with
Raspberry Pi
• LED is connected to GPIO pin 18
• switch is connected to pin 25.
269
270. Interfacing LED and switch with Raspberry Pi
import RPi.GPIO as GPIO
import time
switch_pin=25
LED_pin=18
GPIO.setmode(GPIO.BCM)
GPIO.setup(switch_pin, GPIO.IN)
GPIO.setup(LED_pin, GPIO.OUT)
while True:
if (GPIO.input(switch_pin) == True):
GPIO.output (LED_pin, True)
time.sleep (1)
else:
GPIO.output (LEDpin, False)
time.sleep (1)
270
271. Interfacing LED and switch with
Raspberry Pi
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(25, GPIO.IN)
GPIO.setup(18, GPIO.OUT)
while True:
if (GPIO.input(25) == True):
GPIO.output (18, True)
else:
GPIO.output (18, False)
271
272. Interfacing LED and switch with
Raspberry Pi
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(25, GPIO.IN)
GPIO.setup(18, GPIO.OUT)
while True:
if (GPIO.input(25) == True):
GPIO.output (18, True)
sleep (1)
else:
GPIO.output (18, False)
sleep (1)
272
273. Interfacing a Light Sensor (LDR) with Raspberry Pi
import RPi.GPIO as GPIO
import time
GPIO.setmode (GPIO.BCM)
LDR_PIN = 18
LIGHT_PIN = 25
ldr_threshold = 1000
def readLDR (LDR_PIN):
reading=0
GPIO. setup (LDR_PIN, GPIO.OUT)
GPIO.output (LDR_PIN, False)
time.sleep (1)
GPIO. setup (LDR_PIN, GPIO.IN)
while (GPIO.input (LDR_PIN) == False):
reading=reading+1
return reading 273
274. 20EC503PE - INTERNET OF THINGS
Unit-5
CASE STUDIES
Home Automation – Cities – Environment –
Agriculture – Structural Health monitoring –
Weather monitoring.
274
278. Home Intrusion Detection
Purpose:
• to detect intrusions using sensors (such as
PIR sensors and door sensors) and raise
alerts, if necessary.
• Components:
• Raspberry Pi
• PIR sensors
• door sensors
278
280. Smart Parking
• Purpose:
• to detect the number of empty parking
slots and send the information over the
Internet to smart parking application
backends.
• Components:
• Raspberry Pi
• ultrasonic sensor
280