0% found this document useful (0 votes)
24 views31 pages

Iot Unit3

Jutuk IOT pdfs

Uploaded by

Crazy Creations
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)
24 views31 pages

Iot Unit3

Jutuk IOT pdfs

Uploaded by

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

UNIT-3

IOT APPLICATION DEVELOPMENT


Communication:
IoT devices are found everywhere and will enable circulatory intelligence in the future. For
operational perception, it is important and useful to understand how various IoT devices
communicate with each other. Communication models used in IoT have great value. The
IoTs allow people and things to be connected any time, any space, with anything and
anyone, using any network and any service.
Types of Communication Model:
1. Request & Response Model –
This model follows a client-server architecture.
• The client, when required, requests the information from the server. This request
is usually in the encoded format.
• This model is stateless since the data between the requests is not retained and
each request is independently handled.
• The server Categories the request, and fetches the data from the database and its
resource representation. This data is converted to response and is transferred in
an encoded format to the client. The client, in turn, receives the response.
• On the other hand — In Request-Response communication model client sends a
request to the server and the server responds to the request. When the server
receives the request it decides how to respond, fetches the data retrieves
resources, and prepares the response, and sends it to the client .

2. Publisher-Subscriber Model –
This model comprises three entities: Publishers, Brokers, and Consumers.
• Publishers are the source of data. It sends the data to the topic which are
managed by the broker. They are not aware of consumers.
• Consumers subscribe to the topics which are managed by the broker.
• Hence, Brokers responsibility is to accept data from publishers and send it to
the appropriate consumers. The broker only has the information regarding the
consumer to which a particular topic belongs to which the publisher is unaware
of.

3. Push-Pull Model –
The push-pull model constitutes 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 situations where there is a mismatch
between the rate at which the producers push the data and consumers pull the
data.

4. Exclusive Pair –
• Exclusive Pair is the bi-directional model, including full-duplex communication
among client and server. The connection is constant and remains open till the
client sends a request to close the connection.
• The Server has the record of all the connections which has been opened.
• This is a state-full connection model and the server is aware of all open
connections.

5.Device-to-device (D2D): This type of communication allows devices to


communicate directly with each other without the need for a central server. This is
useful for applications where low latency and reliability are important, such as in
industrial control systems or smart homes.

6.Device-to-cloud (D2C): This type of communication allows devices to send data to


a central cloud server for storage, processing, and analysis. This is the most common
type of IoT communication, and it is used in a wide range of applications, such as
smart cities, smart homes, and wearable devices.

7.Cloud-to-device (C2D): This type of communication allows a central cloud server


to send data to devices. This is useful for applications where devices need to be
updated with new firmware or configuration data.

8.Peer-to-peer (P2P): This type of communication allows devices to communicate


directly with each other without the need for a central server. This is useful for
applications where low latency and reliability are important, and where there is no
need to send data to a central server.

9.Machine-to-machine (M2M): This type of communication allows machines to


communicate with each other without human intervention. This is useful for
applications in industrial automation, smart cities, and transportation.
SENSOR:
A sensor converts physical energy like heat, sound, strain, pressure, vibrations and
motion into electrical energy. An electronic circuit connects to the input at a sensor.
The circuit receives the output of the sensor. The output is according to the variation
in physical condition. A smart sensor includes the electronic circuit within itself, and
includes computing and communication capabilities.

A sensor can sense a change in physical parameters, such as temperature, pressure,


light, metal, smoke and proximity to an object. Sensors can also sense acceleration,
orientation, location, vibrations or smell, organic vapours or gases.

Analog Sensors

Analog sensors use a sensor and an associated electronic analog circuit. Analog
sensors generate analog outputs as per the physical environmental parameters, such as
temperature, strain, pressure, force, flex, vapours, magnetic field, or proximity.

Digital Sensors

A specific electronic component or circuit gives digital output 1 or 0 (on-off state) or


output of 1s and 0s as a binary number (corresponding to a set of on-off states). A
digital sensor uses the sensor and has an associated electronic circuit which gives
digital output. The output 1 or 0 (1s and 0s) is read through a port in a
microcontroller.

Examples of Sensors
Temperature
A component called thermistor, shows larger changes in resistance within narrow
environment temperature range (120°C to –90°C). An NTC thermistor shows negative
temperature coefficient which means a drop in the resistance value with rise in
temperature.
A temperature sensor is called PTC, when it exhibits a Positive Temperature
Coefficient. Resistance value of a PTC resistor rises with rise in temperature.
Humidity
Humidity is measured in percentage. It is the relative percentage ratio (RH%) of
content of water vapours in air compared to one in a situation of maximum possible
water vapour content for the air temperature at the instance of measurement.
Distance
Infrared (IR) sensor is useful for a 0.15 m to 0.8 m range of object. IR sensor works on
the principle that when a narrow beam IR LED sends radiation at an inclined angle, the
nearby phototransistor FPT receives the reflected radiation after travelling two times
the object distance
Light
A photoconductor can be used to detect light in the vicinity. The sensor shows a drop in
resistance with surrounding light.

Acceleration
A Micro-Electro-Mechanical Sensor (MEMS) detects linear accelerations ax, ay and az
along three axes x, y and z, respectively. An MEMS moves when a mass moves along a
direction.
Vibrations and Shocks
Alternatively, MEMS may use piezoelectric effect in place of capacitive change
effects. The effect observed in certain specific materials is accumulation of electric
changes on surfaces due to mechanical compression of the piezoelectric material.
Angular Acceleration and Change in Direction (Angle)
Gyroscope is a sensor which measures the change in angular velocity (angular
acceleration) and the change in direction (angle). An application takes measurements
using a gyroscope or accelerometer and the system initiates actions as programmed. For
example, mobile gaming application uses in-motion gestures of a player when
deploying a gyroscope.
Orientation and Direction Compass
A gyroscope can be used as an electronic compass or a digital compass as it shows the
change in direction (angle).
Electric Current
Alternating Current (AC) is detected by a miniature transformer and its associated
circuitry. A Direct Current (DC) flows in one direction at all instances. It detects using a
sensor circuit, which detects the magnetic field by flowing current.
Sound
A microphone is used to sense sound. A readily available electronic board with a
microphone connects to the microcontroller, which can control an actuator for actions
based on the sensed sound, or recognise the voice and then take required action, such as
dialing a number using the actuator circuit or switching on the car.
Pressure Sensors
Pressure P is measured as force per m2 . Pressure can be sensed in a number of ways.
The sensor is called pressure transducer, pressure transmitter, pressure sender or
pressure indicator. Piezometer pressure transducer uses a piezoelectric object between
two surfaces. The compression creates electric charges on the opposite surfaces of the
object.
GPS
Location determination can be done using a Global Positioning System (GPS), also
known as Geographical Positioning System. A user can receive the location from a
service provider.
Camera
Camera is an image sensor. The camera uses CCD, which consists of a large number of
pixels, exposed to the light from the image. It accumulates charges on each of the pixel
present at a large number of horizontal and vertical coordinates.

