IoT Unit 3

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 50

UNIT III

IoT Application Development: Communication, IoT Applications, Sensing,


Actuation, I/O interfaces.
Software Components- Programming API’s (using Python/Node.js/Arduino) for
Communication
Protocols-MQTT, ZigBee, CoAP, UDP, TCP, Bluetooth.
Bluetooth Smart Connectivity Bluetooth overview, Bluetooth Key Versions,
Bluetooth Low Energy
(BLE) Protocol, Bluetooth, Low Energy Architecture, PSoC4 BLE architecture and
Component Overview.

Communication
 The communication module is the device's final, but most important,
component. This is a device that connects devices to storage, either
locally or in the cloud.
 Communication ports including USB, Modbus, and Ethernet/IP, to
mention a few, can be found in this module. Wireless
communication radio technology, such as Wireless fidelity, might be
included as well.
 Communication ports such as USB, serial (232/485), and CAN, to
name a few, may be included in this module. It could also contain
Wi-Fi, LoRA, ZigBee, and other wireless communication
technologies
 The communications module might be part of the same device as the
other modules, or it can be a distinct device dedicated to
communications only. A "gateway architecture" is a term used to
describe this approach.
 If you have three sensors in a room that need to send data to the
Cloud, you could link them all to a single gateway in the same room,
which then consolidates the data and delivers it to the Cloud.

Sensing
 Sensors can be found all over the place. They can be found in our
homes and businesses, as well as retail malls and hospitals. They're
built into smartphones and play a key role in the Internet of Things
(IoT).
 Sensors have existed for quite some time. Infrared sensors have been
around since the late 1940s, while the first thermostat was launched in
the late 1880s. The Internet of Things (IoT) and its industrial cousin,
the Industrial Internet of Things (IIoT), are taking sensor usage to new
heights.
 Sensors, in general, are devices that detect and respond to changes in
their surroundings. Light, temperature, motion, and pressure are all
examples of possible inputs. Sensors produce useful data, which they
can exchange with other connected devices and management systems
if they are connected to a network.
 Sensors are vital to the success of many modern organizations. They
can alert you to possible issues before they turn into major issues,
allowing firms to do preventative maintenance and avoid costly
downtime.
 A good sensor should have these three characteristics:
1. It needs to be attentive to the phenomenon it's tracking.
2. It shouldn't be affected by other bodily factors.
3. During the measuring procedure, it should not change the
phenomenon being measured.
We can use a variety of sensors to measure practically all of the physical
properties around us. Thermometers, pressure sensors, light sensors,
accelerometers, gyroscopes, motion sensors, gas sensors, and many other
common sensors are widely used in everyday life.
Properties of a sensor:
1. Range - The sensor's range refers to the phenomenon's highest and
minimum values.
2. Sensitivity - Sensitivity is defined as the smallest change in the
measured parameter that results in a noticeable change in the
output signal.
3. Resolution - The sensor's resolution is the smallest change in the
phenomenon it can detect.
Sensor classification
Several criteria can be used to classify sensors:
1. Passive or Active - Active sensors, on the other hand, require an
external power source to monitor an environment, whereas
passive sensors do not.
2. Another classification is dependent on how the property was
detected and measured (mechanical, chemical, etc.).
3. Analog or Digital - Digital sensors produce a discrete signal,
whereas analog sensors produce an analog, or continuous,
signal.
Types of sensors
There are many different types of IoT sensors, as well as numerous
applications and use cases. Here are ten of the most common types of IoT
sensors, as well as some of their applications.
1. Temperature sensors:
Temperature sensors detect temperature changes and translate
them to data by measuring the quantity of heat energy present in a
source. Manufacturing machinery frequently necessitates specific
environmental and device temperatures. Similarly, soil temperature
is an important determinant in crop growth in agriculture.

2. Humidity sensors:
These sensors determine how much water vapor is present in the
environment of air or other gases. Humidity sensors are often found in
both industrial and domestic heating, venting, and air conditioning
systems. They can also be found in a variety of different places, such
as hospitals and meteorology stations, where they record and forecast
weather.
3. Pressure sensors
Changes in gases and liquids are detected by a pressure sensor.
The sensor monitors changes in pressure and conveys them to
connected systems when they occur. Leak testing, which might
occur as a result of degradation, is a common application case.
Pressure sensors are also important in the manufacture of water
systems since they can easily detect pressure variations or dips.
4. Proximity sensors
Proximity sensors are used to detect objects that are close to the
sensor without having to touch them. Electromagnetic fields or
beams of radiation, such as infrared, are frequently emitted by these
sensors. Proximity sensors have a variety of applications. A
proximity sensor in retail can detect motion between a customer and
a product that piques his or her attention. Any discounts or special
offers on products near the sensor might be notified to the user. Mall
parking lots, stadium parking lots, and airport parking lots all use
proximity sensors to signal parking availability. They can also be
employed in production lines in the chemical, food, and a variety of
other industries.
5. Level sensors
The level of substances such as liquids, powders, and granular
materials is detected using level sensors. Level sensors are used in a
variety of industries, including oil production, water treatment, and
beverage and food manufacturing. Level sensors can measure the
amount of rubbish in a garbage can or dumpster, which is a frequent
use case for waste management systems.
6. Gyroscope sensors

Gyroscope sensors measure the angular rate or velocity, which is


commonly defined as the speed and rotation around an axis.
Automobiles, such as automobile navigation and electronic stability
control (anti-skid) systems, are examples of use cases. Motion
sensing for video games and camera shake detection systems are two
other applications.
7. Gas sensors
These sensors track and detect changes in air quality, such as the
presence of toxic, flammable, or dangerous gases. Mining, oil and
gas, chemical research, and manufacturing are all industries that use
gas sensors. Carbon dioxide detectors, which are found in many
homes, are a common consumer use case.
8. Infrared sensors
By producing or detecting infrared radiation, these sensors detect
features in their surroundings. They can also detect the heat that
objects emit. Infrared sensors are employed in a range of IoT projects,
including healthcare, because they make blood flow and blood
pressure monitoring easier. Infrared sensors are used by televisions to
decipher the signals supplied by a remote control. Art historians
utilizing infrared sensors to observe hidden layers in paintings to
assist establish whether a work of art is real or fake, or has been
altered by a restoration technique, is another intriguing application.
9. Optical sensors
Optical sensors are devices that transform light beams into
electrical impulses. Optical sensors have a wide range of
applications and use cases. Vehicles in the automotive industry
utilize optical sensors to detect signs, obstructions, and other objects
that a driver might see while driving or parking. Optical sensors are
crucial in the development of self-driving cars. Optical sensors are
widely used in mobile phones.
Actuation
A physical object (“thing”) + controller (“brain”) + sensors + actuators +
networks make up an IoT device (Internet). A machine component or
system that moves or regulates a mechanism or system is known as an
actuator. The device's sensors detect the surroundings, and control signals
are sent to the actuators based on the activities required.

An actuator is something like a servo motor. They can move to a defined


angular or linear location and are either linear or rotatory actuators. For
IoT applications, we can use servo motors and rotate them to 90 degrees,
180 degrees, and other angles as needed.

The controller instructs the actuator to conduct the task depending on the
sensor data, as shown in the diagram below.

Fig 2: Use of actuations

Through the actuator, the control system affects the environment. It


necessitates an energy supply as well as a control signal. It turns the
source of energy into a mechanical operation when it gets a control
signal. On this premise, on the form of energy it uses, it has different
types given below.
Types of Actuators

