0% found this document useful (0 votes)
50 views48 pages

5g and Iot Notes

The document provides an overview of the evolution of mobile technologies from 1G to 5G, detailing the advancements in communication capabilities and the introduction of various technologies at each generation. It highlights the key features and requirements of 5G, including high data rates, low latency, and massive connectivity for IoT applications, as well as the regulatory and security considerations involved. Additionally, it discusses the challenges of implementing 5G networks, particularly in terms of propagation scenarios and channel modeling for millimeter-wave systems.

Uploaded by

parvathi1234v
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)
50 views48 pages

5g and Iot Notes

The document provides an overview of the evolution of mobile technologies from 1G to 5G, detailing the advancements in communication capabilities and the introduction of various technologies at each generation. It highlights the key features and requirements of 5G, including high data rates, low latency, and massive connectivity for IoT applications, as well as the regulatory and security considerations involved. Additionally, it discusses the challenges of implementing 5G networks, particularly in terms of propagation scenarios and channel modeling for millimeter-wave systems.

Uploaded by

parvathi1234v
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

5G & IOT TECHNOLOGIES

Unit I: Overview of 5G Broadband Wireless Communica ons


Evolu on of Mobile Technologies (1G to 5G)
Introduc on :
Mobile Cellular Telephony is one of the greatest innova ons of the twen eth century and today
in the twenty-first century it can be safely said that it has brought nothing less than a revolu on
in the way communica ons take place across the globe. The Mobile Cellular Telephony is
enabled through a combina on of cellular networks and mobile devices which communicate
to each other by means of radio frequency spectrum (i.e. wirelessly). A cellular network
consists of thousands of nodes that assist mobile device users in performing plethora of tasks.
Mobile device has become the Third Screen a er Television and Computer and is becoming
more economical and powerful with con nual technological advancements. There are more
than 5 billion mobile subscribers in the world and for the very vast majority the mobile device
has become a necessity and without it they can’t go about with their daily rou ne lives.

Simply, the "G" stands for "GENERATION". While connected to the internet, the speed of the
connec on depends upon the signal strength that is shown in abbrevia ons like 2G, 3G, 4G,
5G, etc. on any mobile device. Each genera on of wireless broadband is defined as a set of
telephone network standards that describe the technological implementa on of the system.

 1G (First Genera on):

o Introduced in the 1980s, 1G technology was purely analog and provided basic voice
communica on. It used frequency modula on for voice signals and was highly prone
to sta c and noise. The systems were circuit-switched and had low capacity, leading
to frequent dropped calls.

o Technology: Analog cellular systems like AMPS (Advanced Mobile Phone System).

o Features: Voice-only, low data security, large cell size.

o Drawbacks: Poor voice quality, frequent call drops, lack of data services.
 2G (Second Genera on):

o Launched in the 1990s, 2G was the first digital mobile communica on system. It
introduced digital encryp on, data services like SMS and MMS, and improved call
quality. Technologies like GSM (Global System for Mobile communica ons) and CDMA
(Code Division Mul ple Access) emerged in this era.

o Technology: Digital, introduced technologies like GSM (Global System for Mobile
Communica ons) and CDMA (Code Division Mul ple Access).

o Features: Enhanced voice clarity, basic data services (SMS and MMS), be er security
with encryp on.

o Impact: Enabled global mobile connec vity with standardized protocols.

o Examples: GSM networks that became the founda on for future mobile
communica on.

 3G (Third Genera on):

Introduced around the early 2000s, 3G brought significant improvements in data transfer
speeds, enabling mobile broadband services. It facilitated video calls, mobile internet
access, and streaming services. Key technologies include UMTS (Universal Mobile
Telecommunica ons System) and CDMA2000.

o Technology: UMTS (Universal Mobile Telecommunications System), CDMA2000.

o Features: Faster data speeds (up to 2 Mbps), video calling, mobile internet.

o Impact: Revolutionized mobile broadband, paving the way for smartphones.

o Applications: Streaming, web browsing, and early app ecosystems.

 4G (Fourth Genera on):

o Launched in the late 2000s, 4G focused on high-speed internet access and the ability
to transmit large amounts of data. LTE (Long Term Evolu on) and WiMAX are the
predominant 4G technologies. It supports mobile HD TV, video conferencing, and
faster online gaming.

o Technology: LTE (Long Term Evolu on), WiMAX.

o Features: Speeds up to 100 Mbps for mobile, seamless video streaming, online
gaming.

o Impact: Made mobile internet comparable to broadband, enabling services like HD


streaming.

o Real-world Usage: Services like Ne lix, YouTube, and social media apps flourished
due to 4G networks.
An Overview of 5G Requirements :
 5G (Fi h Genera on):

5G, the latest genera on, offers extremely high speeds, ultra-low latency, and massive
connec vity. It enables advanced applica ons such as IoT, autonomous vehicles, and smart
ci es. The key features include Enhanced Mobile Broadband (eMBB), Ultra-Reliable Low-
Latency Communica ons (URLLC), and Massive Machine Type Communica ons (mMTC)

o High Data Rates: 5G aims to deliver peak data rates of up to 10 Gbps.

o Low Latency: Target latency in 5G is around 1 millisecond, which is crucial for


applica ons like remote surgery and autonomous vehicles.

o Massive Device Connec vity: 5G is designed to connect a vast number of IoT devices
efficiently.

o Energy Efficiency: 5G networks aim to consume less energy per transmi ed data unit.

o Spectrum Efficiency: Efficient use of the spectrum is cri cal for handling the increased
demand for bandwidth.

Regula ons for 5G


o Spectrum Alloca on: 5G operates in a wide range of frequencies, including sub-6 GHz
and mmWave bands. Regulatory bodies manage the alloca on to avoid interference.

o Global Standards: Organiza ons like the ITU (Interna onal Telecommunica on Union)
and 3GPP (3rd Genera on Partnership Project) work on crea ng unified global
standards for 5G.
o Security and Privacy: Regula ons also focus on ensuring secure communica on and
protec ng user privacy.

Spectrum Analysis and Sharing for 5G


o Frequency Bands:

o Sub-6 GHz: Used for broad coverage and be er penetra on.

o mmWave (Millimeter Wave): Offers extremely high bandwidth but limited range and
penetra on.

o Dynamic Spectrum Sharing (DSS): Allows 5G to share the spectrum with 4G LTE,
ensuring smooth transi ons and be er resource u liza on.

o Carrier Aggrega on: Combining mul ple frequency bands to improve bandwidth and
data rates.

Unit II: The 5G Wireless Propaga on Channels