ACTUATOR:
An actuator is a device that takes actions as per the input command, pulse or state (1 or 0), or
set of 1s and 0s, or a control signal. An attached motor, speaker, LED or an output device
converts electrical energy into physical action.

Examples of applications of actuators are:

● Light sources

● LEDs

● Piezoelectric vibrators and sounders


● Speakers
● Solenoids
● Servomotor
● Relay switch
● Switching on a set of streetlights
● Application of brakes in a moving vehicle
● Ringing of alarm bell
● Switching off or on a heater or air-conditioner or boiler current in a steam boiler in a
thermal plant.
Light Source
Traffic lights are examples of function of light sources as actuators controlled by the
inputs.
LED
LED is an actuator which emits light or infrared radiation. Uses of different colour
LEDs,
RGB (Red-Green-Blue) LEDs, intensity variation of LED and colours, graphic and text
display using big screens are actions which are controlled using the inputs. RGB LED
has three inputs to control, i.e. R, G and B components and thus the composite colour.
Pulse width modulated pulses control the LED light emission intensity. A
microcontroller is used for generating PWM outputs.
Piezoelectric Vibrator
Piezoelectric crystals when applied in varying electric voltages at the input generate
vibrations.
Piezoelectric Speaker
A piezoelectric speaker enables synthesised music tunes and sounds. The appropriately
programmed pulses generate the music, sounds, buzzers and alarms when they are the
input to the speaker. A microcontroller is used for generating PWM outputs for actions
using speakers.
Solenoid
A solenoid is an actuator consisting of a number of cylindrically wound coils. The flow
of current creates a magnetic field in proportion to the number of turns in the solenoid
and the current in it.
Motor
A motor can be DC (direct current controlled) or AC (alternating current controlled). IO
modules are readily available to receive the control digital inputs of 1s and 0s and
deliver
high currents. The dc or ac rotates the motor. A cam also converts rotator motion into
linear motion when it rotates using a motor.
Servomotor
Servomotor is a geared DC motor for applications such as robotics. It rotates the shaft
of
a motor. The shaft of the motor can be controlled and positioned or rotated through
180°
(+90°) degrees. The shaft’s angular position is controlled through 180°, between –90°
and +90° degrees.
Relay Switch
An electronic switch can be controlled by the input 1 or 0 from the port pin of a
microcontroller or through a push button switch and battery. The current flows through
the switch or voltage applies through the switch depending upon the input state 1 or 0.
A relay switch makes mechanical contact when the input circuit magnetises with a
control circuit and pulls a lever to make the contact.

I/O INTERFACES:
Input/output (I/O) interfaces in the Internet of Things (IoT) are the physical and logical
connections that allow IoT devices to communicate with each other and with the outside
world. I/O interfaces can be wired or wireless, and they can be used to connect to a variety of
sensors, actuators, and other devices.

Some of the most common I/O interfaces used in IoT include:

• Serial interfaces: Serial interfaces, such as RS-232 and RS-485, are commonly used to
connect IoT devices to sensors and actuators. Serial interfaces are relatively simple to
implement and they can be used to transmit data over long distances.
• Parallel interfaces: Parallel interfaces, such as the General-Purpose Input/Output
(GPIO) interface, are commonly used to connect IoT devices to multiple sensors and
actuators. Parallel interfaces can transmit data faster than serial interfaces, but they are
more complex to implement and they have a shorter range.
• Wireless interfaces: Wireless interfaces, such as Bluetooth, Wi-Fi, and ZigBee, are
commonly used to connect IoT devices to each other and to the internet. Wireless
interfaces are convenient and flexible, but they can be more susceptible to
interference than wired interfaces.

The choice of I/O interface for an IoT device depends on a number of factors, including the
type of sensors and actuators being used, the required data rate, the desired range, and the
cost and complexity of the implementation.

Here are some examples of how I/O interfaces are used in IoT:

• A smart thermostat uses a serial interface to connect to a temperature sensor. The


thermostat uses the temperature data to adjust the temperature in the building.
• A smart home security system uses a parallel interface to connect to multiple door and
window sensors. The security system uses the sensor data to detect break-ins.
• A wearable fitness tracker uses a wireless interface to connect to a smartphone. The
fitness tracker sends the smartphone data about the user's heart rate, steps taken, and
calories burned.

Input/output is used as a method which helps in transferring of information between the


internal storage devices i.e. memory and the external peripheral device. A peripheral device
is that which provide input and output for the computer, it is also called Input-Output
devices.
For Example, computer i/o interfaces
A keyboard and mouse provide Input to the computer are called input devices while a
monitor and printer that provide output to the computer are called output devices. Just like
the external hard-drives, there is also availability of some peripheral devices which are able
to provide both input and output.

The major differences are as follows:


1. The nature of peripheral devices is electromagnetic and electro-mechanical. The
nature of the CPU is electronic. There is a lot of difference in the mode of
operation of both peripheral devices and CPU.
2. There is also a synchronization mechanism because the data transfer rate of
peripheral devices are slow than CPU.
3. In peripheral devices, data code and formats are differ from the format in the
CPU and memory.
4. The operating mode of peripheral devices are different and each may be
controlled so as not to disturb the operation of other peripheral devices
connected to CPU.