1. Hydraulic actuator
A hydraulic actuator is a mechanical device that employs hydraulic
power to complete a task. A cylinder or a fluid motor drives them.
According to the needs of the IoT device, mechanical motion is
translated to rotary, linear, or oscillatory motion.
Hydraulic actuators are used in construction equipment because
they can create a considerable amount of force.
Advantages:
● Hydraulic actuators have the ability to generate significant
amounts of force at a high rate.
● Used in welding, clamping, and other applications.
● In car transport carriers, it's used to lower or raise the vehicles.
Disadvantages
● Leaks in hydraulic fluid can reduce performance and complicate
cleanup.
● Noise reduction equipment, heat exchangers, and high-
maintenance systems are all required.
● It is expensive.
2. Pneumatic Actuators
A pneumatic actuator converts energy created by vacuum or high-
pressure compressed air into linear or rotary motion. For example,
sensors that act like human fingers and are powered by compressed
air are used in robotics.
Advantages
● They are a low-cost solution that is employed in extreme
temperatures where employing air rather than chemicals is a
safer option.
● They require little maintenance, are long-lasting, and have a
lengthy service life.
● It is quite quick to initiate and stop the action.
Disadvantages
● It can become less efficient if there is a loss of pressure.
● The air compressor should be turned on all the time.
● It is possible for air to be polluted, and it must be maintained.
3. Electrical actuators
An electric actuator works by converting electrical energy into
mechanical torque and is usually powered by a motor. A solenoid-
based electric bell is an example of an electric actuator.
Advantages
● It can automate industrial valves, which makes it useful in a variety
of sectors.

● It makes less noise and is completely safe to use because there are
no fluid leaks.
● It has the ability to be reprogrammed and delivers the highest
level of control and precision positioning.
Disadvantages
● It's not cheap.
● It is highly dependent on the surrounding environment.
I/O interfaces
The Input Output Interface (IOI) is a technique for exchanging data
between internal and external storage and I/O devices.

The Input-Output Interface (I/O) is a means for moving data between


internal storage devices, such as memory, and external peripheral devices.
A peripheral device, often known as an input-output device, is a device that
provides input and output for a computer. Consider the following scenario:
Input devices, such as a keyboard and mouse, offer input to the computer,
and output devices, such as a monitor and printer, provide output to the
computer. In addition to external hard drives, several peripheral devices that
can provide both input and output are also available.

For peripherals connected to a computer to communicate with the central


processing unit, special communication cables are required.

The communication link's aim is to reconcile the disparities between the


central computer and each peripheral.

The following are the main differences:

1. Electronic devices are CPU and memory, whereas electromechanical


and electromagnetic devices are peripherals. As a result, signal values
may need to be converted.
2. Because peripheral data transfer rates are typically slower than CPU
data transfer rates, a synchronization mechanism may be required.
3. The word format in the CPU and RAM differs from the data codes
and formats in
the peripherals.

4. Peripheral operating modes differ from one another and must be


managed so as not to interfere with the operation of other peripherals
attached to the CPU.

Computer systems include additional hardware components between the


CPU and peripherals to supervise and synchronize all input and out transfers
in order to resolve these mismatches.
● Because they connect the CPU bus to peripheral devices, these
components are known as Interface Units.
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
 APIs, or applications programming interfaces, are what make it possible to
communicate with a connected device, based on a set of rules.
 APIs are critical in IoT, both to communicate with the device and to leverage
the information from the device, but there is a lot to understand.
What is an IoT API?

The term API (application programming interface) is the tool software developers use
to gather and transfer data from one application or computer to another. Or in other
words, APIs enable developers to programmatically interact with software
components both inside and outside of their own code.

In IoT specifically, APIs are used to gather and transfer data from the connected
device to an application or computer. They are also used to instruct a connected
device to take a particular action. Because connected devices can be anywhere in the
world, having an API makes it possible to remotely access a device and make the data
useful.

For Hologram specifically, we gather and transfer usage data via cellular connectivity
and share it in the Dashboard. Within the Dashboard, users can remotely pause,
activate, or deactivate devices; pull reports; and more. The Hologram API enables
users to expand on what’s done in the Dashboard as well as bring connectivity data
directly into their own applications or reports.

How do APIs and IoT work together?

An API is a way to enable users to programmatically access information about their


devices and make decisions or take actions based on it. There are an endless number
of ways they can work together in IoT. A few examples include:

 Managing a fleet: Everything from activating devices to billing and reporting


are all done via the API.
 Preventing fraud: Leveraging the API enables users to create alerts if a device
is moved or if a SIM card was stolen. We’ve also seen users configure SMS
limits to prevent high data charges if a device is stolen.

While the Hologram Dashboard surfaces all of this information and capabilities, users
will leverage the Hologram API to either bring data into their own tools or leverage it
as part of their application for their customers. APIs are powerful tools that take the
data created at the device level and make it usable.

What is an API endpoint and why is it important?

An API endpoint is the source which you want to get the data from. In more technical
terms, it’s an API call. The most obvious API endpoint in IoT is at the device level,
gathering data from the connected device. This collects data usage, connectivity
status, and any other additional data an IoT application is intending to collect.

Beyond the device endpoint, there are many other useful endpoints within an IoT
deployment. For example, a team may use the API to collect data as it relates to
billing, making finance reporting programmatic.

Main types of IoT APIs

There are four common types of APIs: Public, Partner, Internal and Composite.
Public APIs

Public APIs, also known as Open APIs, are available to the public with no
restrictions. This enables developers outside of an organization to access data to
enhance their own application. Single sign on, using your email or social media
account, is made possible through Public APIs, bringing in the email provider or
social platform code into your application.

Partner APIs

Partner APIs can be leveraged by a client or partner of an application. These APIs


require users to sign in and authenticate with an API key to access the API. The
Hologram API is an example of a Partner API, allowing customers to communicate
directly with their connected devices and bring data back to their applications.

Internal APIs

APIs used by a company to build and manage their applications are internal or private
APIs. This ensures that only those working on a product have access to make changes
to a product or to the sensitive data on a platform.

Composite APIs

Composite APIs batch several API requests into a single API call. This reduces the
number of trips to a server. By grouping a chain of API calls into one API, a client
can make one API request that includes a chain of calls and end with one response.

Types of API architectures and delivery formats

While we discussed the different types of APIs, there are also different approaches in
how data is transferred over a network using API calls. REST and SOAP are leading
architectures, but offer different benefits to users. JSON and XML are the formats in
which the data is delivered.

SOAP API
SOAP (Simple Object Access Protocol) is a protocol specification for exchanging
data between two endpoints. SOAP is mostly used for applications that require a high
level of security – like payments. It is much complex but also well defined in terms of
security. Banking transactions or any other applications that need high security use
this. It can allow any style of programming and is based on a wide range of protocols
such as HTTP, SMTP, TCP, etc. Also, uses XML for formatting. It is one of the
established API used.

REST API

REST, also known as a RESTful API (Representational State Transfer), is an


architectural style for building client-server applications. REST supports high-
performing and reliable communication at scale, independent of the technology used.
It is a more lightweight architecture than SOAP.

The interface has nothing to do with storage or backend. The client-server


communication is simple here and is based on URLs or HTTP protocols. These are
also easy to build and can be cached. These are very reliable and have larger
applications. SSL security is used here. Thus, it uses JSON, XML for formatting. It
provides user with the option of flexible data formatting.

JSON (JavaScript Object Notation) and XML (Extensible Markup Language)

JSON and XML are two of the formats in which data is delivered. SOAP relies
exclusively on XML while REST allows XML, JSON, HTML, and plain text. JSON
is a lightweight, human-readable format that can be used with any programming
language. Most public web services use REST APIs with JSON.