Propaga on Scenarios and Challenges in 5G
A channel model is also known as radio wave propaga on model, it characterizes radio wave
propaga on as a func on of frequency, distance, environment, and other factors. In other
words, we can say that channel model provides us rough idea how much distance a signal can
travel in a certain environment (morphology like urban, suburban or rural etc.) with the known
transmi er and receiver height.
Channel Modeling Requirements
The requirements of the new channel model that can support 5G opera on across frequency
bands up to 100 GHz is based on the exis ng 3GPP channel models along with extensions to
cover addi onal 5G modeling requirement and some of these requirements are listed below:
 New channel model should support large antenna arrays, especially at higher-
frequencies in millimeter-wave bands, it will very likely to be 2D and dual-polarized
both at the access point (AP) and the user equipment (UE)
 New channel model must accommodate a wide frequency range up to 100 GHz.
 It needs to include joint propaga on characteris cs over different frequency bands to
evaluate mul band opera on, e.g., low-band and high-band carrier aggrega on
configura ons.
 New channel model must support large channel bandwidths (up to 2 GHz), where
the individual channel bandwidths may be in the range of 100 MHz to 2 GHz and may
support a carrier aggrega on
 The new channel model must accommodate mobility, in par cular, the channel
model structure should be suitable for mobility up to 500 km/hr,
 The mobility channel model should be extendable to support scenarios such as
device to device (D2D) or vehicle to vehicle (V2V).
 Key Components:
o Path Loss: The reduc on in signal strength as it travels through the medium.
o Shadowing: Signal a enua on caused by obstacles such as buildings or trees.
o Mul path Propaga on: Signals reflec ng off surfaces and reaching the
receiver at different mes, causing interference.
o Doppler Effect: Frequency shi due to the rela ve mo on between the
transmi er and receiver.

Propaga on Scenarios and Challenges in 5G


5G networks use millimeter-wave (mm-Wave) technology to support high data rates and low
latency. However, there are challenges to implemen ng 5G networks, including spectrum
availability, cost, and infrastructure.
Propaga on scenarios

 Channel modeling
A model that reflects the communica on characteris cs of radio signals. It can be
used to study the channel's transmission capability.
 Spectrum
5G networks require a large amount of spectrum, or radio frequencies, to support
high data rates and low latency.
 Millimeter-wave (mm-Wave) technology
5G networks use mm-Wave technology, which operates in the 24.25–52.6 GHz
frequency range. This technology allows for a wider range of frequencies, which
results in a larger bandwidth and be er data transmission rates.
Challenges
 Cost
5G networks can be expensive to implement due to the cost of spectrum, hardware,
and planning permissions.
 Infrastructure
5G networks may face challenges related to infrastructure, such as gaps in coverage
and penetra on.
 Cybersecurity
5G networks may be vulnerable to cybera acks, despite having more
comprehensive algorithms than previous networks.
 Latency
5G networks need to have low latency, which is the me it takes for a data signal to
travel from one point to another and back.
 Urban Macro (UMa):
o Scenario: Dense urban environments with tall buildings.
o Challenges: High path loss, significant mul path effects, and frequent
handovers due to small cell size.

 Urban Micro (UMi):


o Scenario: Urban areas with a lower base sta on height, closer to street level.
o Challenges: Similar to UMa but with less severe path loss and mul path
issues due to lower heights.

Channel Models for mmWave MIMO Systems


Channel models for millimeter wave (mmWave) mul ple-input mul ple-output (MIMO)
systems describe the propaga on of radio waves in this band. They are used to develop and
op mize wireless communica on systems.

The General MIMO Channel Model


The basic MIMO channel model and its core requirements, mul link channel sounding
techniques, MIMO technology classifica on, and MIMO channel modeling are presented in
this sec on. First, the generalized MIMO channel model and MIMO channel modeling
techniques are introduced. Second, the concept of mul link channel sounders is presented
briefly. This sec on also covers the single-sounder sequen al measurements, single-sounder
mul node measurements, and mul sounder measurements. Further to this, we highlight the
basic classifica on of MIMO channel models, point-to-point, mul user MIMO, and massive
MIMO, and provided a concise descrip on of the mul user MIMO for the uplink and downlink
scenarios.
Basic MIMO Channel Model
The tradi onal single antenna communica on system lacks the required spa al degree of
freedom provided by mul ple antennas. In MIMO communica on systems, the presence of
mul ple antennas can be of great advantage. The spa al degree of freedom provided by these
antennas can be appropriately harnessed to boost the capacity and expand the system’s
coverage through op mal scheduling of mul ple users to simultaneously share the spa al
channel. As illustrated in Figure 1, the channel gives useful informa on about transmi ng and
receiving antennas in a simple MIMO channel. Considering the case of an n × m MIMO
channel system, where m and n represent the respec ve numbers of transmi ng and
receiving antennas, the linear me-variant MIMO channel could be modeled as shown in (1),
using an n × m channel matrix .
where hnm(t, τ) is the me-variant channel impulse response between the mth transmit
antenna and the nth receive antenna.
Figure 1

 mmWave Characteris cs:


o Operates in the 30 GHz to 300 GHz range.
o Offers high bandwidth but limited range and poor penetra on through
obstacles
 MIMO (Mul ple Input Mul ple Output):
o Uses mul ple antennas at both the transmi er and receiver to improve
communica on performance.
o Enhances data throughput and link reliability through spa al mul plexing and
diversity gains.

Channel Models:
o NYUSIM: A popular simulator for mmWave channel modeling.
o Cluster-based models: Group mul path components into clusters for easier
modeling.

o Ray Tracing: Predicts the path of radio waves through the environment using
geometrical op cs principles.

3GPP Standards for 5G


The 3rd Genera on Partnership Project (3GPP) has standardized 5G through a series
of releases, specifica ons, and frequency bands. These standards include
performance requirements, security features, and frequency bands.
Performance requirements
 Data rate: 3GPP has targeted a peak data rate of 20 Gbps
 Latency: 3GPP has targeted a radio network latency of 1 ms
 Throughput: 3GPP has targeted an area throughput of 10 Mbps/m2
 IoT devices: 3GPP has targeted suppor ng 1 million IoT devices per square
kilometer
Security features
 3GPP has enhanced subscriber privacy to make it harder for false base sta ons
to iden fy and trace subscribers
 3GPP has made it harder for a ackers to correlate protocol messages and
iden fy a single subscriber
 3GPP has a general framework for detec ng false base sta ons
Frequency bands
 3GPP has standardized frequency bands for 5G NR, known as the "FR1" and
"FR2" bands
 FR1 includes low and mid-band frequencies, from 410 MHz to 7.125 GHz
Releases
 3GPP has split the 5G standard into two releases: Release 15 and Release 16
 Release 15 corresponds to NR Phase 1, while Release 16 corresponds to NR
Phase 2

IEEE 802.15.4
IEEE 802.15.4 is a standard that defines the physical layer (PHY) and media access control (MAC)
sublayer for low-rate wireless networks. It's used in home automa on, sensor networking, and the
Internet of Things (IoT). (or)

