0% found this document useful (0 votes)
15 views70 pages

FSIoT Chapter4

The document provides an overview of sensors, actuators, and the Raspberry Pi platform, highlighting their functionalities and applications in the Internet of Things (IoT). It also introduces Python programming, emphasizing its simplicity, versatility, and key features, making it suitable for various applications including web development and data science. Additionally, it discusses Software Defined Networking (SDN), explaining its architecture and components that enhance network management and performance.

Uploaded by

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

FSIoT Chapter4

The document provides an overview of sensors, actuators, and the Raspberry Pi platform, highlighting their functionalities and applications in the Internet of Things (IoT). It also introduces Python programming, emphasizing its simplicity, versatility, and key features, making it suitable for various applications including web development and data science. Additionally, it discusses Software Defined Networking (SDN), explaining its architecture and components that enhance network management and performance.

Uploaded by

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

UNIT IV

FUNDAMENTALS OF SENSORS AND


INTERNET OF THINGS (SIoT)

INTRODUCTION TO PYTHON
PROGRAMMING

1
2.1 Sensors and Actuators

⚫ Sensors are devices that detect or measure physical


quantities such as temperature, pressure, humidity,
light, sound, or motion.

⚫ They convert these physical quantities into electrical


signals that can be processed by electronic devices,
such as computers or control systems.

⚫ Examples of sensors include thermometers,


pressure sensors, humidity sensors, light sensors,
microphones, and accelerometers.

2
Cont’
Figure 2.1 The outline of a simple sensing operation

⚫ Actuators are devices that use energy to perform a specific task or to control a
system.
⚫ They are often used to convert electrical signals into physical motion or other types
of energy.
⚫ Examples of actuators include motors, solenoids, relays, and hydraulic cylinders.

3
Figure 2.2 The outline of a simple actuation mechanism
2.5 Raspberry pi Platform and
Processor
⚫ Raspberry Pi is a small, low-cost computer developed by the
Raspberry Pi Foundation, a UK-based charity organization.

⚫ It was created to promote the teaching of basic computer science in


schools and developing countries.

⚫ The original Raspberry Pi Model B, released in 2012, had a 700 MHz


single-core ARM11 processor.

⚫ Since then,the Raspberry Pi Foundation has released several


updated models with more powerful processors.

⚫ The most common model currently in use is the Raspberry Pi 3,


which has a 1.2 GHz 64-bit quad-core ARM Cortex-A53 processor.

⚫ This processor is based on the ARMv8 architecture and is capable of


running a range of operating systems, including Linux and Windows
10 IoT Core.

4
Cont’
⚫ Raspberry Pi 4, have even more powerful processors, with options
ranging from a 1.5 GHz quad-core ARM Cortex-A72 processor to a
2.0 GHz 64-bit Hexa-core ARM Cortex-A72 processor.

⚫ These processors are capable of running a wide range of


applications and can even be used for tasks such as video streaming
and gaming.

⚫ The most common OS for the Raspberry Pi is Raspbian, a free


operating system based on the Debian Linux distribution and
optimized for the Raspberry Pi.

⚫ Other operating systems that can be run on the Raspberry Pi include


Ubuntu, a popular Linux distribution; Windows 10 IoT Core, a version
of Windows 10 designed for IoT devices; and various other Linux
distributions such as Fedora and CentOS.

⚫ Raspbian includes a wide range of software, including the Chromium


web browser, the LibreOffice office suite, and the Python
programming language, as well as a range of tools for managing
and configuring the system.
5
6
Cont’
⚫ The Raspberry Pi is a small computer equipped with several
input/output (I/O) pins, which can be used to connect the Raspberry Pi
to other electronic devices and sensors.

⚫ These pins are located on the Raspberry Pi circuit board's top edge and
labeled with their function and numbering.

⚫ There are a total of 40 pins on the Raspberry Pi, which are divided into
two rows of 20 pins each.