JSON-RPC (JavaScript Object Notation-Remote Procedure Calls):-

It has one of the best request efficiencies. Thus, it uses JSON formatting. It is much
reliable and simple to use. Popular programming languages e.g., Java, Java-script,
Ruby, C#, PHP and Python) and application platforms provide good support for
producing and consuming JSON data. It is human-readable as well as machine-
readable and is designed in such a way that they call methods.

XML-RPC(Extensible Markup Language -Remote Procedure Calls):-


This Is Much Similar To JSON-RPC, But Here XML Is Used For Formatting Of
Data. It Is Much Simpler And Uses Minimum Bandwidth. While REST Performs
Basis On Resources The RPCs Depend On The Actions.

Examples of IoT APIs

There are endless applications for IoT APIs. As we mentioned earlier, APIs enable
fleet operators to manage an entire IoT deployment. This includes activating and
deactivating devices, reporting and more. It also can help users prevent fraud through
alerts and data usage limits.

APIs in IoT can also send SMS messages to activate a device. Take for example a
scooter. Once a consumer uses their mobile app to start a ride, an API then sends a
message to the scooter to activate the ride.

Or, in the case of a remote patient monitoring device, an API can check the last time
someone tested a specific health metric and then alert the patient via text or email.

In each of the examples, the API programmatically sends a message based on an


action, to enable another action to take place.

Benefits of IoT APIs

APIs are powerful tools. They enable users to communicate with connected devices
anywhere in the world – both to send information to and receive data from. Without
an API, it would be impossible to run an IoT deployment without having feet on the
ground with each device. By programmatically communicating with connected
devices, they provide a ton of useful data and allow new experiences for consumers.

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 a Rest 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 Rest 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

Arduino implementations
Now that we've covered the fundamentals of Arduino and how to utilize it
to connect it to an external system, we'll go through how to put it into
reality. We'll use Rest API requests to control an LED strip in this
example. Because we need to concentrate on the Arduino Rest API, the
sketch is straightforward. The LED strip is a Neopixels RGB Stick Board,
and it is able to select a single RGB led color using the Adafruit library.

The following sketch demonstrates how to connect it to an Arduino UNO.

Fig 3: Arduino UNO

The Neopixel components in this image are different, but the connections
are the same.

We want to change the color of the led strip using a Rest JSON API
call. The color is supplied as a HEX parameter to the sketch function.
This sample exemplifies the library's versatility. The Arduino code is
straightforward:

// Create aREST instance

AREST rest = aREST();


// NeoPixel Init

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN,


NEO_GRB + NEO_KHZ800);

Void setup() { Serial.begin(115200);


//Register RGB function
Rest.function("rgb", setPixelColor);
Serial.println("Try DHCP...");
If (Ethernet.begin(macAdd) == 0) {
Serial.println("DHCP FAIL...Static IP");
Ethernet.begin(macAdd , ip, myDns, myGateway) ;
}

Server.begin();

Serial.print("server IP: ");

Serial.println(Ethernet.localIP());

Pixels.begin();

Serial.println("Setup complete.\n");
}