IEEE 802.15.4 is a technical standard that defines the opera on of a low-rate wireless personal area
network (LR-WPAN).

 The IEEE 802.15 working group defined the standard in 2003

 IEEE 802.15.4-2006 was published a er revisions and improvements made by IEEE 802.15
TG4b

 Defines the MAC and PHY layers for low-rate wireless personal area networks (LR-WPANs)

 Specifies how to insert MAC headers and footers into network-layer frames

 Provides the basis for higher-layer standards like ZigBee, WirelessHART, and 6LoWPAN
Architecture
The LR-WPAN architecture is defined in terms of a number of blocks in order to simplify the
standard. These blocks are called layers. Each layer is responsible for one part of the standard
and offers services to the higher layers. The layout of the blocks is based on the open systems
interconnec on (OSI) seven-layer model (see 2.2).
An LR-WPAN device comprises a PHY, which contains the radio frequency (RF) transceiver
along with its low-level control mechanism, and a MAC sublayer that provides access to the
physical channel for all types of transfer. Figure 3 shows these blocks in a graphical
representa on
PHY
The PHY provides two services:
the PHY data service and the PHY management service interfacing to the physical layer
management en ty (PLME). The PHY data service enables the transmission and recep on of
PHY protocol data units (PPDUs) across the physical radio channel. Clause 6 contains the
specifica ons for the PHY. Figure 3—LR-WPAN device architecture Physical Medium PHY MAC
802.2 LLC Upper Layers SSCS IEEE WIRELESS MAC AND PHY SPECIFICATIONS FOR LR-WANS Std
802.15.4-2003 .
The features of the PHY are ac va on and deac va on of the radio transceiver, ED, LQI,
channel selec on, clear channel assessment (CCA), and transmi ng as well as receiving
packets across the physical medium. The radio shall operate at one of the following license-
free bands:
— 868–868.6 MHz (e.g., Europe),
— 902–928 MHz (e.g., North America) or

— 2400–2483.5 MHz (worldwide).


MAC sublayer
The MAC sublayer provides two services: the MAC data service and the MAC management
service interfacing to the MAC sublayer management en ty (MLME) service access point (SAP)
(known as MLME-SAP). The MAC data service enables the transmission and recep on of MAC
protocol data units (MPDUs) across the PHY data service. The features of the MAC sublayer
are beacon management, channel access, GTS management, frame valida on, acknowledged
frame delivery, associa on, and disassocia on. In addi on, the MAC sublayer provides hooks
for implemen ng applica on appropriate security mechanisms. Clause 7 contains the
specifica ons for the MAC sublayer.
Uses
 The standard is the basis for higher-layer standards like ZigBee, WirelessHart,
6LoWPAN, and MiWi.
 It's used by many IoT protocols.
Advantages of IEEE 802.15.4:
 cheap cost
 long ba ery life,
 Quick installa on
 simple
 extensible protocol stack
Disadvantages of IEEE 802.15.4:
IEEE 802.15.4’s drawbacks include:
 IEEE 802.15.4 causes interference and mul path fading.
 doesn’t employ a frequency-hopping approach.
 unbounded latency
 interference suscep bility
Unit III: Introduc on to Internet of Things (IoT)
Defini on and Characteris cs of IoT:
 IoT Defini on:
o The Internet of Things (IoT) refers to a network of physical objects ("things")
embedded with sensors, so ware, and other technologies to connect and
exchange data with other devices and systems over the internet.
 Characteris cs:
o Connec vity: Devices are connected to each other and to central systems via
the internet.
o Intelligence: IoT devices o en have smart capabili es, such as sensing,
processing, and decision-making.
o Sensing: Devices are equipped with sensors to collect data from the
environment.
o Interac on: IoT devices can interact with users and other devices.
o Data: The backbone of IoT, with devices collec ng and transmi ng vast
amounts of data.
o Ac on: Devices can perform specific ac ons based on data analysis.
Physical Design of IoT:
A physical design of an IoT system refers to the individual node devices and their
protocols that are u lized to create a func onal IoT ecosystem, which includes :
o Connec vity: Devices like USB hosts and ETHERNET are used for connec vity
between the devices and the server.
o Processor: A processor like a CPU and other units are used to process the data.
these data are further used to improve the decision quality of an IoT system.
o Audio/Video Interfaces: An interface like HDMI and RCA devices is used to
record audio and videos in a system.

o Input/Output interface: To give input and output signals to sensors, and


actuators we use things like UART, SPI, CAN, etc.
o Storage Interfaces: Things like SD, MMC, and SDIO are used to store the data
generated from an IoT device.
o Other things like DDR and GPU are used to control the ac vity of an IoT system.

IoT Protocols:
These protocols are used to establish communica on between a node device and a
server over the internet. it helps to send commands to an IoT device and receive data
from an IoT device over the internet. we use different types of protocols that are
present on both the server and client side and these protocols are managed by
network layers like applica on, transport, network, and link layer.
Applica on Layer protocol:
In this layer, protocols define how the data can be sent over the network with the lower
layer protocols using the applica on interface. these protocols include HTTP,
WebSocket, XMPP, MQTT, DDS, and AMQP protocols.

 HTTP
Hypertext transfer protocol is a protocol that presents in an applica on layer for
transmi ng media documents. it is used to communicate between web browsers and
servers. it makes a request to a server and then waits ll it receives a response and in
between the request server does not keep any data between the two requests.
 WebSocket
This protocol enables two-way communica on between a client and a host that can be
run on an untrusted code in a controlled environment. This protocol is commonly used
by web browsers.
 MQTT
It is a machine-to-machine connec vity protocol that was designed as a
publish/subscribe messaging transport. and it is used for remote loca ons where a small
code footprint is required.
Transport Layer:
This layer is used to control the flow of data segments and handle error control. also, these
layer protocols provide end-to-end message transfer capability independent of the underlying
network.

 TCP
The transmission control protocol is a protocol that defines how to establish and maintain
a network that can exchange data in a proper manner using the internet protocol.
 UDP
a user datagram protocol is a part of an internet protocol called the connec onless
protocol. this protocol is not required to establish the connec on to transfer data.
Network Layer:
This layer is used to send datagrams from the source network to the des na on network.
we use IPv4 and IPv6 protocols as host iden fica on that transfers data in packets.
 IPv4
This is a protocol address that is a unique and numerical label assigned to each device
connected to the network. an IP address performs two main func ons host and
loca on addressing. IPv4 is an IP address that is 32-bit long.
 IPv6
It is a successor of IPv4 that uses 128 bits for an IP address. it is developed by the IETF
task force to deal with long-an cipated problems.
Link Layer:
Link-layer protocols are used to send data over the network’s physical layer. it also
determines how the packets are coded and signaled by the devices.
 Ethernet
It is a set of technologies and protocols that are used primarily in LANs. it defines the
physical layer and the medium access control for wired ethernet networks.
 WiFi