⚫ These pins include power and ground pins and a range of digital
input/output (GPIO) pins that can be used to read digital signals or
control devices such as LEDs or motors.

⚫ The Raspberry Pi also has several specialized pins, including serial


communication pins (RXD and TXD), I2C pins (SDA and SCL), and a
hardware pulse width modulation (PWM) pin.

⚫ These pins can be used for a wide range of applications, including


communication with other devices, controlling servo motors, and
reading sensors. 7
Cont’

8
9
10
⚫ Total pins on Raspberry
Pi

11
12
13
Architecture of Raspberry Pi

14
15
16
17
Interfacing Raspberry Pi with basic
peripherals
Introduction

There are many peripherals that can be added to a


microprocessor over the I2C and SPI serial interfaces.
These include atmospheric sensors, EEPROMS, and
several types of display.

The Pi Wedge helps access the I2C


and SPI signals.
18
The Raspberry Pi has three types of serial interface on
the GPIO header. You’re probably already familiar with
the UART serial port, which allows you to open a login
session from a serial terminal application, such as
PuTTY.

The other two serial interfaces are the Serial Peripheral


Interface (SPI) and Inter-Integrated-Circuit bus (I2C). SPI
on the Pi allows for up to two attached devices, while
I2C potentially allows for many devices, as long as their
addresses don’t conflict.

Before we get started, you might want to review some


related background material.
•I2C is a useful bus that allows data exchange between
microcontrollers and peripherals with a minimum of
wiring. 19

20
21
22
23
LDR Sensor

24
25
2.6 Raspberry pi Vs. Arduino
Sno Arduino Raspberry pi
Control unit of Arduino is from Atmega While control unit of Raspberry Pi is from
1.
family. ARM family.
While Raspberry Pi is based on a
2. Arduino is based on a microcontroller.
microprocessor.

While Raspberry Pi computes data and


It is designed to control the electrical
produces valuable outputs, and controls
3. components connected to the circuit
components in a system based on the
board in a system.
outcome of its computation.

While Raspberry Pi boards have a


Arduino boards have a simple hardware
4. complex architecture of hardware and
and software structure.
software.

5. CPU architecture: 8 bit. CPU architecture: 64 bit.

While Raspberry Pi requires more RAM, 1


6. It uses very less RAM, 2 kB.
GB.
While Raspberry Pi clocks a processing
7. It clocks a processing speed of 16 MHz.
speed of 1.4 GHz.

8. It is cheaper in cost. While Raspberry Pi is expensive.

26
S.no Arduino Raspberry pi

It has a higher I/O current drive While Raspberry Pi has a lower I/O
9.
strength. current drive strength.
While it consumes about 700 MW of
10. It consumes about 200 MW of power.
power.

11. Its logic level is 5V. Its logic level is 3V.

It has inbuilt Ethernet port and WiFi


12. It does not have internet support.
support.

13. It has higher current drive strength. It has lower current drive strength.

Some of the applications of Arduino are Some of the application of Raspberry Pi


14. traffic light countdown timer, Weighing are Stop motion cameras , Robot
machines, etc. Controllers , Game Servers.

operating system are required in Operating System is required in


15
arduino. raspberry pi.

16 two tiny cores Arduino with 32 Mhz Single core and 700 MHz

27
Introduction to Python Programming
Python is a high-level, versatile programming language known for its
simplicity and readability, making it an excellent choice for beginners
and experienced developers alike.
Created by Guido van Rossum and first released in 1991, Python
emphasizes code readability and allows developers to express
concepts with fewer lines of code than many other programming
languages.

28
Why Learn Python?
 Easy to Learn: Python has simple syntax (rules of
writing code), which makes it less complex than other
programming languages.
 Versatile: You can use Python for almost anything –
from building websites to analyzing data, creating video
games, or even controlling robots.
 Large Community Support: Since Python is so
popular, there’s a huge community of programmers
ready to help with resources, tutorials, and forums.