Functions
● It's utilized to keep the CPU's operating speed in sync with the input-output
devices.
● It chooses the input-output device that is best suited for the input-output device's
interpretation.
● It can send out signals such as control and timing signals.
● Data buffering is possible through the data bus in this case.
● There are several types of error detectors.
● Serial data is converted to parallel data and vice versa.
● It can also convert digital data to analog signals and the other way around.

Software Components- Programming API’s (using Python / Node.js


/Arduino) for Communication
The Arduino Rest API is a way for Arduino and other external systems to
communicate data. It is possible to operate Arduino from afar using the Arduino Rest
API framework. The confluence of APIs and IoT creates new integration possibilities.
The creation of an API ecosystem is a fascinating topic, and the way we use APIs to
access IoT services exposed by remote IoT boards is a difficult component.
In greater detail, a client application uses the Arduino Rest API to read or transmit
data to the Arduino board. An external system or application that retrieves sensor
values is a common use case for HTTP Rest API.
When different systems and boards are connected and share information, the
Arduino Rest API framework can be used in IoT projects. The Arduino Rest API is used
by IoT cloud companies as well. This type of method is used when an external
application (client) submits a request to Arduino, and Arduino responds with data.
Because the Arduino Rest API uses the HTTP protocol, these queries are synchronous.
Other protocols, like as MQTT, can be utilized in IoT applications. When Arduino is
acting as a server in a client-server scenario, the Arduino API over HTTP plays a
critical role. MQTT, for example, employs a structure known as publish-subscribe.
Arduino rest framework
There is an intriguing library called aRest that may be used to construct a Rest API
architecture. This library is a framework for Restful services that includes a number
of useful features. This library works with a variety of development boards, including
Arduino, Raspberry Pi, and ES8266. More information is available on the aRest
website.
This library is easy to use and may be acquired from the Arduino library directly
through the Arduino IDE.
We can implement the API using this library because it supports aRest:
● Reading pin values in rest style
● Writing pin values in rest style
● Remote sketch function call

Protocols-MQTT
MQTT (Message Queuing Telemetry Transport) is an IBM-developed lightweight
messaging protocol that was initially introduced in 1999. It interprets
communications between devices, servers, and applications using the pub/sub
pattern.
The MQTT protocol was established with the goal of connecting sensors on oil
pipelines to communications satellites with the least amount of battery loss and
bandwidth use possible.
MQTT has been evolving since its creation, with version 5.0 being released in May
2018. Version 3.1.1 was accepted as an ISO standard after being submitted to the
OASIS consortium in 2013.
Advantages
The following are some of the advantages of MQTT:
● Lightweight code footprint - The MQTT protocol requires only a few lines of code
to get up and running on devices.
● Minimized data packets - MQTT is a low-energy protocol. If a device is batterypowered or
has a low CPU, this is ideal.
● Speed - Outside of QoS, MQTT functions in real time with no delays.
● Ease of Implementation - MQTT includes libraries in a number of programming
languages, including Elixir and Python.
● Last will and testament - If a client disconnects abruptly, you can send a message
to all subscribers with information on how to fix the problem.
● Retained messages - When a client subscribes to a topic, it will automatically get
one retained message for that subject (like a pinned post on social media).

MQTT architecture
In the MQTT protocol, connected devices are known as "clients," and they
communicate with a server known as the "broker." Data communication between
clients is handled by the broker.
When a customer (known as a "publisher") wants to disseminate information, it
publishes to a specific topic, which the broker then distributes to any clients who have
subscribed to that topic (known as "subscribers").
The publisher does not require information on the number of subscribers or their
locations. As a result, subscribers do not require any information about the publisher.
Any client can be both a publisher and a subscriber. The clients are usually unaware
of each other and are only aware of the broker who acts as an intermediary. The
“pub/sub model” is a popular term for this structure.

MQTT messages
A “publish” occurs when a customer wishes to submit data to the broker. A client will
"subscribe" to a subject or topics if they desire to get data from the broker. When a
client subscribes to a topic, it will get all future messages that are published on that
subject.
The publisher additionally sends a QoS (Quality of Service) level along with the
message. This level specifies the message's delivery guarantee. The following are the
levels of QoS:
● At most once - The broker will only get the message "at most once" after it is
published. This level should not be utilized for mission-critical information since it
increases the danger of the message not being received by the intended recipients.
● At least once - The publisher will continue to resend the message until it obtains a
response from the broker on the specific message. In other words, ensuring that the
message is received is more critical than ensuring that it is only received once. This is
most likely the most used QoS level.
● Exactly once - The publisher and the broker collaborate to ensure that the broker
receives and acts on messages only once. This necessitates some more effort in the
form of a four-part handshake. This is the safest QoS level, but it's also the slowest,
therefore, it's only used when absolutely required.

ZigBee
ZigBee is a Personal Area Network task group with low rate task group 4. It is a technology
of home networking. ZigBee is a technological standard created for controlling and sensing
the network. As we know that ZigBee is the Personal Area Network of task group 4 so it is
based on IEEE 802.15.4 and is created by Zigbee Alliance.
ZigBee is an open, global, packet-based protocol designed to provide an easy-to-use
architecture for secure, reliable, low power wireless networks. Flow or process control
equipment can be place anywhere and still communicate with the rest of the system. It can
also be moved, since the network doesn’t care about the physical location of a sensor, pump
or valve.
IEEE802.15.4 developed the PHY and MAC layer whereas, the ZigBee takes care of upper
higher layers.
ZigBee is a standard that addresses the need for very low-cost implementation of Low power
devices with Low data rates for short-range wireless communications.
IEEE 802.15.4 supports star and peer-to-peer topologies. The ZigBee specification supports
star and two kinds of peer-to-peer topologies, mesh and cluster tree. ZigBee-compliant
devices are sometimes specified as supporting point-to-point and point-to-multipoint
topologies.
Types of ZigBee Devices:
Zigbee Coordinator Device: It communicates with routers. This device is used for connecting
the devices.
Zigbee Router: It is used for passing the data between devices.
Zigbee End Device: It is the device that is going to be controlled.