It is a set of LAN protocols and specifies the set of media access control and physical
layer protocols for implemen ng wireless local area networks.

IoT Communica on Models:


There are mul ple kinds of models available in an Internet of Things system that is
used for communica ng between the system and server, such as:
 Request-Response Model:
Request-response model is a communica on 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
representa on, prepares the response, and then sends the response to the client.
Request-response is a stateless communica on model and each request-response pair
is independent of the others.
HTTP works as a request-response protocol between a client and a server. A web
browser may be the client, and an applica on on a computer that hosts a website may
be the server.
Example: A client (browser) submits an HTTP request to the server; then the server
returns a response to the client. The response contains status informa on about the
request and may also contain the requested content.
 Publisher-Subscriber Model — This model comprises three en es: Publishers,
Brokers, and Consumers.
Publishers are the source of data. It sends the data to the topic which is managed by
the broker. They are not aware of consumers.
Consumers subscribe to the topics which are managed by the broker.
Brokers' responsibility is to accept data from publishers and send it to the appropriate
consumers. The broker only has the informa on regarding the consumer to which a
par cular topic belongs which the publisher is unaware.

 Push-Pull Model — The push-pull model cons tutes data publishers, data consumers,
and data queues.
Publishers and Consumers are not aware of each other.
Publishers publish the message/data and push it into the queue. The consumers,
present on the other side, pull the data out of the queue. Thus, the queue acts as the
buffer for the message when the difference occurs in the rate of push or pull of data
on the side of a publisher and consumer.
Queues help in decoupling the messaging between the producer and consumer.
Queues also act as a buffer which helps in situa ons where there is a mismatch
between the rate at which the producers push the data and consumers pull the data.

 Exclusive Pair –
Exclusive Pair is the bi-direc onal model, including full-duplex communica on
between client and server. The connec on is constant and remains open ll the client
sends a request to close the connec on.
The Server has the record of all the connec ons which has been opened.
This is a state-full connec on model and the server is aware of all open connec ons.
WebSocket-based communica on API is fully based on this model.

IoT communica on API:


In IoT, there are 2 communica on APIs –
 REST — based Communica on APIs
 Web Socket — based Communica on APIs
Web service can either be implemented using REST principles or using Web Socket
Protocol –
1. REST-Based Communica on API:
REpresenta onal State Transfer (REST) is a set of architectural principles by which you
can design web services and web APIs that focus on a system’s resources and how
resource states are addressed and transferred. REST APIs follow the request-response
communica on model. The REST architectural constraints apply to the components,
connectors, and data elements, within a distributed hypermedia system.

2. Web Socket-Based Communica on APIs:


Web Socket APIs allow bi-direc onal, full-duplex communica on between clients and
servers. It follows the exclusive pair communica on model. This Communica on API
does not require a new connec on to be set up for each message to be sent between
clients and servers. Once the connec on is set up the messages can be sent and
received con nuously without any interrup on. WebSocket APIs are suitable for IoT
Applica ons with low latency or high throughput requirements.

Difference between Rest API and Web Socket API :

IoT Enabling Technologies:


IoT-enabling technologies primarily focus on conver ng a standalone device into an
IoT device by giving it the addi onal possibility of connec ng to the internet and
exchanging informa on with it.
IoT(internet of things) enabling technologies are
1. Wireless Sensor Network
2. Cloud Compu ng
3. Big Data Analy cs
4. Communica ons Protocols
5. Embedded System

1. Wireless Sensor Network(WSN): A WSN comprises distributed devices with sensors


that are used to monitor environmental and physical condi ons. A wireless sensor
network consists of end nodes, routers, and coordinators. End nodes have several
sensors a ached to them and the data is passed to a coordinator with the help of
routers. The coordinator also acts as the gateway that connects WSNs to the internet.
Example –
 Weather monitoring system
 Indoor air quality monitoring system
 Soil moisture monitoring system
 Surveillance system
 Health monitoring system

2. Cloud Compu ng: It provides us the means by which we can access applica ons as
u li es over the internet. Cloud means something which is present in remote
loca ons. With Cloud compu ng, users can access any resources from anywhere like
databases, web servers, storage, any device, and any so ware over the internet.
Characteris cs –
1. Broad network access
2. On-demand self-service
3. Rapid scalability
4. Measured service
5. Pay-per-use
Provides different services, such as –
 IaaS (Infrastructure as a service) Infrastructure as a service provides online services
such as physical machines, virtual machines, servers, networking, storage, and data
center space on a pay-per-use basis. Major IaaS providers are Google Compute Engine,
Amazon Web Services, and Microso Azure, etc. Ex: Web Hos ng, Virtual Machine,
etc.
 PaaS (Pla orm as a service) Provides a cloud-based environment with a very thing
required to support the complete life cycle of building and delivering West web-based
(cloud) applica ons — without the cost and complexity of buying and managing the
underlying hardware, so ware provisioning, and hos ng. Compu ng pla orms such
as hardware, opera ng systems, libraries, etc. Basically, it provides a pla orm to
develop applica ons. Ex: App Cloud, Google app engine
 SaaS (So ware as a service): it is a way of delivering applica ons over the internet as
a service. Instead of installing and maintaining so ware, you simply access it via the
internet, freeing yourself from complex so ware and hardware management. SaaS
Applica ons are some mes called web-based so ware on-demand so ware or hosted
so ware. SaaS applica ons run on a SaaS provider’s service and they manage security
availability and performance. Ex: Google Docs, Gmail, office, etc.

3. Big Data Analy cs: It refers to the method of studying massive volumes of data or
big data. Collec on of data whose volume, velocity, or variety is simply too massive
and tough to store, control, process and examine the data using tradi onal databases.
Big data is gathered from a variety of sources including social network videos, digital
images, sensors, and sales transac on records. Several steps are involved in analyzing
big data –
1. Data cleaning
2. Munging
3. Processing
4. Visualiza on
Examples –
 Bank transac ons
 Data generated by IoT systems for loca on and tracking of vehicles
 E-commerce and in Big-Basket
 Health and fitness data generated by IoT systems such as fitness bands

4. Communica ons Protocols: They are the backbone of IoT systems and enable
network connec vity and linking to applica ons. Communica on protocols allow
devices to exchange data over the network. Mul ple protocols o en describe different
aspects of a single communica on. A group of protocols designed to work together is
known as a protocol suite; when implemented in so ware they are a protocol stack.
They are used in
1. Data encoding
2. Addressing schemes

5. Embedded Systems: It is a combina on of hardware and so ware used to perform