Void loop() {

// listen for incoming clients


EthernetClient client = server.available();
Rest.handle(client);
Wdt_reset();

Int setPixelColor(String hexColor) {

HexColor="0x" + hexColor;

Serial.println("Hex color " + hexColor);

Long n = strtol( &hexColor[0], NULL, 16);

Serial.println("N :" + String(n));


Long r = n << 16;
Long g = n << 8 && 0xFF;
Long b = n && 0xFF;

// set single pixel color Return 1;


}

SetColor is the Arduino function that we'd like to make available via an
Arduino HTTP Rest API. As a result, the sketch registers it as rgb at line 36.
Define an API?

How will you implement the API in an application or service:

An application or service consists of mashed APIs. Following are the steps for
implementing the APIs:

1. Make an implementation table for sequences of API actions. A session of


message exchanges between two ends of API may consist of number of actions.

 Column 1 of each row has the actions in sequences which occur one by one.

 Column 2 may specify for each action, the authentication code or method (device
platform ID, such as MAC address) for secured communication to and from other
end (server or application). Column 2 has authentication method for use that may
involve user/password communication. User in case of IoT device platform is
device platform ID, such as MAC address. Password can be some code internally
generated at device platform using some algorithm using a secret key as input
(Example 9.8).

 Column 3 specifies the API inputs for initiating the action on event.

 Column 4 specifies the API outputs for the inputs. The outputs communicate to
other end and initiate the execution of methods, callback functions, generate
requests or send responses.

2. Use the secure communication protocols, such as DTLS/TLS.

3. Use the standard formats for object or message exchanges: JSON, TLV or XML
or REST style of URIs or URLs for message format (Section 3.2 of Raj Kamal
Text book).

4. Use for access to remote methods standard protocols, such as SOAP (for XML-
RPC) or JSON-RPC. RPC stands for remote procedure call. Procedure also
means function in C/C++ or method in Java (Sections 3.3 and 3.4 of Raj Kamal
Text book).

5. Use the standard client-server protocols, such as MQTT when using


publish/subscribe or such as XMPP models of message or object exchanges
(Section 3.2 of Raj Kamal Text book).

6. Use the standard client and server protocol for client-server http, or CoAP or ws
protocol using client-response model of message or object exchanges (ws:// used
in place of http:// for bi-directional message exchanges) (Section 3.4 of Raj
Kamal Text book).

7. Use the standard methods for web object or message exchanges. For example,
REST request-response model methods, such as HTTP GET/POST methods or
WebSocket methods for bi-direction message exchanges (Section 3.4 of Raj
Kamal Text book).

8. Use the scripts, for example, JavaScript or Node.js framework for creating set of
codes in event model or codes for running at distributed computing systems
(device platforms or services at web/cloud). Event model calls a callback()
[onEventAction()] functions on inputs. The function may initiate sending a client
data or sending a server response. Function runs once on each input-event.

9. Use the language or scripting language framework which provides wider support
of libraries, community and test tools.
Example 9.15 explains the table for easy implementation of API. Example 9.15
Problem: Drawing an implementation table for weather web APIs: How does a table
make it easy writing codes for weather web APIs? Use the sequences shown in Figure
9.4. Solution Table 9.4 gives the actions, inputs and outputs for weather APIs. Table
9.4 Implementation table for weather web APIs
Sequence Authentication Inputs Outputs
Number and
Action
1:New API MAC Location (City Message to weather web
connection to address or Name) client to enable client
weather service deviceID/ connect to send request
ApplicationID/ for weather messages
API_ID
2:New MAC address Messages (city Subscribe to the weather
connection to or weather name, ClientID, service, if a new city
weather Service service API ID time stamp) name (messaged from
the location server)
3:New MAC address Messages of Subscription message(s)
connection to or weather weather web- on new city to the
weather service service API ID service API on weather service and
new city name messages (clientID,
weather information
with with time stamp
from messaged data)
3: New response MAC address Weather Response message(s)
of weather or weather messages and
service service ID warnings for this
and predictions of
next two days for
the city from
repository
APIs Implementation Using REST Methods:
When implementing a REST API or using REST methods in client or server, first
making a table makes the coding easy.
 Column 1 of each row has the URL for communication for implementing an
action.
 Column 2 may specify the action (REST methods), such as
PUT/GET/POST/DELETE for implementation.
 Column 3 may specify for each action, the authentication code or method
(device platform ID, such as MAC address) for secured communication to and
from other end (server or Application). Column 3 has authentication method
for use at server/ destination end that may involve user/password session. User
in case of IoT device platform is device platform ID, such as MAC address.
Password can be some code internally generated at device platform using
some algorithm using a secret key as input (Example 9.8).
 Column 4 specifies the API inputs/parameters for initiating the action.
 Column 5 specifies the API outputs for the inputs. The outputs communicate
to other end and initiate the execution of methods, callback functions, generate
Cookie or response.
Protocols
1. 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 battery- powered 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.

Fig 4: MQTT workflow


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.
2. ZigBee
Zigbee is a standards-based wireless technology that enables low-cost, low-
power wireless M2M and internet of things (IoT) networks.

Zigbee is an open standard for low-data-rate, low-power applications.


This allows for the mixing of implementations from different manufacturers
in theory, but in practice, vendors have expanded and personalized Zigbee
devices, resulting in interoperability concerns. Unlike Wi-Fi networks,
which employ a mesh networking protocol to avoid hub devices and
establish a self-healing design, Zigbee networks support significantly
lower data rates and utilize a mesh networking protocol to avoid hub
devices and build a self-healing architecture.

Furthermore, these mesh networks self-configure when devices are added or


withdrawn, and their interconnection allows for a greater coverage range
than competitors like Bluetooth Low Energy.

Despite this, Zigbee remains a low-range communication standard,


with a coverage range of up to 100 meters. As a result, it's an excellent
solution for personal spaces such as smart homes or in-building
operations.

A coordinator, a router, and a device make up a Zigbee network. The


coordinator serves as the network's hub, connecting all of its components
and managing data transfer and storage.

The routers in the network support Zigbee coordinators. These are data-
transfer devices that send and receive data from a variety of devices,
including televisions, doors, cameras, and thermostats.

Zigbee is known for its secure connections, which is why it's often the
chosen choice for personal area networks, particularly in corporate
networks with sensitive data.

Because of its low power consumption, Zigbee is a better choice for IoT
connectivity than Wifi. It's utilized for a variety of tasks, such as smart
building automation, temperature management, and more.

Zigbee is an ideal partner for any business where little amounts of data are
exchanged rarely, such as remote monitoring or in-building applications.
Finding ZigBee’s place in the industrial IoT
The properties of ZigBee set it unique from other conceivable IoT
protocols, allowing it to carve out its own niche in the market. Because of
its mesh topography, it can handle longer distances than Bluetooth Low
Energy, and its extremely low energy consumption makes it more IoT-
friendly than Wi-Fi.

According to Gigaom, after the chips are extensively utilized in houses,


the next stage will be to include a ZigBee chip in cellphones. Because the
homeowner's primary method of communicating with sensors in the home
is through their smartphone or tablet, having such a chip built inside would
put it in the hands of millions of smartphone owners who could turn it on at
the touch of a button.

ZigBee radios are currently installed in homes via a hub, router, or


set-top box, making their adoption by homeowners reliant on service
providers and early adopters of products such as the Almond Router,
SmartThings hub, or Revolv hub.
Challenges and Shortcoming
In the battle to become an internationally acknowledged IIoT standard,
Zigbee has its work cut out for it. The space to become the solution to
future IoT solutions is increasingly competitive, with established
competitors such as Wi-Fi and Bluetooth, as well as newcomers Thread.

However, ZigBee already has a considerable presence in the market. In


fact, if you have a Nest thermostat, Comcast's new router, or a Hue
lighting, you already have ZigBee chips.

Unfortunately, the specification has had several difficulties in recent years,


with interoperability issues highlighting much of its content. The issue is
that the standard is more than simply a wireless transport method; it also
includes a layer of software that can build profiles that conflict with other
ZigBee profiles. So, unlike Wi-Fi, it's possible that two ZigBee-enabled
devices won't be able to communicate with one another.

Another obstacle that ZigBee must overcome is Z-Wave, its closest


competitor. According to Gigaom, nine out of ten sensors use the
proprietary Z-wave protocol instead of ZigBee, and more startups are
releasing Bluetooth Low Energy devices that can talk with smartphones.
Architecture of Zigbee:

Zigbee architecture is a combination of 6


layers.

1. Application Layer
2. Application Interface Layer
3. Security Layer
4. Network Layer
5. Medium Access Control Layer
6. Physical Layer

 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. The physical layer translates the data packets in the over-the-
air bits for transmission and vice-versa during the reception.
 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.
Channel Access:
1. Contention Based Method (Carrier-Sense Multiple Access with
Collision Avoidance Mechanism)
2. Contention Free Method (Coordinator dedicates a specific time
slot to each device (Guaranteed Time Slot (GTS)))
Zigbee Applications:
1. Home Automation
2. Medical Data Collection
3. Industrial Control Systems
4. meter reading system
5. light control system
6. Commercial
7. Government Markets Worldwide
8. Home Networking

3. CoAP
In the Internet of Things, the Confined Application Protocol (CoAP) is a
customized web transfer protocol for usage with constrained nodes and
constrained networks. CoAP is a protocol that allows basic, restricted
devices to connect to the Internet of Things, even across constrained
networks with poor bandwidth and availability.
Machine-to-machine (M2M) applications such as smart energy and
building automation are common uses.

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
Architecture

CoAP is a document transport protocol, similar to HTTP. Unlike HTTP,


CoAP is created with restricted devices in mind.

HTTP TCP transfers are substantially larger than CoAP packets. To save
space, bitfields and mappings from strings to integers are frequently utilized.
Packets are simple to create and can be parsed in place on restricted devices
without spending additional RAM.

CoAP uses UDP rather than TCP. Connectionless datagrams are used to
communicate between clients and servers. In the application stack, retries
and reordering are implemented. By eliminating the need for TCP,
compact microcontrollers may be able to provide complete IP networking.
CoAP enables the usage of UDP broadcast and multicast for addressing.

The client/server model is used in CoAP. Clients send requests to servers,


and servers respond. Clients have access to resources that they can GET,
PUT, POST, and DELETE.

Through simple proxies, CoAP is meant to work with HTTP and the
RESTful web in general.

CoAP can be used on top of SMS and other packet-based communications


protocols because it is datagram-based.

CoAP can be represented as follows from the abstraction protocol layer:

Fig 5: CoAP

As you can see, the CoAp protocol is made up of two layers: messages
and request/response. The Messages layer is responsible for UDP and
asynchronous messages. Based on request/response messages, the
Request/Response layer manages request/response interaction.
Four different message types are supported by CoAP:
● Confirmable
● Non-confirmable
● Acknowledgment
● Reset

The CoAp protocol, it's helpful to define a few terminologies.

● Endpoint - An object that takes part in the CoAP protocol. An


Endpoint is usually associated with a host.
● Sender - The person or thing who transmits a message.
● Recipients - A message's final destination.
● Client - The sender of a request and the recipient of the response.
● Server - The entity that accepts a client's request and responds with a
response to the client.
4. UDP
User Datagram Protocol (UDP) is less widespread in IoT (and data
transmission in general) than TCP. However, IoT manufacturers favor
UDP since it requires fewer network resources to transmit and does not
require a continual connection between the two endpoints. To put it
another way, it uses less data and utilizes less energy.
Resource constrained devices
Low-power, lossy networks are frequently used by IoT devices (LLNs).
Because LLNs are optimized for power efficiency, they have a limited
number of resources. The Constrained Application Protocol (CoAP) was
created expressly to assist these devices in communicating, and it works
on UDP-capable devices.

Low downlink transmissions

UDP does not acknowledge that a communication has been received.


Although the sender has no way of knowing whether the data packets have
reached, the exchange requires less downlink budget. UDP can be a useful
communication protocol for communications with limited downlink
allowances.

Low power applications


Because IoT devices send data on a regular basis, losing a single datapoint
is rarely a problem. Every time a datapoint is lost or contains an error,
attempting to resend the data uses an additional battery. Because UDP does
not provide an acknowledgement, the device can shut down faster after
sending or receiving data. This makes UDP appealing to developers who
want to get the most out of their resources.
UDP Security
While UDP is simple to set up and has a lower overhead, it makes your
devices more exposed to cyber threats.

It's more difficult to deliver a packet to a specific application using TCP


because it establishes a direct connection and provides a sequence
number. Intercepting, altering, and replicating data packets to attack a
device, application, or network is easy with UDP.

Botnets (large networks of compromised computers, including IoT devices)


can also deliver false packets to a computer using UDP. Bots frequently
transmit spam to non- existent ports, forcing the computer to respond by
stating that the port is inaccessible. This swiftly diverts network resources
away from legitimate data transmissions, potentially causing the network to
go down.

You must be vigilant about IoT security with UDP and be certain that
your hardware and network-level security can secure your customers' data
and keep your devices from becoming liabilities.
UDP datagrams
UDP traffic is carried in datagram packets, each of which is made up of
a single message unit. The first eight bytes hold the header information,
but the remaining bytes hold the actual message. The header of a UDP
datagram is broken into four pieces, each of which is two bytes long.
These are the components:
● Source port - This 16-bit (2-byte) information is used to identify the
data-sending sender port. The range of permitted UDP port numbers is 0
to 65535.

● Destination port - This 16-bit data is used to identify the port on


which the data will be received by the receiver. The range of permitted
UDP port numbers is 0 to 65535. This parameter is mandatory and
identifies the receiver's port.

● Length - The length field gives the UDP packet's total length (UDP
header and UDP data). This specific field is a 16-bit field. In the absence of
UDP data, the Length field must be at least 8 bytes long.