General Characteristics of Zigbee Standard:


Low Power Consumption
Low Data Rate (20- 250 kbps)
Short-Range (75-100 meters)
Network Join Time (~ 30 msec)
Support Small and Large Networks (up to 65000 devices (Theory); 240 devices (Practically))
Low Cost of Products and Cheap Implementation (Open Source Protocol)
Extremely low-duty cycle.
3 frequency bands with 27 channels.
Operating Frequency Bands (Only one channel will be selected for use in a network):
Channel 0: 868 MHz (Europe)
Channel 1-10: 915 MHz (the US and Australia)
Channel 11-26: 2.4 GHz (Across the World)
Features of Zigbee:
1. Stochastic addressing: A device is assigned a random address and announced. Mechanism
for address conflict resolution. Parents node don’t need to maintain assigned address table.
2. Link Management: Each node maintains quality of links to neighbors. Link quality is used
as link cost in routing.
3. Frequency Agility: Nodes experience interference report to channel manager, which then
selects another channel
4. Asymmetric Link: Each node has different transmit power and sensitivity. Paths may be
asymmetric.
5. Power Management: Routers and Coordinators use main power. End Devices use batteries.
Architecture of Zigbee:
Zigbee architecture is a combination of 6 layers.

Physical layer: The lowest two layers i.e the physical and the MAC (Medium Access
Control) Layer are defined by the IEEE 802.15.4 specifications. The Physical layer is closest
to the hardware and directly controls and communicates with the Zigbee radio.
Medium Access Control layer (MAC layer): The layer is responsible for the interface
between the physical and network layer. The MAC layer is also responsible for providing
PAN ID and also network discovery through beacon requests.
Network layer: This layer acts as an interface between the MAC layer and the application
layer. It is responsible for mesh networking.
Application layer: The application layer in the Zigbee stack is the highest protocol layer and
it consists of the application support sub-layer and Zigbee device object. It contains
manufacturer-defined applications.
Zigbee Applications:
Home Automation
Medical Data Collection
Industrial Control Systems
meter reading system
light control system
Commercial
Government Markets Worldwide
Home Networking
CoAP(constrained application protocol):
CoAP stands for Constrained Application Protocol and it is defined in RFC 7252. CoAP is a
simple protocol with low overhead specifically designed for constrained devices (such as
microcontrollers) and constrained networks. This protocol is used in M2M data exchange and
it is very similar to HTTP
The main features of CoAP protocols are:
Web protocol used in M2M with constrained requirements
Asynchronous message exchange
Low overhead and very simple to parse
URI and content-type support
Proxy and caching capabilities
some features are very similar to HTTP even if CoAP must not be considered a compressed
HTTP protocol because CoAP is specifically designed for IoT and in more details for M2M
so it is very optimized for this task.
From the abstraction protocol layer, CoAP can be represented as:
there are two different layers that make CoAp protocol: Messages and Request/Response.
The Messages layer deals with UDP and with asynchronous messages. The Request/Response
layer manages request/response interaction based on request/response messages.
CoAP supports four different message types:
• Confirmable
• Non-confirmable
• Acknowledgment
• Reset
CoAP Messages Model
This is the lowest layer of CoAP. This layer deals with UDP exchanging messages between
endpoints. Each CoAP message has a unique id, this is useful to detect message duplicates. A
CoAP message is built by these parts:
a binary header
a compact option
payload
The CoAP protocol uses two kinds of messages:
• Confirmable message
• Non-confirmable message
A confirmable message is a reliable message. When exchanging messages between two
endpoints, these messages can be reliable. In CoAP a reliable message is obtained using a
Confirmable message (CON). Using this kind of message, the client can be sure that the
message will arrive at the server. A Confirmable message is sent again and again until the
other party sends an acknowledge message (ACK). The ACK message contains the same ID
of the confirmable message (CON).

The picture below shows the message exchange process:

If the server has troubles managing the incoming request it can send back a Rest message
(RST) instead of the Acknowledge message (ACK):
The other message category is the Non-confirmable (NON) messages. These are messages
that don’t require an Acknowledge by the server. They are unreliable messages or in other
words messages that do not contain critical information that must be delivered to the server.
To this category belongs messages that contain values read from sensors.

Even if these messages are unreliable, they have a unique ID.

CoAP Request/Response Model


The CoAP Request/Response is the second layer in the CoAP abstraction layer. The request is
sent using a Confirmable (CON) or Non-Confirmable (NON) message. There are several
scenarios depending on if the server can answer immediately to the client request or the
answer if not available:

If the server can answer immediately to the client request then if the request is carried using a
Confirmable message (CON) then the server sends back to the client an Acknowledge
message containing the response or the error code:
TCP/IP PROTOCOL:
TCP/IP was designed and developed by the Department of Defense (DoD) in the 1960s and is
based on standard protocols. It stands for Transmission Control Protocol/Internet Protocol.
The TCP/IP model is a concise version of the OSI model. It contains four layers, unlike the
seven layers in the OSI model.
The main work of TCP/IP is to transfer the data of a computer from one device to another.
The main condition of this process is to make data reliable and accurate so that the receiver
will receive the same information which is sent by the sender. To ensure that, each message
reaches its final destination accurately, the TCP/IP model divides its data into packets and
combines them at the other end, which helps in maintaining the accuracy of the data while
transferring from one end to another end.
Layers of TCP/IP Model
• Application Layer
• Transport Layer (TCP/UDP)
• Network/Internet Layer (IP)
• Data Link Layer (MAC)
• Physical Layer

1. Physical Layer
It is a group of applications requiring network communications. This layer is
responsible for generating the data and requesting connections. It acts on behalf of the
sender and the Network Access layer on the behalf of the receiver.
2. Data Link Layer
The packet’s network protocol type, in this case, TCP/IP, is identified by the data-link
layer. Error prevention and “framing” are also provided by the data-link layer. Point-
to-Point Protocol (PPP) framing and Ethernet IEEE 802.2 framing are two examples
of data-link layer protocols.
3. Internet Layer
This layer parallels the functions of OSI’s Network layer. It defines the protocols
which are responsible for the logical transmission of data over the entire network. The
main protocols residing at this layer are as follows:

IP: IP stands for Internet Protocol and it is responsible for delivering packets from the
source host to the destination host by looking at the IP addresses in the packet
headers. IP has 2 versions: IPv4 and IPv6. IPv4 is the one that most websites are using
currently. But IPv6 is growing as the number of IPv4 addresses is limited in number
when compared to the number of users.
ICMP: ICMP stands for Internet Control Message Protocol. It is encapsulated within
IP datagrams and is responsible for providing hosts with information about network
problems.
ARP: ARP stands for Address Resolution Protocol. Its job is to find the hardware
address of a host from a known IP address. ARP has several types: Reverse ARP,
Proxy ARP, Gratuitous ARP, and Inverse ARP.
Example: Imagine that you are using a computer to send an email to a friend. When
you click “send,” the email is broken down into smaller packets of data, which are
then sent to the Internet Layer for routing. The Internet Layer assigns an IP address to
each packet and uses routing tables to determine the best route for the packet to take
to reach its destination. The packet is then forwarded to the next hop on its route until
it reaches its destination. When all of the packets have been delivered, your friend’s
computer can reassemble them into the original email message.
In this example, the Internet Layer plays a crucial role in delivering the email from
your computer to your friend’s computer. It uses IP addresses and routing tables to
determine the best route for the packets to take, and it ensures that the packets are
delivered to the correct destination. Without the Internet Layer, it would not be
possible to send data across the Internet.
4. Transport Layer
The TCP/IP transport layer protocols exchange data receipt acknowledgments and
retransmit missing packets to ensure that packets arrive in order and without error.
End-to-end communication is referred to as such. Transmission Control Protocol
(TCP) and User Datagram Protocol are transport layer protocols at this level (UDP).

TCP: Applications can interact with one another using TCP as though they were
physically connected by a circuit. TCP transmits data in a way that resembles
character-by-character transmission rather than separate packets. A starting point that
establishes the connection, the whole transmission in byte order, and an ending point
that closes the connection make up this transmission.
5.Application Layer
This layer is analogous to the transport layer of the OSI model. It is responsible for
end-to-end communication and error-free delivery of data. It shields the upper-layer
applications from the complexities of data. The three main protocols present in this
layer are:
HTTP and HTTPS: HTTP stands for Hypertext transfer protocol. It is used by the
World Wide Web to manage communications between web browsers and servers.
SSH: SSH stands for Secure Shell. It is a terminal emulations software similar to
Telnet. The reason SSH is preferred is because of its ability to maintain the encrypted
connection.
NTP: NTP stands for Network Time Protocol. It is used to synchronize the clocks on
our computer to one standard time source. you carry out a transaction, where your
computer reads the time at 2:30 PM while the server records it at 2:28 PM. The server
can crash very badly if it’s out of sync.
BLUETOOTH SMART CONNECTIVITY
Bluetooth overview
i. Bluetooth is a short-range wireless technology standard that is used for exchanging data
between fixed and mobile devices over short distances using Ultra high frequency radio
waves in the ISM (industrial, scientific and medical) bands, from 2.402 to 2.48 GHz, and
building personal area networks (PANs). ii. It is mainly used as an alternative to wire
connections, to exchange files between nearby portable devices and connect cell phones
and music players with wireless headphones. In the most widely used mode, transmission
power is limited to 2.5 milliwatts, giving it a very short range of up to 10 metres (33 ft).

a. Bluetooth links
i. To provide effective mechanisms for the data transfer over a Bluetooth link, there are
number of protocols and different types of link. There are two main types of Bluetooth link
that are available and can be set up:
SCO Synchronous Connection Orientated communications link
ACL Asynchronous Connectionless communications Link
The Bluetooth link that is used is determined by the type of Bluetooth data transfer
required.
i. SCO: The SCO or Synchronous Connection Orientated communications link is
used where data is to be streamed rather than transferred in a framed format. The
SCO can operate alongside the ACL channels
ii. ACL: The ACL or Asynchronous Connectionless Communications Link is possible
the most widely used form of Bluetooth link. The ACL Bluetooth link is used for
carrying framed data - i.e. data submitted from an application to logical link control
and adaptation protocol channel. The channel may support either unidirectional or
bidirectional Bluetooth data transfer.

b. Bluetooth connection basics


i. Bluetooth is a system in which connections are made between a master and a slave.
These connections are maintained until they are broken, either by deliberately
disconnecting, or by communications cannot be maintained - typically this occurs as the
devices go out of range of each other.
ii. The way in which Bluetooth devices make connections is more complicated than
many other types of wireless device. The reason for this is the frequency hopping nature of
the devices.
iii. Within the connection process, there are four types of Bluetooth connection
channel: Basic piconet channel, Adapted piconet channel, Inquiry channel & Paging
channel
c. Bluetooth pairing
i. The devices can connect easily and quickly, known as Bluetooth pairing. Once
Bluetooth pairing has occurred two devices may communicate with each other.
ii. Bluetooth pairing is generally initiated manually by a device user. The Bluetooth
link for the device is made visible to other devices. They may then be paired.
iii. The Bluetooth pairing process is typically triggered automatically the first time a
device receives a connection request from a device with which it is not yet paired. In order
that Bluetooth pairing may occur, a password has to be exchanged between the two
devices. This password or "Passkey" as it is more correctly termed is a code shared by both
Bluetooth devices. It is used to ensure that both users have agreed to pair with each other.
iv. The process of Bluetooth pairing is summarised below:
a. Bluetooth device looks for other Bluetooth devices in range
b. Two Bluetooth devices find each other
c. Prompt for Passkey
Device 1 sends passkey: The initiating device, Device 1 sends the passkey that has been
entered to Device 2.
Device 2 sends passkey: The passkeys are compared and if they are both the same, a
trusted pair is formed, Bluetooth pairing is established. d. Communication is established

d. Bluetooth security basics