special tasks. It includes microcontroller and microprocessor memory, networking
units (Ethernet Wi-Fi adapters), input-output units (display keyword, etc. ), and storage
devices (flash memory).It collects the data and sends it to the internet. Embedded
systems used in.
Examples –
1. Digital camera
2. DVD player, music player
3. Industrial robots
4. Wireless Routers etc.
IoT Levels and Deployment Templates
Developing an IoT Level Template system consists of the following components:
1. Device: These may be sensors or actuators capable of iden fying, remote sensing, or
monitoring.
2. Resources: These are so ware components on IoT devices for accessing and
processing. storing so ware components or controlling actuators connected to the
device. Resources also include so ware components that enable network access.
3. Controller Service: It is a service that runs on the device and interacts with web
services. The controller service sends data from the device to the web service and
receives commands from the applica on via web services for controlling the device.
4. Database: Stores data generated from the device
5. Web Service: It provides a link between IoT devices, applica ons, databases, and
analysis components.
6. Analysis Component: It performs an analysis of the data generated by the lol device
and generates results in a form which are easy for the user to understand.
7. Applica on: It provides a system for the user to view the system status and view
product data. It also allows users to control and monitor various aspects of the IoT
system.
IoT Levels
IoT level 1
 A level-1 IoT system has a single node/device that performs sensing and/or actua on,
stores data, performs analysis, and hosts the applica on • It is suitable for modeling
low-cost and low-complexity solu ons where the data involved are not big and the
analysis requirements are not computa onally intensive.

IoT Level-2
 It has a single node that performs sensing and/or actua on and local analysis (IoT
Device and collected data).
 At this, IoT Level Databases and applica ons establish in Cloud.
 It is useful for solu ons where the data involved is big, however, the primary analysis
requirement is not computa onally intensive and can be done locally itself.
IoT Level-3
 It has a single node. Database and applica ons established in the cloud.
 It is suitable for solu ons where the data involved is big and the analysis requirements
are computa onally intensive.

IoT Level-4
 It has mul ple nodes that perform local analysis. It has a Cloud-based applica on and
database. This IoT System contains local and cloud-based observer nodes which can
subscribe to and receive informa on collected in the cloud from IoT node devices.
 It is suitable for solu ons where we are using mul ple nodes, the data involved is big
and the analysis requirements are computa onally intensive.
IoT Level-5
 It has mul ple end nodes and one coordinator node. The end nodes use for sensing
and/or actua on.
 In this model, the Coordinator node collects data from the end nodes and transfers it
to the cloud. In this model, we used a Cloud-based Database for storing and Analyzing
data.
 It is suitable for solu ons based on wireless sensor networks, in which the data
involved is big and the analysis requirements are computa onally intensive.
IoT Level-6
 It has mul ple independent end nodes that are used for sensing and/or actua on and
transferring data to the cloud. We used a Cloud-based database.
 The analy cs component analyzes the data and stores the results in the cloud database
and the results are visualized with the cloud-based applica on.
 The centralized controller is aware of the status of all the end nodes and sends control
commands to the nodes

Domain-Specific IoTs:
The Internet of Things (IoT) applica ons span a wide range of domains Home Automa on
Ci es Environment, Energy, Retail, Logis cs, Agriculture, Industry and Health & Lifestyle.
1. Home Automa on IoT
 Smart Appliances: IoT-connected appliances such as refrigerators, washing machines,
and ovens can be controlled remotely via smartphone apps.
 Home Security: IoT-enabled security systems include smart locks, cameras, and
mo on detectors, which provide real- me alerts and remote access.
 Energy Management: Smart thermostats and ligh ng systems adjust se ngs based
on occupancy or me of day, improving energy efficiency.
 Home Health Monitoring: Devices like smart beds and air quality monitors track
health metrics and environmental condi ons, enhancing well-being.
2. Smart Ci es IoT
 Public Safety: IoT sensors and cameras monitor streets for crimes, accidents, and
other safety issues, providing data to emergency services.
 Smart Parking: IoT-based systems direct drivers to available parking spaces, reducing
traffic conges on.
 Infrastructure Monitoring: Sensors on bridges and buildings provide data on
structural health, allowing for proac ve maintenance.
 Public Transport: IoT devices track buses and trains, providing real- me loca on data
to commuters and op mizing schedules.
3. Environment IoT
 Weather Monitoring: IoT sensors collect data on temperature, humidity, and other
weather parameters, aiding in climate studies and disaster preparedness.
 Pollu on Control: IoT systems track air and water quality, enabling authori es to take
mely ac ons to reduce pollu on.
 Wildlife Monitoring: IoT devices are used to track wildlife movements, aiding
conserva on efforts.
4. Energy IoT
 Smart Meters: IoT-enabled meters provide real- me electricity usage data, helping
consumers and u li es manage energy be er.
 Renewable Energy Management: IoT systems op mize the genera on and
distribu on of solar and wind energy, integra ng them into the grid.
 Energy Storage: IoT devices manage ba ery storage systems, ensuring efficient
energy use during peak and off-peak hours.
5. Retail IoT

 Smart Shelves: Shelves equipped with weight sensors track product levels and no fy
staff for restocking.
 Personalized Shopping: IoT beacons in stores provide personalized discounts and
product informa on to customers via their smartphones.
 Checkout Automa on: IoT systems enable cashier-less checkouts, where sensors and
cameras track what customers take and automa cally bill them.
6. Logis cs IoT
 Asset Tracking: IoT devices monitor the loca on and condi on of goods during
transit, ensuring mely deliveries and quality maintenance.
 Warehouse Automa on: IoT robots and sensors op mize storage, retrieval, and
inventory management in warehouses.
 Supply Chain Transparency: IoT data provides real- me insights into the supply chain,
enhancing efficiency and reducing bo lenecks.
7. Agriculture IoT
 Soil Sensors: IoT devices measure soil moisture and nutrient levels, guiding farmers in
irriga on and fer liza on.
 Crop Monitoring: Drones and IoT sensors collect data on crop health, helping in early
disease detec on and yield predic on.
 Livestock Management: IoT devices monitor the health and loca on of livestock,
improving animal welfare and produc vity.
8. Industry IoT (Industrial IoT or IIoT)
 Smart Manufacturing: IoT-enabled machines communicate and coordinate with each
other, op mizing produc on processes.
 Quality Control: IoT sensors detect defects in products during manufacturing,
ensuring high-quality output.
 Supply Chain Op miza on: IoT data helps in tracking materials and finished goods,
improving supply chain efficiency.
9. Health & Lifestyle IoT
 Remote Pa ent Monitoring: IoT devices monitor pa ents’ vital signs and send data to
healthcare providers, enabling remote care.
 Wearable Health Devices: Fitness trackers and smartwatches collect data on physical
ac vity, sleep, and heart rate, helping users maintain a healthy lifestyle.
 Smart Fitness Equipment: IoT-enabled gym equipment adjusts workouts based on
the user’s performance and health data.

Unit IV: IoT and M2M