29
Key Features of Python:
1. Simple and Readable Syntax: Python’s syntax is clean and easy to
understand, which makes it ideal for beginners. The use of indentation instead
of braces makes code look neat and improves readability.
2. Interpreted Language: Python is an interpreted language, meaning that it
executes code line by line, which allows for easier debugging and faster
development cycles.
3. Dynamically Typed: Variables in Python do not need explicit declaration, and
the type of a variable can change during runtime, making coding flexible.
4. Extensive Standard Library: Python comes with a rich set of libraries and
frameworks that support a wide range of programming tasks, from web
development to scientific computing, machine learning, and automation.
5. Cross-platform Compatibility: Python can be run on various operating
systems such as Windows, macOS, and Linux, making it a portable language.
6. Open Source and Community Support: Python is free and open-source,
supported by a large and active community that contributes to its vast
repository of packages and tools.
30
Python Syntax and Basics
Let’s start with the basics of Python. Here are some important concepts:
1. Variables: In Python, you don’t need to declare a variable's type. Python
automatically understands whether it’s a number, string, or something else.
age = 18 # Integer
name = "Alice" # String
2. Printing: To output something in Python, we use the print() function.
print("Hello, World!")
3. Data Types:
o Integers: Whole numbers like 5, 10, -3.
o Floats: Decimal numbers like 3.14, 0.5.
o Strings: Text inside quotes, like "Python", "Coding".
o Booleans: True or False values.

31
4. Arithmetic: Python can handle basic math operations:
x = 5 + 3 # Addition
y = 10 - 2 # Subtraction
z = 4 * 2 # Multiplication
a = 10 / 2 # Division
5. Conditional Statements: Python allows you to make
decisions in your program using if, else, and elif
(else if) statements.
age = 18
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.") 32
6. Loops: Loops let you repeat code multiple times. The two main types are for
loops and while loops.
o For Loop: Useful for iterating over a range of numbers or a list of items.
for i in range(5):
print(i) # This will print numbers from 0 to
4
o While Loop: Repeats as long as a condition is true.
count = 0
while count < 3:
print("Counting:", count)
count += 1 # Increment count
7. Functions: Functions allow you to write code once and reuse it whenever you
need. It helps to organize your code better.
def greet(name):
print(f"Hello, {name}!")

greet("Alice")
33
Basic Python Concepts:
 Variables: Used to store data values. Python does not require declaring a
variable’s type.
x = 5
name = "John"
 Data Types: Python supports several data types like integers, floats, strings,