i. Bluetooth security is important as devices are subject to a variety of wireless and
networking attacking (including denial of service attacks, eavesdropping, man-in-the-
middle attacks, message modification, and resource misappropriation).
ii. Bluetooth security must address these attacks in Bluetooth implementations and
specifications. These may include attacks against improperly secured Bluetooth
implementations which can provide attackers with unauthorized access.
iii. Many Bluetooth network has an issue with Bluetooth security, hackers may be able
to gain access to information from phone lists to more sensitive information.
There are three basic means of providing Bluetooth security:
Authentication: In this process the identity of the communicating devices are verified.
User authentication is not part of the main Bluetooth security elements of the specification.
Confidentiality: This process prevents information being eavesdropped by ensuring that
only authorised devices can access and view the data.
Authorisation: This process prevents access by ensuring that a device is authorised to use
a service before enabling it to do so.

e. Common Bluetooth security issues


There are a number of ways in which Bluetooth security can compromised often. The
major forms of Bluetooth security problems fall into the following categories:
i. Bluejacking: Bluejacking is often not a major malicious security problem,
although there can be issues with it, especially as it enables someone to get their
data onto another person's phone, etc. Bluejacking involves the sending of a vCard
message via Bluetooth to other Bluetooth users within the locality - typically 10
metres. The aim is that the recipient will not realise what the message is and allow
it into their address book. Thereafter messages might be automatically opened
because they have come from a supposedly known contact
ii. ii. Bluebugging: This more of an issue. This form of Bluetooth security issue
allows hackers to remotely access a phone and use its features. This may include
placing calls and sending text messages while the owner does not realise that the
phone has been taken over.
iii. Car Whispering: This involves the use of software that allows hackers to send and
receive audio to and from a Bluetooth enabled car stereo system.
Bluetooth versions
Bluetooth Key Versions Bluetooth 1.0 and 1.0B
Products weren't able to exchange and make use of information. The condition of being
anonymous wasn't possible and preventing certain services from using Bluetooth
environments

Bluetooth 1.1
i. Ratified as IEEE Standard 802.15.1 ii. Many errors
found in the v1.0B specifications were fixed. iii. Added
possibility of non-encrypted channels. iv. Received
Signal Strength Indicator (RSSI).

Bluetooth 1.2
Major enhancements include:
• Faster Connection and Discovery
• Adaptive frequency-hopping spread spectrum (AFH), which improves resistance to
radio frequency interference by avoiding the use of crowded frequencies in the
hopping sequence.
• Higher transmission speeds in practice, up to 721 kbit/s.
• Extended Synchronous Connections (eSCO), which improve voice quality of audio
links.
• Host Controller Interface (HCI) operation with three-wire UART.
• Ratified as IEEE Standard 802.15.1

Bluetooth 2.0 + EDR


The introduction of an Enhanced Data Rate (EDR) for faster data transfer. The bit rate of
EDR is 3 Mbit/s, although the maximum data transfer rate is 2.1 Mbit/s. EDR uses a
combination of Gaussian frequency-shift keying (GFSK) and phase-shift keying
modulation (PSK).
Bluetooth 2.1 + EDR
The headline feature of v2.1 is secure simple pairing (SSP): this improves the pairing
experience for Bluetooth devices, while increasing the use and strength of security.
Version 2.1 allows various other improvements, including extended inquiry response
(EIR), which provides more information during the inquiry procedure to allow better
filtering of devices before connection.
Bluetooth 3.0 + HS
Bluetooth v3.0 + HS (High-Speed) provides theoretical data transfer speeds of up to 24
Mbit/s, though not over the Bluetooth link itself. Instead, the Bluetooth link is used for
negotiation and establishment, and the high data rate traffic is carried over a collocated
802.11 link.

Bluetooth 4.0 (Bluetooth Low Energy)


Bluetooth 4.0 includes Classic Bluetooth, Bluetooth high speed and Bluetooth Low Energy
(BLE) protocols. Bluetooth high speed is based on Wi-Fi, and Classic Bluetooth consists
of legacy Bluetooth protocols. Bluetooth Low Energy, previously known as Wibree, is a
subset of Bluetooth v4.0 with an entirely new protocol stack for rapid build-up of simple
links. As an alternative to the Bluetooth standard protocols that were introduced in
Bluetooth v1.0 to v3.0, it is aimed at very low power applications powered by a coin cell.
Chip designs allow for two types of implementations, dual-mode, single-mode and
enhanced past versions.
In a single-mode implementation, only the low energy protocol stack is implemented.
In a dual-mode implementation, Bluetooth Smart functionality is integrated into an
existing Classic Bluetooth controller.
Compared to Classic Bluetooth, Bluetooth Low Energy is intended to provide considerably
reduced power consumption and cost while maintaining a similar communication range.
Consider table 1 for more comparison.
Bluetooth 4.1
Bluetooth v4.1 is an incremental software update to Bluetooth Specification v4.0, and not
a hardware update. Adds new features that improve consumer usability. These include
increased co-existence support for LTE, bulk data exchange rates and helps the developer
innovation by allowing devices to support multiple roles simultaneously.
Bluetooth 4.2
Bluetooth 4.2 Introduces features for the Internet of Things.
The major areas of improvement are:
• Low Energy Secure Connection with Data Packet Length Extension
• Link Layer Privacy with Extended Scanner Filter Policies
• Internet Protocol Support Profile (IPSP) for Bluetooth Smart things to support
connected home
Bluetooth 5
The increase in transmissions could be important for Internet of Things devices, where
many nodes connect throughout a whole house. Bluetooth 5 increases capacity of
connectionless services such as location-relevant navigation of low-energy Bluetooth
connections.
The major areas of improvement are:
Bluetooth 5.1
The major areas of improvement is Angle of Arrival (AoA) and Angle of Departure (AoD)
which are used for locating and tracking of devices

Bluetooth 5.2
Enhanced Attribute Protocol (EATT), an improved version of the Attribute Protocol (ATT)
Table 1: Comparition of Bluetooth Low Energy (LE) to Bluetooth Classic
Bluetooth Low Energy (LE) Bluetooth Classic
Frequency Band 2.4GHz ISM Band 2.4GHz ISM Band
Channels 40 channels with 2 MHz spacing 79 channels with 1 MHz spacing