M2M:
M2M Machine-to-Machine (M2M) refers to networking of machines (or devices) for the
purpose of remote monitoring and control and data exchange.

 Term which is o en synonymous with IoT is Machine-to-Machine (M2M).

 IoT and M2M are o en used inter changeably. Fig. Shows the end-to-end architecture of
M2M systems comprises of M2M area networks, communica on networks and applica on
fomain.
An M2M area network comprises of machines( or M2M nodes) whiach have embedded
network modules for sensing, actua on and communica ng various communic on protocols
can be used for M2M LAN such as ZigBee, Bluetooth, M-bus, Wireless M-Bus etc., These
protocols provide connec vity between M2M nodes within an M2M area network.

 The communica on network provides connec vity to remote M2M area networks. The
communica on network provides connec vity to remote M2M area network.

 The communica on networkcan use either wired or wireless network(IP based). While the
M2M are networks use either properietorary or non-IP baed communica on protocols, the
communica on network uses IP-based network. Since non-IP based protocols are used
within M2M area network, the M2M nodes within one network cannot communicate with
nodes in an externalnetwork.

 To enable the communica on between remote M2M are network, M2M gateways are used.

Fig. Shows a block diagram of an M2M gateway. The communica on between M2M nodes
and the M2M gateway is based on the communica on protocols which are naive to the M2M
are network. M2M gateway performs protocol transla ons to enable Ip-connec vity for M2M
are networks. M2M gateway acts as a proxy performing transla ons from/to na ve protocols
to/from Internet Protocol(IP). With an M2M gateway, each mode in an M2M area network
appears as a virtualized node for external M2M area networks.

Differences between IoT and M2M :


1) Communica on Protocols:
 Commonly uses M2M protocols include ZigBee, Bluetooth, ModBus, M-Bus,
WirelessM-Bustec.,
 In IoT uses HTTP, CoAP, WebSocket, MQTT,XMPP,DDS,AMQPetc.,
2) Machines in M2M Vs Things inIoT:
 Machines in M2M will be homogenous whereas Things in IoT will be
heterogeneous.
3) Hardware Vs So wareEmphasis:
 the emphasis of M2M is more on hardware with embedded modules, the
emphasis of IoT is more onso ware.
4) Data Collec on &Analysis
 M2M data is collected in point solu ons and o en in on-premises storage
infrastructure.
 The data in IoT is collected in the cloud (can be public, private or hybrid
cloud).
5) Applica ons
 M2M data is collected in point solu ons and can be accessed by on-premises
applica ons such as diagnosis applica ons, service management applica ons,
and on- premisis enterpriseapplica ons.
 IoT data is collected in the cloud and can be accessed by cloud applica ons
such as analy cs applica ons, enterprise applica ons, remote diagnosis and
management applica ons,etc.
SDN and NVF for IoT
So ware Defined Networking (SDN):
• So ware-DefinedNetworking (SDN) is a networking architecture that separates the
control plane from the data plane and centralizes the networkcontroller.
• So ware-based SDN controllers maintain a unified view of thenetwork
• Theunderlying infrastructure in SDN uses simple packet forwarding hardware as opposed
to specialized hardware in conven onalnetworks.

SDN Architecture Key elements of SDN:

Figure shows the SDN Architecture and SDN Layers in which the control and data planes
are decoupled and the network controller is centralized

1) Centralized NetworkController With decoupled control and data planes and centralized
network controller, the network administrators can rapidly configure the network.

2) Programmable OpenAPIs SDN architecture supports programmable open APIs for


interface between the SDN applica on and control layers (Northbound interface).
3) Standard Communica on Interface(OpenFlow)
 SDN architecture uses a standard communica on interface between the control and
infrastructure layers (Southbound interface). OpenFlow, which is defined by the Open
Networking Founda on (ONF) is the broadly accepted SDN protocol for the
Southboundinterface.

Network Func on Virtualiza on (NFV)


• Network Func on Virtualiza on (NFV) is a technology that leverages virtualiza on to
consolidate the heterogeneous network devices onto industry standard high volume servers,
switches andstorage.
• NFV is complementary to SDN as NFV can provide the infrastructure on which SDN can run.
• NFV and SDN are mutually beneficial to each other but not dependent.
• Network func ons can be virtualized without SDN similarly SDN can run without NFV.
Key elements of NFV:
• Virtualized Network Func on (VNF):
VNF is a so ware implementa on of a network func on which is capable of running over the
• NFV Infrastructure (NFVI).
NFVI includes compute, network and storage resources that are virtualized.
 NFV Management and Orchestra on:
NFV Management and Orchestra on focuses on all virtualiza on-specific management
tasks and covers the orchestra on and life-cycle management of physical and/or so ware
resources that support the infrastructure virtualiza on, and the life-cycle management of
VNFs.
NFV Use Case
 NFV can be used to virtualize the Home Gateway.
 The NFV infrastructure in the cloud hosts a virtualized Home Gateway.
 The virtualized gateway provides private IP addresses to the devices in the home.
 The virtualized gateway also connects to network services such as VoIP and IPTV.

NEED FOR IOT SYSTEMS MANAGEMENT


1. Automa ng Configura on
2. Monitoring Opera onal & Sta s cal Data
3. Improved Reliability
4. System Wide Configura ons
5. Mul ple System Configura ons
6. Retrieving & Reusing Configura ons
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.
• SNMP component include
• Network Management Sta on (NMS)
• Managed Device
• Management Informa on Base (MIB)

• SNMP Agent that runs on the device


Limita ons of SNMP
SNMP is stateless in nature and each SNMP request contains all the informa on to process
the request. The applica on needs to be intelligent to manage the device.
• SNMP is a connec onless protocol which uses UDP as the transport protocol, making it
unreliable as there was no support for acknowledgement of requests.
• MIBs o en lack writable objects without which device configura on is not possible using
SNMP.
• It is difficult to differen ate between configura on and state data in MIBs.
• Retrieving the current configura on from a device can be difficult with SNMP.

• Earlier versions of SNMP did not have strong security features. 18PCSC41-Interner of Things
2020-2021(Even) 13 M.Sc(CS) CS Department- MTNC
NETWORK OPERATOR REQUIREMENTS
Ease of use
• Dis nc on between configura on and state data
• Fetch configura on and state data separately
• Configura on of the network as a whole
• Configura on transac ons across devices
• Configura on deltas
• Dump and restore configura ons
• Configura on valida on
• Configura on database schemas
• Comparing configura ons
• Role-based access control
• Consistency of access control lists:
• Mul ple configura on sets
• Support for both data-oriented
NETCONF
Network Configura on Protocol (NETCONF) is a session-based network management
protocol. NETCONF allows retrieving state or configura on data and manipula ng
configura on data on network devices.