● Checksum - The checksum value computed by the sender before


delivering the data to the recipient is stored in this field. UDP checksums
keep message data from being tampered with. The checksum value is an
encoding of the datagram data that is calculated by the sender first and
then by the receiver. In UDP, checksums are optional, whereas in TCP,
checksums are required.
UDP Features

The User Datagram Protocol offers properties that make it useful for
applications that can suffer data loss. Consider the following scenario:

● It permits packets to be lost and received in a different order than


when they were sent, making it ideal for real-time applications where
latency is an issue.

● It's suitable for transaction-based protocols like DNS and Network


Time Protocol (NTP).

● Gaming, audio or video conferencing, and streaming media are


examples of applications where a large number of customers are
connected and real-time mistake correction isn't required.
Advantages of UDP

The UDP/IP stack has the following benefits over the TCP/IP stack:
1) It is superior to TCP for applications that require continual data flow,
large amounts of data, and a higher level of speed than reliability.
2) Because it provides point-to-multipoint transmission, UDP is the
best choice for multicast and broadcast applications. In contrast to
TCP/IP, where the sender is responsible for each packet, the sender
does not need to keep track of data retransmission for many receivers.
3) UDP has a tiny packet header overhead (only 8 bytes), but TCP has a
header of 20 bytes.
1. TCP
TCP is used in conjunction with the Internet Protocol (IP), which
specifies how computers exchange data packets. TCP and IP are the
fundamental rules that govern the Internet. The Internet Engineering Task
Force (IETF) defines TCP in RFC 793, a Request for Comment (RFC)
standards document. TCP is a connection-oriented protocol, which means
it establishes and maintains a connection until both ends' application
programs have done exchanging messages.

TCP (Transmission Control Protocol) is a connection-oriented transport-


layer protocol that provides end-to-end reliable and ordered data transfer
between applications operating on Internet hosts. It was created four
decades ago. TCP has remained the dominant transport-layer protocol on
the Internet ever since, with many key applications (such as the WWW, e-
mail, file transfer, instant messaging, and so on) relying on it. However, as
the Internet has grown beyond its core qualities, TCP has faced and
overcome enormous hurdles.

TCP has been effectively employed on mobile networks, despite the


fundamental premise of TCP congestion control that the Internet is a wired
network and the challenges that arise in wireless environments. TCP's
extensive presence in mobile phones today is due to optimization
approaches.

The Internet of Things is a new challenge for TCP (IoT). Tens of billions
of affordable devices (e.g., sensors, actuators, etc.) attached to everyday
things will be connected to the Internet to enable smart scenarios in this
big networking trend. IoT devices, on the other hand, are frequently
constrained (in terms of memory, computation, and energy), employ low-
speed and error-prone connectivity, and have multi-hop networks.

TCP has been heavily chastised as a transport-layer protocol for the Internet
of Things due to these challenging networking settings. As a result, many
early IP-based IoT implementations had to rely on UDP for application-
layer dependability. The Constrained Application Protocol (CoAP), a
lightweight RESTful application-layer protocol designed at the IETF for the
Internet of Things, took the same approach.
Similarly, the IPv6 over Low Power Wireless Personal Area Networks
project produced enhancements for UDP header compression while
neglecting TCP.
TCP in the Internet of Things

End-to-end communication between IoT devices and other computers on


the same network is enabled through Connecting Things to the Internet.
Cloud backend systems can communicate with IoT devices in this manner
(e.g., for sensor data centralization, actuator triggering, and device
management). The primary protocol and architectural alternatives for end-
to-end connectivity with IoT devices using TCP are described in this
section. We concentrate on scenarios involving HTTP, CoAP, MQTT, and
AMQP.
2. HTTP

HTTP has several advantages as an IoT protocol: it is a free, open


standard, and HTTP development tools are plentiful because it is the most
widely used application-layer protocol on the Internet. Furthermore, it is
the protocol that has the best chance of passing security middle boxes. In
an IoT scenario, HTTP/2 is more appropriate than HTTP/1.1. A binary,
compact header is included in HTTP/2, and pseudo-header fields can be
compressed using the HPACK format. An IETF specification for
leveraging HTTP/2 in IoT settings is currently being developed. As a
result, HTTP (and consequently TCP) is a viable option for IoT device
connection.

Fig 6: HTTP

CoAP

CoAP was created as a lightweight alternative to HTTP/1.1, preserving the


fundamental principles of HTTP, such as the REST architecture, but with
a lot less complexity. CoAP provides interoperability with HTTP using
protocol translation proxies, allowing it to fully realize its promise. CoAP
was created with UDP in mind, with stop-and-wait dependability as an
option. However, implementation experience has shown that in order to
circumvent connectivity limits imposed by corporate firewalls, CoAP via
TCP or WebSocket’s must be enabled.

Fig 7: CoAP over TCP

MQTT
MQTT is a communications protocol developed by ISO/IEC for
monitoring applications. It is built on the publish-subscribe paradigm, in
which publishers (such as sensors) send data messages to a broker, who
then distributes the messages to subscribers (e.g., backend systems). The
broker becomes more complex as a result of this flexible approach.
MQTT also specifies a lightweight header format and necessitates a
minimal code footprint. A TCP connection is created between the broker
and the publisher or subscriber in MQTT.

Fig 8: MQTT

AMQP

AMQP is another ISO/IEC messaging protocol that was created with the
financial industry in mind. It is compatible with a number of broker-based
architectures, including publish subscribe. AMQP has more complicated
mechanisms than MQTT (for example, fine-grained control, queue
management, and error handling), but at the cost of more implementation
complexity and bigger message headers. TCP is also used in AMQP.

Fig 9: AMQP