Channel Usage Frequency-Hopping Spread Frequency-Hopping Spread


Spectrum (FHSS) Spectrum (FHSS)
Modulation GFSK GFSK
Data Rate 2 Mb/s 3 Mb/s
Tx Power ≤ 100 mW (+20 dBm) ≤ 100 mW (+20 dBm)
Data Transports Asynchronous Connection-oriented Asynchronous Connection-oriented
Isochronous Connection-oriented Synchronous Connection-oriented
Asynchronous Connectionless
Synchronous Connectionless
Isochronous Connectionless
Communication Point-to-Point Point-to-Point
Topologies Broadcast
Mesh
Positioning Presence: Advertising None
Features Direction: RSSI, HADM(Coming)
Distance: Direction
Finding (AoA/AoD)

Bluetooth Low Energy (BLE) Protocol


Although users will usually interface directly only with the upper layers of the Bluetooth
Low Energy protocol stack, it’s probably best to begin with a basic overview of the
complete stack, which provides a solid foundation to understanding how and why things
operate the way they do. As shown in Figure 1, a complete single-mode BLE device is
divided into three parts: controller, host, and application. Each of these basic building
blocks of the protocol stack is split into several layers that provide the functionality
required to operate:
Bluetooth low energy architecture
Application
The application is the highest layer and the one responsible for containing the logic, user
interface, and data handling related to the application. The architecture of an application is
highly dependent on each particular implementation.
Host
Includes the following layers:
Generic Access Profile (GAP)
Generic Attribute Profile (GATT)
Logical Link Control and Adaptation Protocol (L2CAP)
Attribute Protocol (ATT)
Security Manager (SM)
Host Controller Interface (HCI), Host side
Controller
Includes the following layers:
Host Controller Interface (HCI), Controller side
Link Layer (LL)
Physical Layer (PHY)

1. Physical Layer
The physical (PHY) layer is the part that actually contains the analog communications
circuitry, capable of modulating and demodulating analog signals and transforming them into
digital symbols. The radio uses the 2.4 GHz ISM (Industrial, Scientific, and Medical) band to
communicate and divides this band into 40 channels from 2.4000 GHz to 2.4835 GHz. As
shown in Figure 2, 37 of these channels are used for connection data and the last three
channels (37, 38, and 39) are used as advertising channels to set up connections and send
broadcast data.

The standard uses a technique called frequency hopping spread spectrum, in which the radio
hops between channels on each connection event using the following formula:
channel = (curr_channel + hop) mod 37
The value of the hop is communicated when the connection is established and is therefore
different for every new established connection. The modulation chosen to encode the
bitstream over the air is Gaussian Frequency Shift Keying (GFSK), the same modulation used
by classic Bluetooth. The modulation rate for Bluetooth Low Energy is fixed at 1 Mbit/s,
which is therefore the upper physical throughput limit for the technology.

2. Link Layer
The Link Layer is directly interfaces with the PHY, and it is usually implemented as a
combination of custom hardware and software.
The Link Layer defines the following roles:
Advertiser: A device sending advertising packets.
Scanner: A device scanning for advertising packets.
Master: A device that initiates a connection and manages it later.
Slave: A device that accepts a connection request and follows the master’s timing. These
roles can be logically grouped into two pairs: advertiser and scanner
A BLE device can be a master, a slave, or both, depending on the use case and requirements.
Devices that initiate connections will be masters and devices that advertise their availability
and accept connections will be slaves. A master can connect to multiple slaves and a slave
can be connected to multiple masters. Typically, devices such as smartphones or tablets tend
to act as a master, while smaller, simpler, and memory-constrained devices such as standalone
sensors usually adopt the slave role.

Bluetooth Device Address


The fundamental identifier of a Bluetooth device is the Bluetooth device address. This 48-bit
(6-byte) number uniquely identifies a device among peers. There are two types of device
addresses, and one or both can be set on a particular device:
Public device address
This is the equivalent to a fixed, BR/EDR, factory-programmed device address. It must be
registered with the IEEE Registration Authority and will never change during the lifetime of
the device.
Random device address
This address can either be pre-programmed on the device or dynamically generated at
runtime. It has many practical uses in BLE.

3. Host Controller Interface (HCI)


i. Host Controller Interface (HCI) is a standard protocol that allows for the
communication between a host and a controller. A line draw at this level to indicate the
controller (is the only module with real-time requirements and contact with the physical
layer) separated from the host.
ii. Typical examples of this configuration include most smartphones, tablets, and
personal computers, in which the host (and the application) runs in the main CPU, while the
controller is located in a separate hardware chip connected via a UART or USB. iii. The
Bluetooth specification defines HCI as a set of commands and events for the host and the
controller to interact with each other, along with a data packet format and a set of rules for
flow control and other procedures.

4. Logical Link Control and Adaptation Protocol (L2CAP)


i. L2CAP serves as a protocol multiplexer that takes multiple protocols from the upper
layers and compresses them into the standard BLE packet format.
ii. It also performs fragmentation and recombination, a process by which it takes large
packets from the upper layers and breaks them up into chunks that fit into the 27-byte
maximum payload size of the BLE packets on the transmit side.
iii. On the reception path, it receives multiple packets that have been fragmented and
recombines them into a single large packet that will then be sent upstream to the appropriate
entity in the upper layers of the host. iv. For Bluetooth Low Energy, the L2CAP layer is in
charge or routing two main protocols: the Attribute Protocol (ATT) and the Security Manager
Protocol (SMP). The ATT (discussed in) forms the basis of data exchange in BLE
applications, while the SMP (see Security Manager (SM)) provides a framework to generate
and distribute security keys between peers.
5. Attribute Protocol (ATT)
i. The Attribute Protocol (ATT) is a simple client/server stateless protocol based on attributes
presented by a device. In BLE, each device is a client, a server, or both, irrespective of
whether it’s a master or slave. ii. A client requests data from a server, and a server sends data
to clients. The protocol is strict when it comes to its sequencing: if a request is still pending
(no response for it has been yet received) no further requests can be sent until the response is
received and processed.
iii. ATT operations includes Error Handling, Error Response, Server Configuration, Find
Information (Find Information Request/Response), Read Operations (Read by Type
Request/Response, Read Request/Response, Read Multiple Request/Response, Read by
Group Type Request/Response), Write Operations (Write Request/Response, Write
Command, Queued Writes, Prepare Write Request/Response, Execute Write
Request/Response), Server Initiated.