• NETCONF works on SSH transport protocol. Transport layer provides end-to-end connec vity
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 no fica ons.
• NETCONF provides various opera ons to retrieve and edit configura on data from network
devices.
• The Content Layer consists of configura on and state data which is XML-encoded.
• The schema of the configura on and state data is defined in a data modeling language called
YANG.
• NETCONF provides a clear separa on of the configura on and state data.
• The configura on data resides within a NETCONF configura on datastore on the server.

YANG
YANG is a data modeling language used to model configura on and state data manipulated
by the NETCONF protocol
• YANG modules contain the defini ons of the configura on data, state data, RPC calls that
can be issued and the format of the no fica ons.
• YANG modules defines the data exchanged between the NETCONF client and server.
18PCSC41-Interner of Things 2020-2021(Even) 16 M.Sc(CS) CS Department- MTNC
• A module comprises of a number of 'leaf' nodes which are organized into a hierarchical tree
structure. YANG Module Example
• 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 defini ons from other modules.
• Constraints can be defined on the data nodes, e.g. allowed values.
• YANG can model both configura on data and state data using the 'config' statement. This
YANG module is a YANG version of the toaster MIB
• The toaster YANG module begins with the header informa on followed by iden ty
declara ons which define various bread types.
• The leaf nodes (‘toasterManufacturer’ ‘toasterModelNumber’ and oasterStatus’) are
defined in the ‘toaster’ container.
• Each leaf node defini on has a type and op onally a descrip on and default value.
• The module has two RPC defini ons (‘make-toast’ and ‘cancel-toast’).

IoT Systems Management with NETCONF – YANG.


1) Management System
2) Management API
3) Transac on Manager
4) Rollback Manager
5) Data Model Manager 18PCSC41-Interner of Things 2020-2021(Even) 17
M.Sc(CS) CS Department- MTNC
6) Configura on Validator
7) Configura on Database
8) Configura on API
9) Data Provider API
1) Management System : The operator uses a management system to send NETCONF
messages to configure the IoT device and receives state informa on and no fica ons from
the device as NETCONFmessages.
2) Management API : allows management applica on to start NETCONFsessions.
3) Transac on Manager: executes all the NETCONF transac ons and ensures that ACID
proper es hold true for thetrasac ons.
4) Rollback Manager : is responsible for genera ng all the transac ons necessary to rollback
a current configura on to its original state.
5) Data Model Manager : Keeps track of all the YANG data models and the corresponding
managed objects. Also keeps track of the applica ons which provide data for each part of a
datam,odel.
6) Configura on Validator : checks if the resul ng configura on a er applying a transac on
would be a validconfigura on.
7) Configura on Database : contains both configura on and operas onaldata.
8) Configura on API : Using the configura on API the applica on on the IoT device can be
read configura on data from the configura on datastore and write opear onal data to the
opeara onaldatastore.

9) Data Provider API: Applica ons on the IoT device can register for callbacks for various
events using the Data Provider API. Through the Data Provider API, the applica ons can report
sta s cs and opear onaldata.
Steps for IoT device Management with NETCONF-YANG
1) Create a YANG model of the system that defines the configura on and state data of the
system.
2) Complete the YANG model with the ‗Inctool‘ which comes withLibnetconf.
3) Fill in the IoT device mangement code in the TransAPImodule.
4) Build the callbacks C file to generate the libraryfile.
5) Load the YANG module and the TransAPImodule into the Netopeer server using Netopeer
managertool.
6) The operator can now connect from the management system to the Netopeer server using
the NetopeerCLI.
7) Operator can issue NETCONF commands from the Netopeer CLI. Command can be issued
to changew the configura on dsta, get opera onal dat or execute an RPC on the IoTdevice.
Unit V: IoT Physical Devices and Endpoints
IoT Physical Devices and Endpoints:
A "Thing" in Internet of Things (IoT) can be any object that has a unique iden fier and which
can send/receive data (including user data) over a network (e.g., smart phone, smartTV,
computer, refrigerator, car, etc.).
• IoT devices are connected to the Internet and send informa on about themselves or about
their surroundings (e.g. informa on sensed by the connected sensors) over a network (to
other devices or servers/storage) or allow actua on upon the physical en es/environment
around them remotely.
IoT Device Examples
A home automa on device that allows remotely monitoring the status of appliances and
controlling the appliances.
• An industrial machine which sends informa on abouts its opera on and health monitoring
data to a server.
• A car which sends informa on about its loca on to a cloud-based service.
• A wireless-enabled wearable device that measures data about a person such as the
number of steps walked and sends the data to a cloud-based service.

Basic building blocks of an IoT Device:


1. Sensing: Sensors can be either on-board the IoT device or a ached to the device.
2. Actua on: IoT devices can have various types of actuators a ached that allow taking
ac ons upon the physical en es in the vicinity of the device.
3. Communica on: Communica on 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 applica ons.

 Wi-Fi: Provides high-speed internet connec vity.


 Bluetooth: Used for short-range communica on between devices.
 Zigbee: A low-power, low-data-rate wireless communica on standard.
 LoRaWAN: A long-range, low-power communica on protocol for IoT networks.
4. Analysis & Processing: Analysis and processing modules are responsible for making
sense of the collected data.
Block diagram of an IoT Device Exemplary Device:

Raspberry Pi:
Introduc on to Raspberry Pi:
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.
Since Raspberry Pi runs Linux opera ng system, it supports Python "out of the box".
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. Since Raspberry Pi runs Linux opera ng system, it supports Python "out of the box".
 Processor: ARM-based CPU.
 Memory: Varies by model, typically ranging from 512MB to 8GB of RAM.
 Connec vity: Includes USB ports, HDMI output, Ethernet, Wi-Fi, and Bluetooth.
 GPIO Pins: General-purpose input/output pins for connec ng sensors, actuators, and
other peripherals.

Se ng Up Raspberry Pi: To set up a Raspberry Pi, you need:


 MicroSD Card: For storing the opera ng system and files.
 Power Supply: Typically a 5V micro USB or USB-C power adapter.
 Peripherals: Keyboard, mouse, and monitor for ini al setup.
 Opera ng System: Raspbian (now called Raspberry Pi OS) is the recommended OS,
but other Linux distribu ons can also be used.
Programming Raspberry Pi: Raspberry Pi supports various programming languages, including
Python, C, C++, and Java. Python is the most popular choice due to its simplicity and extensive
libraries for IoT development.

Interfaces (Serial, SPI, I2C) :


1. Serial Interface (UART):
 UART (Universal Asynchronous Receiver/Transmi er) is a hardware communica on
protocol that uses two wires for communica on:
o TX (Transmit) for sending data
o RX (Receive) for receiving data
 It is asynchronous, meaning there is no clock signal shared between devices. Instead,
both devices must agree on the baud rate (the speed of data transmission, measured
in bits per second).
 Baud rates are commonly 9600, 115200, etc.
 Use Cases: It is commonly used for serial devices such as GPS modules, GSM modems,