Key takeaway

TCP is used in conjunction with the Internet Protocol (IP), which specifies
how computers exchange data packets.

TCP and IP are the fundamental rules that govern the Internet.
TCP (Transmission Control Protocol) is a connection-oriented transport-
layer protocol that provides end-to-end reliable and ordered data transfer
between applications operating on Internet hosts.

7. Bluetooth

Bluetooth was created by Ericsson in 1994 to provide wireless headsets.


Bluetooth has since evolved into a wide range of products, including
Bluetooth headsets, speakers, printers, game controllers, and much more.

Bluetooth is particularly vital for the Internet of Things, which includes


smart homes and industrial applications, which is quickly developing. It's
a low-power, low-range, high-bandwidth solution for connectivity.
When Bluetooth devices (for example, your phone and your wireless
speaker) connect, the parent-child paradigm is used, with one device
acting as the parent and the others as the children. The parent
communicates with the child, and the youngster listens for the parent to
communicate with him or her.

Because a Bluetooth parent can have up to seven children, your


computer can connect to several devices through Bluetooth at the same
time. A “piconet” is a Bluetooth connection between two or more devices.

A device can be a parent in one piconet and a kid in another at the


same time, and the parent-child relationship can also change. When
you put your Bluetooth device in pairing mode to connect it, it becomes
the parent for a short time in order to establish a connection before
connecting as the child.

Bluetooth, unlike WiFi, was designed for portable devices and related
applications, so it excels when you need to connect two devices with
minimal configuration. Furthermore, because Bluetooth uses weak
signals, there is less interference, and devices may interact even in
noisy surroundings.

Machines sending short bursts of data in excessively loud surroundings


are common in the Industrial Internet of Things. WiFi is too difficult to
set up when there are hundreds of sensors and devices sending data.

The lesser bandwidth of Bluetooth is a disadvantage, although for many


industrial applications, this isn't an issue.

Bluetooth can also be used in a smart home. Many smart home gadgets
don't require high bandwidth connections, and setting up Bluetooth is
significantly easier.
Furthermore, recent Bluetooth versions may build a self-healing mesh
network, which implies that individual devices can still interact even if
one is removed or loses power. If your door locks, HVAC system, washer,
dryer, fridge, and lights are all connected, you don't want them to all fail at
the same time.
Bluetooth Strengths and Weaknesses

 Bluetooth's main strength is communication between Bluetooth-


enabled devices such as smartphones and tablets and specialized
Bluetooth-enabled equipment.
 Bluetooth requires a gateway for access since, unlike cellular or
satellite communications, it does not connect directly to the
Internet.
 Bluetooth now has a range of roughly 328 feet (100 meters),
making it ideal for use in the home and small business.
 Multiple gateways can be set up throughout a facility to receive
Bluetooth communications for larger spaces.

Bluetooth 5 was announced by the Bluetooth SIG in March 2016, and it


will double the existing range of the technology, perhaps making Bluetooth
more appealing for IoT applications than Wi-Fi because it uses less power.
 Despite the improved range, Bluetooth IoT requires device-to-device
communications to take place within a specific radius, and after the
devices have communicated, their data must still reach a gateway
for Internet access.
 When compared to satellite or wireless cellular networks, which can
monitor object data regardless of location and interact with the
internet instantaneously, satellite or wireless cellular networks are
superior.
 Cellular connectivity will continue to be a better choice in remote
locations, such as when used to track oil and construction
equipment.
Bluetooth Connecting IoT in the Future
The roles and applications of Bluetooth in autos and households will
continue to increase and expand. It's not out of the realm of possibility to
receive automatic traffic updates or weather reports on your dashboard
throughout your daily commute, or to script home automations utilizing
Bluetooth to configure lighting, thermostats, and home entertainment
systems for the appropriate mood or occasion. Industry will find Bluetooth
a more commonplace, cost-effective alternative for IoT/M2M
communications as gateway development gets easier and less expensive
(PCWorld.com claims that a gateway can be created on a $35 Raspberry Pi
computer). Bluetooth IoT could lead to smarter waste management in
cities, more accurate health monitoring, and swift communication across a
range of digital devices.
Bluetooth devices follow IEEE 802.15.1 standard protocol for L1 (physical cum
data-link layer). BT devices form a WPAN devices network. Two types of modes
for the devices are Bluetooth BR/EDR (Basic Rate 1 Mbps/Enhanced Data Rate 2
Mbps and 3 Mbps) and Bluetooth low energy (BT LE 1Mbps). A latest version is
Bluetooth v4.2. BT LE is also called Bluetooth Smart. Bluetooth v4.2 (December
2014) provides the LE data packet length extension, link layer privacy and secure
connections, extended scanner and filter link layer policies and IPSP. BT LE range
is 150 m at 10 mW power output, data transfer rate is 1 Mbps and setup time is less
than 6 s.
Bluetooth v5, released in June 2016, has increased the broadcast capacity by
800%, quadrupled the range and doubled the speed.
A device may have provisions for single mode BT LE or dual mode BT BR/EDR
(Mbps stands for Million Bits per second). Its features are:
● Auto-synchronisation between mobile and other devices when both use BT. BT
network uses features of self-discovery, self-configuration and self-healing.
● Radio range depending on class of radio; Class 1 or 2 or radios: 100 m, 10 m or
1 m used in device BT implementation.
● Support to NFC pairing for low latency in pairing the BT devices.
● Two modes—dual or single mode devices are used for IoT/M2M devices local
area network.
● IPv6 connection option for BT Smart with IPSP (Internet Protocol Support
Profile).
● Smaller packets in LE mode.
● Operation in secured as well as unsecured modes (devices can opt for both link-
level as well as service-level security or just service level or unsecured level).
● AES-CCM 128 authenticated encryption algorithm for confidentiality and
authentication (Refer Example 2.4).
● Connection of IoT/M2M/mobile devices using BT EDR device to the Internet
with 24 Mbps Wi-Fi 802.11 adaptation layer (AMP: Alternative MAC/PHY layer)
or BT-enabled wire-bound connection ports or device. MAC stands for media
access control sublayer at a data-link layer/sublayer.
Different versions of Bluetooth
Bluetooth is a short-range wireless communication technology which is intended to
replace wired serial communication i.e. facilitating cable replacement technology
which is operating in the frequencies between 2.4 and 2.485 gigahertz (GHz)
having high level of security, based on Ad-hoc technology which allows you to
share music, videos, photos, & other information wirelessly between paired
devices. Bluetooth have been evolved which include v1.0, v1.1, v1.2, v2.0+EDR,
v2.1+EDR, v3.0+HS, v4.0 LE. This upgradation is on the basis of improvements in
speed, range and data capacity. Bluetooth technology is based on IEEE 802.15.1
standard and all the versions have different speed and data rate requirements. The
important thing to be noted is that the additional features supported by the higher
versions or standards of Bluetooth are optional and also, they do not affect the
encoding and transmission of audio. In other words, all the Bluetooth versions are
compatible with their previous versions which gives the advantage that device with
one version can interoperate with the other version. Different standards of
Bluetooth can be listed as:
1. Bluetooth v1.0 – It was the first standard of Bluetooth technology, faced
many difficulties with interoperability as manufacturers were facing
problems and difficulty in making their products interoperable, being the
drawback of this version.
2. Bluetooth v1.1 – This version fixed all those problems which were faced
from v1.0 i.e. it fixed the problem of interoperability and also added non
encrypted channels and signal strength indicators to it.
3. Bluetooth v1.2 – This version gave faster transfer or transmission speed as
compared to that of v1.1, up to 721 kbit/s, better transmission involving
retransmission of corrupted data packets if any.
4. Bluetooth v2.0+EDR – This version introduced AFH and Enhanced Data
Rate (EDR) technology, which is used for faster transmission of data and
allowing its users to theoretically boost data transfer rate up to 3 megabits per
second (Mbit/s) & maximum data transfer rate is 2.1 Mbit/s. EDR can
provide a lower power consumption i.e, it will draw low power to operate.
According to the specification, Bluetooth v2.0+EDR, EDR is an optional
feature in this version.
5. Bluetooth v2.1+EDR – This version improves the pairing experience for
Bluetooth devices & let device pairing happen much faster and more easily,
while increasing the overall security and use.
6. Bluetooth v3.0+HS – This version could reach data transfer speed of up to
24 Mbits/s & the important feature of this version is its high-speed data
transfer and can able to transfer large amounts of data.
7. Bluetooth v4.0 LE – Bluetooth Low energy, it kept data rates at up by
lowering the power, & it was mainly designed to frequently transmit data to
devices, such as smart devices including fitness bands, smart watches etc,
while saving power. This version is also called as Bluetooth Smart & mainly
used by Health and fitness companies.
8. Bluetooth 5.0 – Bluetooth 5.0 was released in 2016 and introduced several
significant improvements, including higher data transfer rates, improved
range, and increased capacity. It introduced Dual Audio, which allowed
devices to connect to two audio devices simultaneously. It also included
Bluetooth Mesh, which enabled devices to communicate with each other in a
network. The maximum data transfer rate for Bluetooth 5.0 was 50
Technical Facts About BLE