6. Security Manager Protocol (SMP)


The Security Manager (SM) is a protocol and security algorithms designed to provide the
Bluetooth protocol stack with the ability to generate and exchange security keys.
This allow the peers to communicate securely over an encrypted link, to trust the identity of
the remote device.
The Security Manager defines two roles:
Initiator
Always communicates to the Link Layer master and therefore to the GAP central.
Responder
Always corresponds to the Link Layer slave and therefore the GAP peripheral.
Security Procedures
The Security Manager provides support for the following three procedures: Pairing
The procedure by which a temporary common security encryption key is generated to be able
to switch to a secure, encrypted link. This temporary key is not stored and is therefore not
reusable in subsequent connections.
Bonding
A sequence of pairing followed by the generation and exchange of permanent security keys
and stored in non-volatile memory and therefore creating a permanent bond between two
devices, which will allow them to quickly set up a secure link in later connections without
having to perform a bonding procedure again.
Encryption Reestablishment
After a bonding procedure is complete, keys might have been stored on both sides of the
connection. If encryption keys have been stored, this procedure defines to use those keys in
later connections to reestablish.

7. Generic Attribute Profile (GATT)


i. The Generic Attribute Profile (GATT) builds on the Attribute Protocol (ATT) and it
can be considered as the backbone of BLE data transfer because it defines how data is
organized and exchanged between applications.
ii. It defines generic data objects that can be used and reused by a variety of application
profiles (known as GATT-based profiles). It maintains the same client/server architecture
present in ATT, but the data is now converted in services.

8. Generic Access Profile (GAP)


i. The Generic Access Profile (GAP) dictates how devices interact with each other at a lower
level so GAP can be considered to define the BLE topmost control layer. It defines the device
discovery, connection, security establishment, and to allow data exchange to take place
between devices (even from different vendors). ii. GAP establishes different sets of rules and
concepts to regulate and standardize the lowlevel operation of devices. Such as roles and
interaction between devices during the operational modes and following the communication
security aspects, including security modes and procedures.

PSoC4 BLE architecture and Component Overview

Features
PSoC 4100/4200 families have these major
components: i. 32-bit Cortex-M0 CPU with 48 MHz
ii. Up to 32-KB flash and 4-KB SRAM
iv. Four independent pulse-width modulators (PWMs) and synchronized analog-to-
digital converter (ADC) operation
iv. Up to 1 Msps 12-bit ADC
v. Up to two opamps with comparator mode and successive approximation register (SAR)
input buffering capability vi. Two low-power comparators
vii. Two serial communication blocks (SCB) to work as SPI/ UART/I2C serial
communication channels

1. CPU System
i. Processor: The heart of the PSoC 4 is a 32-bit Cortex-M0 CPU core running up to
48MHz. It is optimized for low-power operation. It uses 16-bit instructions and executes a
subset of the Thumb-2 instruction set. ii. Interrupt Controller: The CPU subsystem of
PSoC includes a nested vectored interrupt controller (NVIC) with 32 interrupt inputs and a
wakeup interrupt controller (WIC), which can wake the processor from deep-sleep mode.
The Cortex-M0 implements non-maskable interrupt (NMI) input.

2. Memory
The PSoC 4 memory subsystem consists of flash and SRAM. A supervisory ROM,
containing boot and configuration routines.
• Flash: The PSoC 4 has a flash module with a flash read accelerator tightly
coupled to the CPU to improve average access times from the flash block.
• SRAM: The PSoC 4 provide SRAM, which is engaged during hibernate mode

3. System-Wide Resources
i. Clocking System: The clock system for the PSoC 4100/4200 consists of the internal main
oscillator (IMO) and internal low-speed oscillator (ILO) as internal clocks and has provision
for an external clock. The default IMO frequency is 24 MHz and it can be adjusted between 3
MHz and 48 MHz in steps of 1 MHz. The ILO is a low-power, less accurate oscillator and is
used to generate clocks for peripheral operation in deep-sleep mode. Its clock frequency is 32
kHz with ±60 percent accuracy. ii. Power System: The PSoC 4100/4200 operates with a
single external supply over the range of 1.71 V to 5.5 V. PSoC 4100/4200 has several low-
power modes – sleep, deep-sleep, hibernate, and stop modes – besides the default active
mode. iii. GPIO: Every GPIO in PSoC are capable to disables of input and output. A high-
speed I/O matrix is used to multiplex between various signals that may connect to an I/O pin.

4. Programmable Digital
The PSoC 4200 has up to four universal digital block (UDB). Each UDB contains structured
data-path logic and uncommitted programmable logic devices (PLD) logic with flexible
interconnect. The UDB array provides a switched routing fabric called the Digital System
Interconnect (DSI). The DSI allows routing of signals from peripherals and ports to and
within the UDBs.

5. Analog System
i. SAR ADC: PSoC 4 has a configurable SAR ADC. The ADC provides the choice of
three internal voltage references (VDD, VDD/2, and VREF) and an external reference
through a GPIO pin.
ii. Continuous Time Block mini (CTBm): The CTBm block provides continuous time
functionality at the entry and exit points of the analog subsystem. The CTBm has two
highperformance opamps.

6. Special Function Peripherals


i. LCD Segment Drive: The PSoC 4 has an LCD controller. It uses full digital methods
(digital correlation and PWM) to drive the LCD segments.
ii. CapSense: PSoC 4 devices has the CapSense feature, which allows you to use the
capacitive properties of your fingers to toggle buttons, sliders, and wheels

7. Program and Debug


PSoC 4 devices support programming and debug features of the device via the on-chip SWD
(Serial Wire Debug) interface. The SWD interface is also fully compatible with industry
standard third-party tools.

You might also like