microcontrollers, and sensors that need to send data one bit at a me.

Why We Use UART?


 Simple to implement
 Low overhead in terms of wiring (only two wires needed)
 Ideal for short-distance, point-to-point communica on
How to Interface UART with Raspberry Pi:
Step-by-Step Guide:
1. Raspberry Pi GPIO UART Pins:
o GPIO14 (TXD) and GPIO15 (RXD) are the pins used for UART communica on.
2. Wiring:
o Connect the TXD pin of the device to the RXD pin of the Raspberry Pi.
o Connect the RXD pin of the device to the TXD pin of the Raspberry Pi.
o Connect the GND of the device to the GND of the Raspberry Pi.
3. So ware Setup:
o By default, the UART interface is used for the console, so you need to disable it
for general-purpose use.

Commands:
sudo nano /boot/config.txt
Add the following lines to enable UART:
enable_uart=1

dtoverlay=pi3-miniuart-bt
Save and reboot the Raspberry Pi.
4. Python Code Example:
o You can use the pyserial library in Python for serial communica on.
Python Code:
import serial
import me
ser = serial.Serial('/dev/serial0', 9600) # Open the serial port
while True:
ser.write(b'Hello World\n') # Send data
me.sleep(1)

2. SPI (Serial Peripheral Interface)


 SPI is a synchronous serial communica on protocol primarily used for short-distance
communica on between a master device (e.g., Raspberry Pi) and one or more slave
devices.
 Key Lines:
o MOSI (Master Out, Slave In): Data sent from master to slave.
o MISO (Master In, Slave Out): Data sent from slave to master.
o SCLK (Serial Clock): Clock signal generated by the master.
o SS (Slave Select): Pin used to select which slave to communicate with.
 Use Cases: Commonly used for SD cards, sensors, and LCD displays due to its high-
speed data transfer capability.
Why Use SPI?
 Faster than UART and I2C
 Supports mul ple slave devices
 Suitable for high-speed data transfer
How to Interface SPI with Raspberry Pi:
Step-by-Step Guide:
1. Raspberry Pi GPIO SPI Pins:
o GPIO10 (MOSI), GPIO9 (MISO), GPIO11 (SCLK), and GPIO8 (CE0) for the first
slave.
o GPIO7 (CE1) can be used for a second slave.
2. Wiring:
o Connect the MOSI, MISO, SCLK, and SS pins of the slave device to the
corresponding pins on the Raspberry Pi.
o Connect GND from the slave device to the Raspberry Pi.
3. So ware Setup:
o Enable SPI in the Raspberry Pi using raspi-config:

Commands:
sudo raspi-config
Navigate to Interfacing Op ons -> SPI and enable it.
o Reboot the Raspberry Pi.
4. Python Code Example:
o Use the spidev library for SPI communica on.
Python Code
import spidev
spi = spidev.SpiDev()
spi.open(0, 0) # Open SPI bus 0, device (CS) 0

def read_adc(channel):
adc = spi.xfer2([1, (8 + channel) << 4, 0])
data = ((adc[1] & 3) << 8) + adc[2]

return data
while True:
print(read_adc(0)) # Read from ADC channel 0

3. I2C (Inter-Integrated Circuit)


Detailed Informa on:
 I2C is a synchronous, mul -master, mul -slave serial communica on protocol using
only two wires:
o SDA (Serial Data): Transfers data between devices.
o SCL (Serial Clock): Synchronizes data transfer.
 Each device on the I2C bus has a unique address.
 Use Cases: Used for connec ng low-speed peripherals like sensors, RTC modules, and
EEPROMs.
Why Use I2C?

 Requires only two wires


 Supports mul ple devices on the same bus
 Suitable for low-speed, short-distance communica on
How to Interface I2C with Raspberry Pi:
Step-by-Step Guide:
1. Raspberry Pi GPIO I2C Pins:
o GPIO2 (SDA) and GPIO3 (SCL) are used for I2C communica on.
2. Wiring:
o Connect the SDA and SCL pins of the device to the corresponding pins on the
Raspberry Pi.
o Connect GND from the device to the Raspberry Pi.
3. So ware Setup:
o Enable I2C using raspi-config:
Commands:
sudo raspi-config
Navigate to Interfacing Op ons -> I2C and enable it.
o Install I2C tools for debugging:
sudo apt-get install -y i2c-tools
o Use i2cdetect to find connected devices:
i2cdetect -y 1

4. Python Code Example:


o Use the smbus library for I2C communica on.
Python Code:
import smbus
bus = smbus.SMBus(1) # I2C bus number
device_address = 0x48 # Replace with your device address
def read_temp():
temp = bus.read_byte_data(device_address, 0)
return temp
while True:
print(read_temp()) # Read temperature from device
Difference Between SPI & I2C

Programming with Raspberry Pi


Python Programming with Raspberry Pi: Python is the most popular programming language
for Raspberry Pi due to its simplicity and extensive libraries. Here's a focus on interfacing
external gadgets, controlling output, and reading input from pins.

1. Interfacing External Gadgets:


 GPIO Library: The RPi.GPIO library in Python allows you to control the GPIO pins on
the Raspberry Pi.
 Example: Interfacing an LED and a bu on.
Python
import RPi.GPIO as GPIO
import me
# Set up GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT) # LED pin
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Bu on pin

try:
while True:
bu on_state = GPIO.input(23)
if bu on_state == GPIO.LOW:
GPIO.output(18, GPIO.HIGH) # Turn on LED
else:
GPIO.output(18, GPIO.LOW) # Turn off LED
me.sleep(0.1)
except KeyboardInterrupt:

GPIO.cleanup()

2. Controlling Output:

 Example: Controlling a servo motor.


python
import RPi.GPIO as GPIO
import me

# Set up GPIO
GPIO.setmode(GPIO.BCM)

GPIO.setup(18, GPIO.OUT)

# Set up PWM
pwm = GPIO.PWM(18, 50) # 50Hz frequency
pwm.start(0)

try:
while True:
pwm.ChangeDutyCycle(7.5) # Neutral posi on
me.sleep(1)
pwm.ChangeDutyCycle(12.5) # 180 degrees
me.sleep(1)
pwm.ChangeDutyCycle(2.5) # 0 degrees
me.sleep(1)
except KeyboardInterrupt:
pwm.stop()

GPIO.cleanup()

3. Reading Input from Pins:

 Example: Reading data from a temperature sensor (e.g., DHT11).


python
import Adafruit_DHT
# Set up sensor
sensor = Adafruit_DHT.DHT11
pin = 4 # GPIO pin where the sensor is connected

try:
while True:
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
if humidity is not None and temperature is not None:
print(f'Temp: {temperature}°C Humidity: {humidity}%')
else:
print('Failed to get reading. Try again!')
me.sleep(2)
except KeyboardInterrupt:
pass

You might also like