Some of the most important technical facts about BLE include:

 The frequency spectrum occupied is 2.400 - 2.4835 GHz.

 The frequency spectrum is segmented into 40 “2 MHz”-wide channels.

 The maximum data rate supported by the radio (introduced in Bluetooth


version 5) is 2 Mbps.

 The range varies significantly depending on the environment


surrounding the communicating BLE devices as well as the mode used (for
example, in long-range mode, the range will be significantly longer than in
the 2M/high-speed mode). A typical range is 10-30 meters (30-100 feet).

 Power consumption also varies widely. It depends on the implementation of


the application, the different BLE parameters, and the chipset used. The
peak current consumption of a BLE chipset during radio transmission is
typically under 15 mA.

 Security is optional in BLE communication, and it is up to the device and


applications developers to implement it. That said, though, there are also
varying levels of security that can be implemented.

 For all encryption operations, BLE uses AES CCM with a 128-bit key.

 BLE is designed for low-bandwidth data transfer applications.


Implementing BLE for high-bandwidth applications will significantly
compromise the low power consumption promise. So, minimizing radio
usage as much as possible achieves the optimal power consumption.

 Bluetooth versions (when it relates to BLE) are backwards compatible


with each other. However, the communication may be limited to the
features of the older version of the two communicating devices.
For example, a Bluetooth 5 BLE device can communicate with a Bluetooth
4.1 BLE device, but 5-specific features wonʼt be supported. On the
other hand, Connections, Primary Advertisements, discovering Services,
discovering Characteristics, and reading/writing to these Characteristics
are all possible between two BLE devices regardless of their supported
Bluetooth version (since they were supported by the initial version of
BLE).

Bluetooth Classic vs. BLE

It’s important to note that there’s a big difference between Bluetooth Classic
and Bluetooth Low Energy in terms of technical specification,
implementation, and the types of applications to which they’re each suited.
This is in addition to the fact that they are incompatible with each other.
Some of the notable differences are summarized in the following table:
Table 1: Bluetooth Classic vs. BLE

Bluetooth Classic BLE

Used for streaming applications such


Used for sensor data, control of devices,
as audio streaming, file transfers, and
headsets and low-bandwidth applications

Not optimized for low power, but has


low power, low duty data cycles
a higher data rate (3Mbps maximum
compared to 2Mbps for BLE)

Operates over 79 RF (radio frequency) channels Operates over 40 RF channels.

Discovery occurs on 3 channels,


leading to quicker discovery and
Discovery occurs on 32 channels
connections than Bluetooth Classic

BLE has gone through some major revisions and changes in the short time
since its official release in 2010, with the most recent major update being
Bluetooth 5 released in December 2016. Bluetooth 5 introduced many
important upgrades to the Bluetooth specification, most of which were
focused on BLE. Some of the most important enhancements include twice
the speed, four times the range, and eight times the advertising data
capacity.
Advantages and Limitations of BLE
Every technology has its limitations, and BLE is no exception. As we mentioned
earlier, BLE is most suitable for applications with relatively short range and
infrequent low-bandwidth data transfers.
Limitations of BLE
Data Throughput
The data throughput of BLE is limited by the physical radio data rate,
which is the rate at which the radio transmits data. This rate depends on the
Bluetooth version used. For Bluetooth 4.2 and earlier, the rate is fixed at 1
Mbps. For Bluetooth 5 and later, however, the rate varies depending on the
mode and PHY (discussed later in the Physical Layer section) being used.
The rate can be at 1 Mbps like earlier versions, or 2 Mbps when utilizing
the high-speed feature. When utilizing the long-range feature, the rate
drops to either 500 or 125 Kbps.
At the application layer and for the end-user, the data rate is much lower than
the radio data rate due to the following factors:

Gaps in between packets: The Bluetooth specification defines a gap of 150


microseconds between packets being transmitted as a requirement for
adhering to the specification. This gap is time lost with no data being
exchanged between two devices.
Packet overhead: All packets include header information and data handled at
levels lower than the application level, which count towards the data being
transmitted but are not part of the data utilized by your application.
Slave data packets requirement: The requirement to send back data packets
from the slave, even when no data needs to be sent back and empty packets are
sent.
Retransmission of data packets: In the case of packet loss or interference
from devices in the surrounding environment, the lost or corrupted data
packets get resent by the sender.
Range
BLE was designed for short range applications and hence its range of
operation is limited. There are a few factors that limit the range of BLE
including:
 It operates in the 2.4 GHz ISM spectrum which is greatly affected by
obstacles that exist all around us such as metal objects, walls, and water
(especially human bodies).

 Performance and design of the antenna of the BLE device.

 Physical enclosure of the device which affects the antenna


performance, especially if itʼs an internal antenna.

 Device orientation, which effectively relates to the positioning of the


antenna (e.g. in smartphones).
Gateway Requirement for Internet Connectivity
In order to transfer data from a BLE-only device to the Internet, another
BLE device that has an IP connection is needed to receive this data and
then, in turn, relay it to another IP device (or to the internet).
Advantages of BLE
Even with the previously mentioned limitations of BLE, it has presented some
significant advantages and benefits over other similar technologies in the IoT
space.
Some of these advantages include:
Lower power consumption
Even when compared to other low-power technologies, BLE achieves a
lower power consumption than its competitors. It's optimized, and less
power consumed, by turning the radio off as much as possible, in
addition to sending small amounts of data at low transfer speeds.
No cost to access the official specification documents
With most other wireless protocols and technologies, you would have to
become a member of the official group or consortium for that standard in
order to access the specification. Becoming a member of those groups
can cost a significant amount (up to thousands of dollars per year). With
BLE, the major version (4.0, 4.1, 4.2, 5) specification documents are
available to download from the Bluetooth website for free.
Lower cost of modules and chipsets when compared to other similar
technologies.

Its existence in most smartphones in the market. This is probably the


biggest advantage BLE has over its competitors such as ZigBee, Z-Wave,
and Thread.
Applications Most Suitable for BLE
Based on the limitations and benefits we mentioned earlier, there are a number
of use cases where BLE makes the most sense:

Low-bandwidth data
For cases where a device transfers small amounts of data representing
sensor data or for controlling actuators, BLE has proven to be a
suitable wireless protocol to utilize.
Device Configuration
Even in cases where BLE doesn’t satisfy the main requirements of a
system, it can still be used as a secondary interface to configure a
device before the main wireless connection is established.
For example, some Wi-Fi-enabled devices are adding BLE as a means to
configure and establish the Wi-Fi connection of the device instead of using
a technology such as Wi-Fi direct (a technology that allows two Wi-Fi
devices to connect directly without going through a Wi-Fi router. You can
Learn more about it at its Wikipedia page here).
Using a smartphone as an interface
Small, low-power devices usually donʼt have large screens and are only
capable of displaying limited amounts of data to the end user. Due to the
proliferation of smartphones nowadays, BLE can be utilized to offer an
alternate, much richer user interface to these small devices (even if just
for this sole purpose). Another by-product benefit of using a smartphone
is that the data can be relayed up to the cloud.
Personal and wearable devices
For use cases where a device is portable and can be located in areas
where no other persistent wireless connections exist (such as WiFi),
BLE can be used (since itʼs a direct peer-to-peer connection).
Broadcast-only devices
You’ve probably heard of, and maybe seen, Beacon devices before. These
devices have one simple task: to broadcast data so other devices may
discover them and read their data. There are other technologies that have
been used for this kind of application.
However, BLE is becoming more and more popular because
most people carry smartphones which already support BLE
out-of-the-box.

BLE protocol stack with neat block diagram

Physical Layer:
 The transmitter uses GFSK modulation and operates at unlicensed 2.4 GHz
frequency band.
 Using this PHY layer, BLE offers data rates of 1 Mbps (Bluetooth v4.2)/2 Mbps
(Bluetooth v5.0)
 It uses frequency hopping transceiver.
 Two PHY layer variants are specified viz. uncoded and coded.
Link Layer:
 This layer sits above the Physical layer. It is responsible for advertising,
scanning and creating/maintaining connections.
 The role of BLE devices changes in peer to peer (i.e., Unicast) of broadcast
modes. The common roles are Advertiser/Scanner (Initiator), Slave/Master or
Broadcaster/Observer.
HCI: It provides communication between controller and host through standard
interface types. This HCI layer can be implemented either using API or by interfaces
such as UART/SPI/USB. Standard HCI commands and events are defined in the
Bluetooth specifications.
L2CAP: This layer offers data encapsulation services to upper layers. This allows
logical end to end data communication.
SMP: This security Manager layer provides methods for device pairing and key
distributions. It offers services to other protocol stack layers in order to securely
connect and exchange data between BLE devices.
GAP: This layer directly interfaces with application layer and/or profiles on it. It
handles device discovery and connection related services for BLE device. It also takes
care of initiation of security features.
GATT: This layer is service framework which specifies sub-procedures to use ATT.
Data communications between two BLE devices are handled through these
subprocedures. The applications and/or profiles will use GATT directly.
ATT: This layer allows BLE device to expose certain pieces of data or attributes.
Application Layer:

 The BLE protocol stack layers interact with applications and profiles as desired.
Application interoperability in the Bluetooth system is accomplished by
Bluetooth profiles.
 The profile defines the vertical interactions between the layers as well as the
peer-to-peer interactions of specific layers between devices.
 A profile composed of one or more services to address particular use case. A
service consists of characteristics or references to other services.
 Any profiles/applications run on top of GAP/GATT layers of BLE protocol stack.
It handles device recovery and connection related services for the BLE device.

Essential features associated with PSOC4 BLE architecture.


The PSoC 4000 family has these major components:
 32-bit Cortex-M0 CPU with single-cycle multiply, delivering up to 14
DMIPS at 16 MHz
 Up to 16 KB flash and 2 KB SRAM

 A center-aligned pulse-width modulator (PWM) with complementary, dead-


band programmable outputs
 I2C communication block with slave, master, and multi- master operating
modes
 CapSense

 Low-power operating modes: Sleep and Deep-Sleep

 Programming and debugging system through serial wire debug (SWD)

 Two current sourcing/sinking DACs (IDACs)

 Comparator with 1.2 V reference

 Fully supported by PSoC Creator™ IDE too


Contents
Communication..............................................................................................................1
Sensing..........................................................................................................................1
Properties of a sensor:.............................................................................................2
Sensor classification...............................................................................................3
Types of sensors......................................................................................................3
1. Temperature sensors:...................................................................................3
2. Humidity sensors:.........................................................................................3
3. Pressure sensors...............................................................................................3
4. Proximity sensors............................................................................................4
5. Level sensors.................................................................................................4
6. Gyroscope sensors........................................................................................4
7. Gas sensors....................................................................................................4
8. Infrared sensors.............................................................................................5
9. Optical sensors..............................................................................................5
Actuation........................................................................................................................5
Types of Actuators..................................................................................................6
1. Hydraulic actuator........................................................................................6
2. Pneumatic Actuators....................................................................................7
3. Electrical actuators.......................................................................................7
I/O interfaces................................................................................................................7
Software Components- Programming API’s (using Python / Node.js /Arduino)
for Communication.......................................................................................................9
What is an IoT API?...................................................................................................9
How do APIs and IoT work together?.....................................................................10
What is an API endpoint and why is it important?..................................................10
Main types of IoT APIs............................................................................................10
Public APIs...........................................................................................................11
Partner APIs.........................................................................................................11
Internal APIs........................................................................................................11
Composite APIs...................................................................................................11
Types of API architectures and delivery formats.....................................................11
SOAP API............................................................................................................11
REST API.............................................................................................................12
JSON (JavaScript Object Notation) and XML (Extensible Markup Language)..12
Examples of IoT APIs..............................................................................................13
Benefits of IoT APIs................................................................................................13
Arduino rest framework.......................................................................................14
Define an API?.........................................................................................................17
APIs Implementation Using REST Methods:..........................................................19
Protocols.....................................................................................................................20
1. MQTT..............................................................................................................20
Advantages.........................................................................................................20
MQTT architecture...........................................................................................20
MQTT messages................................................................................................21
2. ZigBee..............................................................................................................22
Finding ZigBee’s place in the industrial IoT...............................................23
Challenges and Shortcoming..........................................................................24
Architecture of Zigbee:.......................................................................................25
Zigbee Applications:...........................................................................................26
3. CoAP................................................................................................................26
Architecture........................................................................................................26
4. UDP..................................................................................................................28
Resource constrained devices.........................................................................28
UDP Security.....................................................................................................29
UDP datagrams..................................................................................................29
Advantages of UDP..........................................................................................30
5. TCP...................................................................................................................31
TCP in the Internet of Things.........................................................................32
6. HTTP................................................................................................................32
7. Bluetooth.........................................................................................................35
Bluetooth Strengths and Weaknesses............................................................36
Bluetooth Connecting IoT in the Future.......................................................37
Different versions of Bluetooth............................................................................38
Technical Facts About BLE...........................................................................................39
Bluetooth Classic vs. BLE...................................................................................41
Advantages and Limitations of BLE....................................................................41
Advantages of BLE..............................................................................................43
Applications Most Suitable for BLE....................................................................43
BLE protocol stack with neat block diagram...........................................................45
Physical Layer:.....................................................................................................45
Link Layer:...........................................................................................................45
Application Layer:...............................................................................................46
Essential features associated with PSOC4 BLE architecture...................................46

You might also like