lists, tuples, sets, and dictionaries.
number = 10 # Integer
pi = 3.14 # Float
fruits = ['apple', 'banana', 'cherry’] # List
 Conditional Statements: Python supports if-else statements to perform
different actions based on conditions.
if x > 0:
print("Positive")
else:
print("Non-positive")

34
Applications of Python:
 Web Development: Using frameworks like Django and
Flask.
 Data Science and Machine Learning: Libraries like
NumPy, pandas, TensorFlow, and scikit-learn are widely
used for data analysis and AI tasks.
 Automation and Scripting: Python is frequently used for
automating repetitive tasks, making it popular in the
DevOps world.
 Game Development: Libraries like Pygame make it
possible to develop simple games.

35
 Loops: Python supports for and while loops to execute code
repeatedly.
for i in range(5):
print(i)
 Functions: Functions in Python are defined using the def
keyword and allow for code reuse.
def greet(name):
return f"Hello, {name}!"

36
Hands-On Activity
Let’s write a simple program together. Here’s an example:
# Program to calculate the area of a
rectangle
width = int(input("Enter the width: "))
# Taking input from the user
height = int(input("Enter the height:
"))

area = width * height # Calculating


area
print(f"The area of the rectangle is:
{area}")
37
Software Defined
Networking (SDN)?
What is Software Defined Networking (SDN)?
 Software defined networking (SDN) is an approach
to network management that enables dynamic,
programmatically efficient network configuration to
improve network performance and monitoring. It is a
new way of managing computer networks that makes
them easier and more flexible to control.

 In traditional networks, the hardware (like routers and


switches) decides how data moves through the
network, but SDN changes this by moving the decision-
making to a central software system.

 This is done by separating the control plane from


the data plane. 38
What is a Data Plane?
All the activities involving and resulting from data
packets sent by the end-user belong to this plane. Data
Plane includes:
•Forwarding of packets.
•Segmentation and reassembly of data.
•Replication of packets for multicasting.
What is a Control Plane?
All activities necessary to perform data plane activities
but do not involve end-user data packets belong to this
plane. In other words, this is the brain of the network.
The activities of the control plane include:

39
40
What are the Components of Software Defining
Networking (SDN)?
The three main components that make the SDN are:
•SDN Applications: SDN Applications relay requests or
networks through SDN Controller using API.
•SDN Controller: SDN Controller collects network
information from hardware and sends this information
to applications.
•SDN Networking Devices: SDN Network devices help
in forwarding and data processing tasks.
Where is Software Defined Networking Used?
•Enterprises use SDN, the most widely used method for
application deployment, to deploy applications faster
while lowering overall deployment and operating costs.
SDN allows IT administrators to manage and provision
network services from a single location.
•Cloud networking software-defined uses white-box
systems. Cloud providers often use generic hardware so41
42
43
44
45
46
47
 SDN Architecture
 In a traditional network, each switch has its own data
plane as well as the control plane.

 The control plane of various switches exchange


topology information and hence construct a
forwarding table that decides where an incoming
data packet must be forwarded via the data plane.

 Software-defined networking (SDN) is an approach


via which we take the control plane away from the
switch and assign it to a centralized unit called the
SDN controller.

 Hence, a network administrator can shape traffic via


a centralized console without having to touch the
48
individual switches.
 The data plane still resides in the switch and when a
packet enters a switch, its forwarding activity is
decided based on the entries of flow tables, which are
pre-assigned by the controller.

 A flow table consists of match fields (like input port


number and packet header) and instructions.

 The packet is first matched against the match fields of


the flow table entries. Then the instructions of the
corresponding flow entry are executed.

 The instructions can be forwarding the packet via one


or multiple ports, dropping the packet, or adding
headers to the packet.

49
SDN Architecture
A typical SDN architecture consists of three layers.
•Application Layer: It contains the typical network
applications like intrusion detection, firewall, and
load balancing.
•Control Layer: It consists of the SDN controller which
acts as the brain of the network. It also allows hardware
abstraction to the applications written on top of it.
•Infrastructure Layer: This consists of physical
switches which form the data plane and carries out the
actual movement of data packets.

50
51
52
Software Defined
Networking in IoT
 Software−defined Networking on the Internet of Things
(IoT) presents a formidable architecture that enhances
the adaptability and flexibility of networks.

 By seamlessly abstracting multiple network layers, SDN


revolutionizes network control, empowering enterprises
and service providers to swiftly adapt to evolving
business demands.

 This cutting−edge approach seeks to optimize network


management and empower organizations with the
agility needed to thrive in an ever−changing digital
landscape.
53
 SDN's inherent ability to provide abstractions
empowers network administrators to exert holistic
control over the network, utilizing high−level policies
without having to concern themselves with the
intricacies of low−level configurations.

 Consequently, leveraging SDN proves advantageous


in addressing the heterogeneous nature of IoT and
catering to its unique application−specific demands.

54
Significance of Software Defined
Networking in IoT
Software−Defined Networking (SDN) on the Internet of
Things (IoT) signifies a considerable improvement over
traditional networking, delivering a range of essential
benefits:
1. Enhanced Control with Unparalleled
Speed and Flexibility:
 SDN eliminates the need for manual
configuration of various hardware devices from
different vendors.
 Instead, developers can exert control over
network traffic by programming a software-
based controller adhering to open standards.
 This approach empowers networking managers
with the freedom to select networking
equipment and communicates with multiple 55
2. Customizable Network Infrastructure:

 With SDN, administrators can centrally design


network services and swiftly allocate virtual
resources to modify the network
infrastructure.

 This capability allows network administrators


to prioritize applications that demand
increased availability and optimize the flow of
data across the network according to specific
requirements.

56
3. Robust Security:

 SDN in IoT offers comprehensive visibility


across the entire network, presenting a
holistic view of potential security threats.

 As the number of intelligent devices


connecting to the Internet continues to
proliferate, SDN surpasses traditional
networking in terms of security advantages.

 Operators can create distinct zones for


devices requiring different security levels or
promptly isolate compromised devices to
prevent the spread of infections throughout57
 By embracing Software−Defined Networking in IoT,
organizations can unlock the potential for greater
control, customization, and security within their
networks, paving the way for optimized performance
and improved management of IoT deployments.

58
Risks of Software Defined Networking in
IoT
 From bolstering agility and control to streamlining
management and configuration, SDN presents a
compelling case for adoption.
 However, it is imperative to acknowledge the
potential risks that accompany this technological
marvel.
 One prominent concern lies in the centralized nature
of the controller, which, if compromised, could act as
a single point of failure.
 Nevertheless, proactive measures can mitigate this
vulnerability by implementing controller redundancy
throughout the network, complete with automatic
fail−over capabilities.
 While this endeavor may incur additional expenses, it
aligns with the principles of maintaining business
continuity, akin to the judicious addition 59of
Distinguishing Software Defined
Networking in IoT from Traditional
Networking
 The dissimilarity between Software−Defined
Networking (SDN) and traditional networking lies
primarily in their underlying infrastructure.
 While traditional networking relies on hardware
components, SDN operates on a software basis.
 This fundamental variance endows SDN with
remarkable flexibility that surpasses the confines of
traditional networking.
 Through a software−driven control panel, SDN
empowers administrators to oversee the network,
modify configuration settings, allocate resources, and
augment network capacity from a centralized user
interface, all without necessitating additional hardware
deployment.
60
 Moreover, SDN and traditional networking diverge in
terms of security.

 SDN, being software defined, boasts enhanced


security attributes owing to its heightened visibility
and ability to define secure pathways.

 However, it is imperative to safeguard the centralized


controller as it represents a potential vulnerability and
single point of failure within SDN networks, which
could compromise the network's overall security.

61
SUMMERY
• In Conclusion, The Internet of Things (IoT) networks
may work more efficiently with the help of
Software−Defined Networking (SDN).
• SDN's ability to provide abstractions and its different
varieties, such as Open SDN, API SDN, Overlay Model
SDN, and Hybrid Model SDN, cater to the unique
demands of IoT applications.
• However, there are also risks associated with SDN,
particularly regarding the centralized nature of the
controller.
• Distinctions between SDN and traditional networking
include the software−driven infrastructure of SDN, its
flexibility, and improved security attributes.
• Safeguarding the centralized controller is crucial to
maintaining the overall security of SDN networks.
62
Data Handling and Analytics
What is Data Analytics?
Data analytics, also known as data analysis, is a
crucial component of modern business operations.
 It involves examining datasets to uncover useful
information that can be used to make informed
decisions.
 This process is used across industries to optimize
performance, improve decision-making, and gain a
competitive edge.

63
What is Data Analytics?

Data Analytics is a systematic approach that


transforms raw data into valuable insights. This process
encompasses a suite of technologies and tools that
facilitate data collection, cleaning, transformation, and
modelling, ultimately yielding actionable information.
This information serves as a robust support system for
decision-making.

Data analysis plays a pivotal role in business


growth and performance optimization. It aids in
enhancing decision-making processes, bolstering risk
management strategies, and enriching customer
experiences. By presenting statistical summaries, data
analytics provides a concise overview of quantitative
data. 64
While data analytics finds extensive
application in the finance industry, its utility is
not confined to this sector alone. It is also
leveraged in diverse fields such as agriculture,
banking, retail, and government, among others,
underscoring its universal relevance and
impact. Thus, data analytics serves as a
powerful tool for driving informed decisions and
fostering growth across various industries.

65
Process of Data Analytics
Data analysts, data scientists, and data
engineers together create data pipelines which helps
to set up the model and do further analysis. Data
Analytics can be done in the following steps which are
mentioned below:

1. Data Collection : It is the first step where raw data


needs to be collected for analysis purposes. It consists
of two steps in which data collection can be done. If the
data are from different source systems, then using data
integration routines the data analysts must combine
the different data whereas sometimes the data are the
subset of the data set. In this case, the data analyst
would perform some steps to extract the useful subset
and transfer it to the other compartment in the system.
66
2.Data Cleansing : After collecting the data, the next step is
to clean the quality of the data as the collected data consists
of a lot of quality problems such as errors, duplicate entries
and white spaces which need to be corrected before moving to
the next step. By running data profiling and data cleansing
tasks, these errors can be corrected. These data are organized
according to the needs of the analytical model by the analysts.

3.Data Analysis and Data Interpretation: Analytical


models are created using software and other tools which
interpret the data and understand it. The tools include Python,
Excel, R, Scala and SQL. Lastly this model is tested again and
again until the model works as it needs to be then in
production mode the data set is run against the model.

4. Data Visualization: Data visualization is the process of


creating visual representation of data using the plots, charts
and graphs which helps to analyze the patterns, trends and get
the valuable insights of the data. By comparing the datasets
and analyzing it data analysts find the useful data from the 67
Types of Data Analytics
There are different types of data analysis in which raw
data is converted into valuable insights. Some of the
types of data analysis are mentioned below:
1.Descriptive Data Analytics : Descriptive data
Analytics is a type of data analysis which summarizes
the data set and it is used to compare the past results,
differentiate between the weakness and strength, and
identify the anomalies. Descriptive data analysis is
used by the companies to identify the problems in the
data set as it helps in identifying the patterns.

2.Real-time Data Analytics: Real time data Analytics


doesn’t use data from past events. It is a type of data
analysis which involves using the data when the data is
immediately entered in the database. This type of
analysis is used by the companies to identify the trends
and track the competitors’ operations.
68
3.Diagnostic Data Analytics: Diagnostic Data Analytics
uses past data sets to analyze the cause of an anomaly.
Some of the techniques used in diagnostic analysis are
correlation analysis, regression analysis and analysis of
variance. The results which are provided by diagnostic
analysis help the companies to give accurate solutions to
the problems.

4.Predictive Data Analytics: This type of Analytics is


done in the current data to predict future outcomes. To
build the predictive models it uses machine learning
algorithms, statistical model techniques to identify the
trends and patterns. Predictive data analysis is also used in
sales forecasting, to estimate the risk and to predict
customer behavior.

5.Prescriptive Data Analytics: Prescriptive data


Analytics is an analysis of selecting best solutions to
problems. This type of data analysis is used in loan
approval, pricing models, machine repair scheduling, 69
Methods of Data Analytics
There are two types of methods in data analysis which are mentioned
below:

1. Qualitative Data Analytics: Qualitative data analysis doesn’t use


statistics and derives data from the words, pictures and symbols. Some
common qualitative methods are:

•Narrative Analytics is used for working with data acquired from diaries,
interviews and so on.

•Content Analytics is used for Analytics of verbal data and behavior.

•Grounded theory is used to explain some given event by studying.

2. Quantitative Data Analysis: Quantitative data Analytics is used to


collect data and then process it into the numerical data. Some of the
quantitative methods are mentioned below:

•Hypothesis testing assesses the given hypothesis of the data set.

•Sample size determination is the method of taking a small sample from a


large group of people and then analyzing it. Average or mean of a subject is
70
dividing the sum of total numbers in the list by the number of items

You might also like