Unit Ii

Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

lOMoARcPSD|316 591 08

Unit-2 Elements of Io T
lOMoARcPSD|316 591 08

1. Hardware components of IoT


• Arduino
Arduino is an open-source platform used for building electronics projects. Arduino
consists of both a physical programmable circuit board (often referred to as
a microcontroller) and a piece of software, or IDE (Integrated Development Environment)
that runs on your computer, used to write and upload computer code to the physical board.
Unlike most previous programmable circuit boards, the Arduino does not need a separate
piece of hardware (called a programmer) in order to load new code onto the board -- you
can simply use a USB cable. Additionally, the Arduino IDE uses a simplified version of
C++, making it easier to learn to program. Finally, Arduino provides a standard form
factor that breaks out the functions of the micro-controller into a more accessible package.

How arduino works?


The Arduino hardware and software was designed for artists, designers, hobbyists,
hackers, newbies, and anyone interested in creating interactive objects or environments.
Arduino can interact with buttons, LEDs, motors, speakers, GPS units, cameras, the
internet, and even your smart-phone or your TV! This flexibility combined with the fact
that the Arduino software is free, the hardware boards are pretty cheap, and both the
software and hardware are easy to learn has led to a large community of users who have
contributed code and released instructions for a huge variety of Arduino-based projects.
For everything from robots and a heating pad hand warming blanket to honest fortune-
telling machines, and even the Arduino can be used as the brains behind almost any
electronics project.
lOMoARcPSD|316 591 08

Arduino board
There are many varieties of Arduino boards (explained on the next page) that can be used
for different purposes. Some boards look a bit different from the one below, but most
Arduinos have the majority of these components in common:

• Power (USB / Barrel Jack): Every Arduino board needs a way to be connected to a
power source. The Arduino UNO can be powered from a USB cable coming from your
computer or a wall power supply (like this) that is terminated in a barrel jack. In the
picture above the USB connection is labeled (1) and the barrel jack is labeled (2).

• Pins (5V, 3.3V, GND, Analog, Digital, PWM, AREF): The pins on your Arduino are
the places where you connect wires to construct a circuit (probably in conjuction with
a breadboard and some wire. They usually have black plastic ‘headers’ that allow you
to just plug a wire right into the board. The Arduino has several different kinds of pins,
each of which is labeled on the board and used for different functions.

✓ GND (3): Short for ‘Ground’. There are several GND pins on the Arduino, any of
which can be used to ground your circuit.
✓ 5V (4) & 3.3V (5): As you might guess, the 5V pin supplies 5 volts of power, and
the 3.3V pin supplies 3.3 volts of power. Most of the simple components used with
the Arduino run happily off of 5 or 3.3 volts.
✓ Analog (6): The area of pins under the ‘Analog In’ label (A0 through A5 on the
UNO) is Analog In pins. These pins can read the signal from an analog sensor (like
a temperature sensor) and convert it into a digital value that we can read.
✓ Digital (7): Across from the analog pins are the digital pins (0 through 13 on the
UNO). These pins can be used for both digital input (like telling if a button is
pushed) and digital output (like powering an LED).
lOMoARcPSD|316 591 08

✓ PWM (8): You may have noticed the tilde (~) next to some of the digital pins (3, 5,
6, 9, 10, and 11 on the UNO). These pins act as normal digital pins, but can also be
used for something called Pulse-Width Modulation (PWM). We have a tutorial on
PWM, but for now, think of these pins as being able to simulate analog output (like
fading an LED in and out).
✓ AREF (9): Stands for Analog Reference. Most of the time you can leave this pin
alone. It is sometimes used to set an external reference voltage (between 0 and 5
Volts) as the upper limit for the analog input pins.

• Reset Button: Just like the original Nintendo, the Arduino has a reset button (10).
Pushing it will temporarily connect the reset pin to ground and restart any code that is
loaded on the Arduino. This can be very useful if your code doesn’t repeat, but you
want to test it multiple times. Unlike the original Nintendo however, blowing on the
Arduino doesn't usually fix any problems.

• Power LED Indicator: Just beneath and to the right of the word “UNO” on your circuit
board, there’s a tiny LED next to the word ‘ON’ (11). This LED should light up
whenever you plug your Arduino into a power source. If this light doesn’t turn on,
there’s a good chance something is wrong.

• TX RX LEDs: TX is short for transmit, RX is short for receive. These markings appear
quite a bit in electronics to indicate the pins responsible for serial communication. In
our case, there are two places on the Arduino UNO where TX and RX appear -- once
by digital pins 0 and 1, and a second time next to the TX and RX indicator LEDs (12).
These LEDs will give us some nice visual indications whenever our Arduino is
receiving or transmitting data (like when we’re loading a new program onto the board).

• Main IC: The black thing with all the metal legs is an IC, or Integrated Circuit (13).
Think of it as the brains of our Arduino. The main IC on the Arduino is slightly
different from board type to board type, but is usually from the ATmega line of IC’s
from the ATMEL company. This can be important, as you may need to know the IC
type (along with your board type) before loading up a new program from the Arduino
software. This information can usually be found in writing on the top side of the IC. If
you want to know more about the difference between various IC's, reading the
datasheets is often a good idea.

• Voltage Regulator: The voltage regulator (14) is not actually something you can (or
should) interact with on the Arduino. But it is potentially useful to know that it is there
and what it’s for. The voltage regulator does exactly what it says -- it controls the
amount of voltage that is let into the Arduino board. Think of it as a kind of gatekeeper;
it will turn away an extra voltage that might harm the circuit. Of course, it has its limits,
so don’t hook up your Arduino to anything greater than 20 volts.
lOMoARcPSD|316 591 08

• Raspberry pi
The Raspberry pi is a single computer board with credit card size, that can be used for
many tasks that your computer does, like games, word processing, spreadsheets and also
to play HD video. It was established by the Raspberry pi foundation from the UK. It has
been ready for public consumption since 2012 with the idea of making a low-cost
educational microcomputer for students and children. The main purpose of designing the
raspberry pi board is, to encourage learning, experimentation and innovation for school
level students. The raspberry pi board is a portable and low cost. Maximum of the
raspberry pi computers is used in mobile phones. In the 20th century, the growth of mobile
computing technologies is very high, a huge segment of this being driven by the mobile
industries. The 98% of the mobile phones were using ARM technology.

Raspberry Pi Hardware Specifications

The raspberry pi board comprises a program memory (RAM), processor and graphics
chip, CPU, GPU, Ethernet port, GPIO pins, Xbee socket, UART, power source connector
and various interfaces for other external devices. It also requires mass storage, for that we
use an SD flash memory card. So that raspberry pi board will boot from this SD card
similarly as a PC boots up into windows from its hard disk

Essential hardware specifications of raspberry pi board mainly include SD card containing


Linux OS, US keyboard, monitor, power supply and video cable. Optional hardware
specifications include USB mouse, powered USB hub, case, internet connection, the
Model A or B: USB WiFi adaptor is used and internet connection to Model B is LAN
cable.
lOMoARcPSD|316 591 08

• Memory: The raspberry pi model Aboard is designed with 256MB of SDRAM and
model B is designed with 51MB.Raspberry pi is a small size PC compare with other
PCs. The normal PCs RAM memory is available in gigabytes. But in raspberry pi
board, the RAM memory is available more than 256MB or 512MB

• CPU (Central Processing Unit): The Central processing unit is the brain of the
raspberry pi board and that is responsible for carrying out the instructions of the
computer through logical and mathematical operations. The raspberry pi uses ARM11
series processor, which has joined the ranks of the Samsung galaxy phone.

• GPU (Graphics Processing Unit): The GPU is a specialized chip in the raspberry pi
board and that is designed to speed up the operation of image calculations. This board
designed with a Broadcom video core IV and it supports OpenGL
lOMoARcPSD|316 591 08

• Ethernet Port: The Ethernet port of the raspberry pi is the main gateway for
communicating with additional devices. The raspberry pi Ethernet port is used to plug
your home router to access the internet.

• GPIO Pins: The general purpose input & output pins are used in the raspberry pi to
associate with the other electronic boards. These pins can accept input & output
commands based on programming raspberry pi. The raspberry pi affords digital GPIO
pins. These pins are used to connect other electronic components. For example, you can
connect it to the temperature sensor to transmit digital data.

• XBee Socket: The XBee socket is used in raspberry pi board for the wireless
communication purpose.

• Power Source Connector: The power source cable is a small switch, which is placed
on side of the shield. The main purpose of the power source connector is to enable an
external power source.

• UART: The Universal Asynchronous Receiver/ Transmitter is a serial input & output
port. That can be used to transfer the serial data in the form of text and it is useful for
converting the debugging code.

• Display: The connection options of the raspberry pi board are two types such as HDMI
and Composite. Many LCD and HD TV monitors can be attached using an HDMI male
cable and with a low-cost adaptor. The versions of HDMI are 1.3 and 1.4 are supported
and 1.4 version cable is recommended. The O/Ps of the Raspberry Pi audio and video
through HMDI, but does not support HDMI I/p. Older TVs can be connected using
composite video. When using a composite video connection, audio is available from the
3.5mm jack socket and can be sent to your TV. To send audio to your TV, you need a
cable which adjusts from 3.5mm to double RCA connectors.

2. Communication in IoT
lOMoARcPSD|316 591 08

IoT is connection of devices over internet, where these smart devices communicate with
each other, exchange data , perform some tasks without any human involvement. These
devices are embedded with electronics, software, network and sensors which help in
communication. Communication between smart devices is very important in IOT as it
enables these devices to gather, exchange data which contribute in success of that IOT
product/project.

Types of Communications in IOT:

The following are some communication types in IoT:-

a. Human to Machine (H2M):


In this human gives input to IOT device i.e as speech/text/image etc. IOT device
(Machine)like sensors and actuators then understands input, analyses it and responds
back to human by means of text or Visual Display. This is very useful as these machines
assist humans in every everyday tasks. It is a combo of software and hardware that
includes human interaction with a machine to perform a task.

H2M communication

Merits: This H2M has a user-friendly interface that can be quickly accessed by
following the instructions. It responds more quickly to any fault or failure. Its features
and functions can be customized.
Examples:
• Facial recognition.
• Bio-metric Attendance system.
• Speech or voice recognition.

b. Machine to Machine (M2M):


In this the interaction or communication takes place between machines by automating
data/programs. In this machine level instructions are required for communication. Here
communication takes place without human interaction. The machines may be either
connected through wires or by wireless connection. An M2M connection is a point-to-
point connection between two network devices that helps in transmitting information
using public networking technologies like Ethernet and cellular networks. IoT uses the
basic concepts of M2M and expands by creating large “cloud” networks of devices that
communicate with one another through cloud networking platforms.
lOMoARcPSD|316 591 08

M2M communication

Merits: This M2M can operate over cellular networks and is simple to manage. It can be
used both indoors and outdoors and aids in the communication of smart objects without
the need for human interaction. The M2M contact facility is used to address security and
privacy problems in IoT networks. Large-scale data collection, processing, and security
are all feasible.

Demerits: However, in M2M, use of cloud computing restricts versatility and creativity.
Data security and ownership are major concerns here. The challenge of
achieving interoperability between cloud/M2M IoT systems is daunting. M2M
connectivity necessitates the existence of a reliable internet connection.

Examples:
• Smart Washing machine sends alerts to the owners’ smart devices after completion
of washing or drying of clothes.
• Smart meters tracks amount of energy used in household or in companies and
automatically alert the owner.

c. Machine to Human (M2H) :


In this machine interacts with Humans. Machine triggers information (text
messages/images/voice/signals) respective / irrespective of any human presence. This
type of communication is most commonly used where machines guide humans in their
daily life. It is way of interaction in which humans co-work with smart systems and
other machines by using tools or devices to finish a task.

M2H communication

Examples:
• Fire Alarms
lOMoARcPSD|316 591 08

• Traffic Light
• Fitness bands
• Health monitoring devices

d. Human to Human (H2H) :


This is generally how humans communicate with each other to exchange information by
speech, writing, drawing, facial expressions, body language etc. Without H2H, M2M
applications cannot produce the expected benefits unless humans can immediately fix
issues, solve challenges, and manage scenarios.

H2H communication

3. IoT I/O Interface

The process of connecting devices together so that they can exchange the information is called
interfacing. In order for these devices to swap their information, they must share a common
communication protocol.

Generally, communication protocol can be separated two categories: parallel or serial.

Interfaces

Parallel: A parallel interface refers to a multi-line channel with each line capable of
transmitting several bits of data simultaneously. They usually require buses of data —
transmitting across eight, sixteen, or more wires. Data is transferred in huge, crashing waves
of 1’s and 0’s.

Serial: Serial interfaces stream their data, one single bit at a time. These interfaces can operate
on as little as one wire, usually never more than four.
lOMoARcPSD|316 591 08

Serial interfaces have certain advantages over parallel interfaces. The most significant
advantage is simpler wiring. In addition, serial interface cables can be longer than parallel
interface cables, because there is much less interaction (crosstalk) among the conductors in the
cable.

Most hardware interfaces are serial interfaces sacrificing potential speed in parallel. Serial
interfaces generally use multiple wires to control the flow and timing of binary information
along the primary data wire. Each type of hardware interface defines a method of
communicating between a peripheral and the central processor.

IoT hardware platforms use a number of common interfaces. Sensor and actuator modules can
support one or more of these interfaces:

• USB. Universal Serial Bus is a technology that allows a person to connect an


electronic device to a microcontroller. It is a fast serial bus.

• GPIO. General-purpose input/output pins area generic pin on an integrated circuit or


computer board whose behavior — including whether it is an input or output pin — is
controllable by the user at run time. GPIO pins have no predefined purpose, and go
unused by default. GPIO pins can be designed to carry digital or analog signals, and
digital pins have only two states: HIGH or LOW.

• Digital GPIO can support Pulse Width Modulation (PWM). PWM lets you very
quickly switch a power source on and off, with each “on” phase being a pulse of a
particular duration, or width. The effect in the device can be a lower or higher power
level. For example, you can use PWM to change the brightness of an LED; the wider the
“on” pulses, the brighter the LED glows.

• Analog pins might have access to an on-board analog-to-digital conversion (ADC)


circuit. An ADC periodically samples a continuous, analog waveform, such as an analog
audio signal, giving each sample a digital value between zero and one, relative to the
system voltage.

• When you read the value of a digital I/O pin in code, the value can must be either
HIGH or LOW, where an analog input pin at any given moment could be any value in a
range. The range depends on the resolution of the ADC. For example an 8-bit ADC can
produce digital values from 0 to 255, while a 10-bit ADC can yield a wider range of
values, from 0 to 1024. More values means higher resolution and thus a more faithful
digital representation of any given analog signal.

• The ADC sampling rate determines the frequency range that an ADC can reproduce. A
higher sampling rate results in a higher maximum frequency in the digital data. For
example, an audio signal sampled at 44,100 Hz produces a digital audio file with a
frequency response up to 22.5 kHz, ignoring typical filtering and other processing.
The bit precision dictates the resolution of the amplitude of the signal.
lOMoARcPSD|316 591 08

• I2C. Inter-Integrated Circuit serial bus uses a protocol that enables multiple modules to
be assigned a discrete address on the bus. I2C is sometimes pronounced “I two C”, “I-I-
C”, or “I squared C”. I has two wires, a clock and data wire.

• SPI. Serial Peripheral Interface/Interchange Bus devices employ a master-slave


architecture, with a single master and full-duplex communication.

• UART. Universal Asynchronous Receiver/Transmitter devices translate data between


serial and parallel forms at the point where the data is acted on by the processor. UART is
required when serial data must be laid out in memory in a parallel fashion.

• RS 232 Recommended Standard 232 is used for obtaining communication between the
computer and circuit such to transfer data between circuit and computer.

4. Software components of IoT

➢ Programming
The software and the programming languages on which IoT works uses very common
programming languages that programmers use and already know, So which language
should be chosen?
Firstly, because embedded systems have less storage and processing power, their language
needs are different. The most commonly used operating systems for such embedded
systems are Linux or UNIX-like OSs like Ubuntu Core or Android.
IoT software encompasses a wide range of software and programming languages from
general-purpose languages like C++ and Java to embedded-specific choices like Google’s
Go language or Parasail.

Here’s a quick overview of each one of IoT Software-

• C & C++: The C programming language has its roots in embedded systems—it even
got its start for programming telephone switches. It’s pretty ubiquitous, that is, it can
be used almost everywhere and many programmers already know it. C++ is theobject-
oriented version of C, which is a language popular for both the Linux OS and Arduino
embedded IoT software systems. These languages were basically written for the
hardware systems which make them so easy to use.

• Java: While C and C++ are hardware specific, the code in JAVA is more portable. It
is more like a write once and read anywhere language, where you install libraries,
invests time in writing codes once and you are good to go.
lOMoARcPSD|316 591 08

• Python: There has been a recent surge in the number of python users and has now
become one of the “go-to” languages in Web development. Its use is slowly spreading
to the embedded control and IoT world—specially the Raspberry Pi processor. Python
is an interpreted language, which is, easy to read, quick to learn and quick to write.
Also, it’s a powerhouse for serving data-heavy applications.

• B#: Unlike most of the languages mentioned so far, B# was specifically designed for
embedded systems, it’s small and compact and has less memory size.

• Data Collection: It is used for data filtering, data security, sensing, and measurement.
The protocols aid in decision making by sensing form real-time objects. It can work
both ways by collecting data from devices or distributing data to devices. All the data
transmits to a central server.

• Device Integration: This software ensures that devices bind and connect to networks
facilitating information sharing. A stable cooperation and communication ensure
between multiple devices.

• Real-Time Analytics: In this, the input from users serves as potential data for
carrying out real-time analysis, making insights, suggesting recommendations to solve
organizations problems and improve its approach. This, as a result, allows automation
and increased productivity.

• Application and Process Extension: These applications extend the reach of existing
systems and software to allow a wider, more effective system. They integrate
predefined devices for specific purposes such as allowing certain mobile devices or
engineering instruments access. It supports improved productivity and more accurate
data collection.

5. Protocols in IoT
lOMoARcPSD|316 591 08

➢ MQTT protocol
MQTT stands for Message Queuing Telemetry Transport. MQTT is a machine to
machine internet of things connectivity protocol. It is an extremely lightweight and
publish-subscribe messaging transport protocol. This protocol is useful for the connection
with the remote location where the bandwidth is a premium. These characteristics make it
useful in various situations, including constant environment such as for communication
machine to machine and internet of things contexts. It is a publish and subscribe system
where we can publish and receive the messages as a client. It makes it easy for
communication between multiple devices. It is a simple messaging protocol designed for
the constrained devices and with low bandwidth, so it's a perfect solution for the internet
of things applications.

Characteristics of MQTT

The MQTT has some unique features which are hardly found in other protocols. Some of
the features of an MQTT are given below:

• It is a machine to machine protocol, i.e., it provides communication between the


devices.
• It is designed as a simple and lightweight messaging protocol that uses a
publish/subscribe system to exchange the information between the client and the
server.
• It does not require that both the client and the server establish a connection at the
same time.
• It provides faster data transmission, like how WhatsApp/messenger provides a faster
delivery. It's a real-time messaging protocol.
• It allows the clients to subscribe to the narrow selection of topics so that they can
receive the information they are looking for.

History of MQTT
lOMoARcPSD|316 591 08

The MQTT was developed by Dr. Andy Stanford-Clark, IBM and Arlen Nipper. The
previous versions of protocol 3.1 and 3.1.1 were made available under MQTT ORG. In
2014, the MQTT was officially published by OASIS. The OASIS becomes a new home
for the development of the MQTT. Then, the OASIS started the further development of the
MQTT. Version 3.1.1 is backward comfortable with a 3.1 and brought only minor changes
such as changes to the connect message and clarification of the 3.1 version. The recent
version of MQTT is 5.0, which is a successor of the 3.1.1 version. Version 5.0 is not
backward, comfortable like version 3.1.1. According to the specifications, version 5.0 has
a significant number of features that make the code in place.

The major functional objectives in version 5.0 are:

o Enhancement in the scalability and the large-scale system in order to set up with the
thousands or the millions of devices.
o Improvement in the error reporting

MQTT Architecture

To understand the MQTT architecture, we first look at the components of the MQTT.

• Message
• Client
• Server or Broker
• TOPIC

Message: The message is the data that is carried out by the protocol across the network
for the application. When the message is transmitted over the network, then the message
contains the following parameters:

1. Payload data
2. Quality of Service (QoS)
3. Collection of Properties
4. Topic Name

Client: In MQTT, the subscriber and publisher are the two roles of a client. The clients
subscribe to the topics to publish and receive messages. In simple words, we can say that
if any program or device uses an MQTT, then that device is referred to as a client. A
device is a client if it opens the network connection to the server, publishes messages that
other clients want to see, subscribes to the messages that it is interested in receiving,
unsubscribes to the messages that it is not interested in receiving, and closes the network
connection to the server.

In MQTT, the client performs two operations:


lOMoARcPSD|316 591 08

• Publish: When the client sends the data to the server, then we call this operation as a
publish.

• Subscribe: When the client receives the data from the server, then we call this
operation a subscription.

Server: The device or a program that allows the client to publish the messages and
subscribe to the messages. A server accepts the network connection from the client,
accepts the messages from the client, processes the subscribe and unsubscribe requests,
forwards the application messages to the client, and closes the network connection from
the client.

TOPIC:

The label provided to the message is checked against the subscription known by the
server is known as TOPIC.

Architecture of MQTT
lOMoARcPSD|316 591 08

Suppose a device has a temperature sensor and wants to send the rating to the server or the
broker. If the phone or desktop application wishes to receive this temperature value on the
other side, then there will be two things that happened. The publisher first defines the topic;
for example, the temperature then publishes the message, i.e., the temperature's value. After
publishing the message, the phone or the desktop application on the other side will subscribe
to the topic, i.e., temperature and then receive the published message, i.e., the value of the
temperature. The server or the broker's role is to deliver the published message to the phone
or the desktop application.

MQTT Message Format

The MQTT uses the command and the command acknowledgment format, which means that
each command has an associated acknowledgment. As shown in the above figure that the
connect command has connect acknowledgment, subscribe command has subscribe
acknowledgment, and publish command has publish acknowledgment. This mechanism is
similar to the handshaking mechanism as in TCP protocol.

The MQTT message format consists of 2 bytes fixed header, which is present in all the
MQTT packets. The second field is a variable header, which is not always present. The third
field is a payload, which is also not always present. The payload field basically contains the
data which is being sent. We might think that the payload is a compulsory field, but it does
not happen. Some commands do not use the payload field, for example, disconnect message.

Fixed Header
lOMoARcPSD|316 591 08

Let's observe the format of the fixed header.

As we can observe in the above format that the fixed header contains two bytes. The first byte
contains the following fields:

o MQTT Control Packet Type: It occupies 4 bits, i.e., 7 to 4-bit positions. This 4-bit is
an assigned value, and each bit represents the MQTT control packet type.
o Flag specific to each MQTT packet type: The remaining 4-bits represent flag
specific to each MQTT packet type.

The byte 2 contains the remaining length, which is a variable-length byte integer. It represents
the number of bytes remaining in a current control packet, including data in the variable
header and payload. Therefore, we can say that the remaining length is equal to the sum of
the data in the variable header and the payload.

MQTT Control Packet Types


lOMoARcPSD|316 591 08

The above table shows the control packet types with 4-bit value and direction flow. As we
can observe that every command is followed by acknowledgment like CONNECT has
CONNACK, PUBLISH has PUBACK, PUBREC, PUBREL, and PUBCOMP, SUBSCRIBE
has SUBACK, UNSUBSCRIBE has UNSUBACK.

Flag Bit
lOMoARcPSD|316 591 08

The above table shows the flag value associated with each command. Here, reserved refers to
future use, which means that it is not being used right now. In the case of PUBLISH
command, flag bits are further divided into DUP, QoS, and RETAIN, where DUP is a
duplicate delivery of a PUBLISH packet, QoS is Quality of Service, and RETAIN is retained
message flag.

Remaining length

The remaining length is a variable-length integer that denotes the number of bytes remaining
within the current control packet, including data in the variable header and the payload.
Therefore, the remaining length is equal to the data in the variable header plus payload.

Remaining length = length of variable header + length of payload

For example, if the length of the variable header is 20 and the length of the payload is 30,
then the remaining length is 50.

The remaining length can be used upto 4 bytes, and it starts from 2 bytes and can be used
upto 4 bytes.

This field uses 7-bit for the lengths, and MSB bit can be used to continue a flag. If the
continuation flag is 1, the next byte is also a part of the

remaining length. If the continuation flag is 0, a byte is the last one of the remaining length.

Variable header

Some types of MQTT control packet types contain an optional field also, i.e., variable header
component. This field resides between the fixed header and the payload. The content of the
variable header depends upon the packet type. The variable header contains the packet
identifier field, which is common in several packet types. The variable header component of
many MQTT control packet types includes 2-byte integer, i.e., the packet identifier field.

The given list below contains the packet identifier field:

o PUBLISH
o PUBACK
o PUBREC
o PUBREL
o PUBCOMP
o SUBSCRIBE
o SUBACK
o UNSUBSCRIBE
o UNSUBACK
lOMoARcPSD|316 591 08

➢ 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 sensor 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 a standard that addresses the need of very low-cost implementation of Low
power devices with Low data rate for short-range wireless communications.
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)

Operating Frequency Bands (Only one channel will be selected for use in a
network):
1. Channel 0: 868 MHz (Europe)
2. Channel 1-10: 915 MHz (US and Australia)
3. Channel 11-26: 2.4 GHz (Across the World)
lOMoARcPSD|316 591 08

Zigbee Network Topologies:


• Star Topology (ZigBee Smart Energy)
• Mesh Topology (Self Healing Process)
• Tree Topology

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

• The Application layer is present at the user level.


• The Application Interface Layer, Security Layer, and Network Layer are the Zigbee
Alliance and they are used to store data and they use the stack.
• Medium Access control and the Physical layer are the IEEE 802.15.4 and they are
hardware which are silicon means they accept only 0 and 1.

Channel Access:
1. Contention Based Method (Carrier-Sense Multiple Access With Collision
Avoidance Mechanism)
2. Contention Free Method (Coordinator dedicates specific time slot to each device
(Guaranteed Time Slot (GTS)))

Applications of ZigBee Technology


Its three major USPs are low-cost, low-power consumption and having faster wireless
connectivity, the ZigBee protocol caters to a lot of applications like industrial automation,
home automation, smart metering, smart grids etc. Also with it low-power requirements, it
ensures seamless operation of various sensor equipments offering years of battery-life.
Here are some of the areas where ZigBee is widely used.
lOMoARcPSD|316 591 08

• Industrial Automation: ZigBee offers a faster and low-cost communication that can
communicate with almost all devices in factories and centralise them at one place
making it easy for you to monitor every process and thereby optimise the control
process. ZigBee protocol also finds its presence in many medical and scientific
equipments such as personal chronic monitoring, sports and fitness trackers, and can
even be used for remote patient monitoring.

• Smart Metering and Smart Grid Monitoring: In case of smart metering, ZigBee is
used for better energy consumption response, security over power theft, pricing
support etc. Additionally in case of smart grids, ZigBee is even used for reactive
power management, fault locations, remote temperature monitoring, etc.

• Home Automation: ZigBee is one of the most widely used protocol in most of the
home automation equipments. Right from offering lighting system solutions, sensor
responsive solutions to security solutions and surveillance, ZigBee has its presence
everywhere.

ZigBee for Home Automation

ZigBee protocol is widely used for home automation solutions and caters to complete
holistic solutions of lighting control, security control, comfort control and even energy
management.

There are several well-known globals brands in home automation that use ZigBee for their
devices. Since Zigbee is cross-compatible and interoperable, it makes managing multi-
vendor devices easy and simple. If a device is ZigBee Home Automation (HA
2.1) compliant, you can be rest assured that it will work with your automation system,
irrespective of the vendor.

The mesh-routing network of ZigBee wherein one device can talk to multiple device and
data packets travel on no fixed routes, offers better flexibility and faster communication
across devices.
lOMoARcPSD|316 591 08

Some of the features of ZigBee for Home Automation include:


• Simplified setup and maintenance
• Ideal for new construction and remodelling
• ZigBee gives access to devices anywhere from the world just from your smartphone
• Monitors power use and allows you to turn on/off devices from remote locations
• Built in security with interference avoidance techniques ensures better/enhanced
security and worry-free operations.
• Help you customise lighting scenes based on daily schedules, events and activities.
• Due to low-power consumption of the ZigBee protocol, your security sensors can
work for a period of 7 years.

➢ Bluetooth
Bluetooth has been in the tech market as a wireless channel of connection between
devices since Ericsson invented it in 1994. Since then, Bluetooth technology has evolved
and has become the go-to wireless connectivity solution for wearables, gadgets, and
other devices. Nowadays, you will find Bluetooth everywhere; cars, speakers, wearables,
medical devices, wireless headphones, shoes, etc. If you own any modern device, it is
safe to assume that you have encountered and used Bluetooth technology at one point or
the other. In other words, Bluetooth is a short-range wireless technology medium used
for exchanging data between two electronic devices (usually mobile) over a short
distance. This process completely eliminates the primitive use of cables for connectivity.
A typical example is how you can listen to music with a headset on the go without
having to plug it into the headset jack of your mobile device.

Bluetooth exchange works using UHF radio waves, otherwise known as short wave
radio, with radio bands ranging from 2.402 GHz to 2.480 GHz and building a Personal
Area Network (PAN). Typically, a master Bluetooth device can connect to a maximum of
seven devices at a go. Still, some Bluetooth devices do not have the capacity to connect
up to this number of devices. However, this kind of connection is called a piconet, an ad
hoc computer network created at that moment using Bluetooth technology. And in this
technology system, connected operate in a master-slave relationship. For example,
lOMoARcPSD|316 591 08

suppose you initiate a connection between a phone and a wireless headset through a
headset; in that case, the headset becomes the master (the initiator), and the phone is the
slave. Subsequently, both devices can switch roles and have the phone operate as the
master, while the headset becomes the slave. Ultimately, in a Bluetooth piconet, it is
possible for a master to have seven slaves; and for a slave to have more than one master.

Bluetooth Classic and Bluetooth Low Energy (BLE)

There are two Bluetooth variants of the Bluetooth technology; hence all Bluetooth
devices can be classified into two categories – Bluetooth Classic and Bluetooth Low
Energy (BLE). On the one hand, the Bluetooth Classic is usually used in wireless
speakers, headsets, and car infotainment systems. On the other hand, Bluetooth Low
Energy (just as the name implies) is more prominent in applications that are keen on
power consumption and transfer small amounts of data less often. In other words, BLE is
commonly found in battery-powered devices like mobile phones, sensor devices, etc. As
opposed to the Bluetooth Classic that consumes high energy, Bluetooth Low Energy
thrives on reduced power consumption and cost, even while maintaining a similar
communication range as Bluetooth Classic.

It is important to note that these two kinds of Bluetooth devices are inharmonious even
when they share the same brand and specification document. That is to say, a Bluetooth
Classic cannot work together with Bluetooth Low Energy. So, it is not farfetched why
some devices like smartphones integrate both Bluetooth variants to communicate with
and connect to either type of Bluetooth present in other devices.

Bluetooth In IoT

Despite its common uses, Bluetooth has become a household name in the Internet of
Things community. It is a serious technology used for IoT applications. Apart from being
the ubiquitous solution for hands-free calling and wireless transmission technology for
lOMoARcPSD|316 591 08

audio, Bluetooth technology is leading in consumer and business IoT. Since a device-to-
device connection is expected to be fast, seamless, and wireless in the Internet of
Things, internet of things Bluetooth (Bluetooth IoT) is highly deployed because of its no-
internet function on the one hand and its capability to create large-scale device networks
via Bluetooth mesh, on the other hand.

Bluetooth Mesh Networking

Bluetooth mesh IoT is a computer mesh networking system based on Bluetooth Low
Energy (BLE) that allows for many-to-many communication among connected devices
over a Bluetooth radio. In a Bluetooth mesh IoT network, every message has a source
and destination address through which devices publish messages to their destinations,
which is a single thing, group of things, or everything.

Bluetooth mesh IoT networking is a game changer for wireless device networks. It is no
surprise that it sets a stage for a new wave of connectivity from whole-building networks
to city-wide smart services, especially in the present era of the home, building,
community, and industrial automation.

Why Bluetooth in IoT?

Bluetooth Low Energy in IoT can help IoT devices conserve energy by keeping the
devices in sleep mode when they are not in use, then let users exit the mode when
connected or reconnected. Bluetooth Low Energy in IoT is ideal for IoT applications
because, contrary to the classic Bluetooth applications, which reconnect to devices at a
time of six seconds or more, IoT BLE applications can quickly pair and reconnect with
devices in six milliseconds instead.

In IoT BLE, a device can function in three stages; the Advertising stage, Scanning stage,
and Connected stage. In a scenario where you want to integrate two BLE devices with
each other, one device has to advertise. In contrast, the other has to scan for the device
lOMoARcPSD|316 591 08

advertising before subsequently initiating a connection. Advertising basically involves


broadcasting packets that allow another scanning device to find them.

Bluetooth IoT Devices

Advertising is deployed in all Bluetooth IoT devices, but one prominent application that
exclusively functions in this state is the Beacon technology. Beacon devices, like
the MOKOBlue M1 Ultra-thin Beacon, stay in the Advertising mode while broadcasting
data to other devices that they can explore and read such data from. Since advertising
data capacity is increased in Bluetooth 5.0, Beacons can unlock new IoT applications and
use cases by transmitting more data.

Properties of Bluetooth network

• Standard: Bluetooth 4.2


• Frequency: 2.4GHz
• Range: 50-150m
• Data transfer rates: 3Mbps

Advantages of Bluetooth network

• It is wireless.
• It is cheap.
• It is easy to install.
• It is free to use if the device is installed with it.

Disadvantages of Bluetooth network

• It is a short-range communication network.


• It connects only two devices at a time.
lOMoARcPSD|316 591 08

➢ Constrained Application Protocol


CoAP a customary client-server IoT protocol. It enables clients to make requests for web
transfers as per the need of the hour. On the other hand, it also let supporting servers to
respond to arriving requests. In summary, devices’ nodes in the IoT ecosystem are
enabled to interact over through CoAP only.

CoAP and HTTP follow the same working procedure. However, CoAP attains its
functionality via asynchronous transactions (using UDP). It utilizes the POST, GET,
PUT, and DELETE calls. That’s the reason why API security is of higher grade while
CoAP is active as it is an RPK and PSK-certified protocol.

CoAP is compatible with 4 types of information exchange:

1. Acknowledgments confirm the completion or failure of an event.


2. Confirmable are the messages that are resent on time out until the confirmation of
successful sending doesn’t arrive.
3. Reset messages are empty, with confirmable as their nature.
4. Non-confirmable information is just sent and has no guarantee of successful
delivery. There is no acknowledgment of success either.

Key traits of CoAP are:

• Works for devices in the same network types.


• Enables data transmission, to and fro, for the general internet-enabled nodes and
network-connected devices.
• Works really fine for SMSs shared over mobile network connectivity.
• Suitable for internet-operative applications that use connected devices/sensors and
have resource limitations.
• Capable of translating HTTP, supports multicast, and exerts the bare minimum cost
burden.
• Only helps machines to communicate (in the network).

CoAP Architecture

The WWW and the constraints ecosystem are the 2 foundational elements of the CoAP
protocol architecture. Here, the server monitors and helps in communication happening
using CoAP and HTTP while proxy devices bridge the existing gap for these 2
ecosystem, making the communication smoother.

CoAP allows HTTP clients (also called CoAP clients here) to talk or exchange
data/information with each other within resource constraints. While one tries to
understand this architecture, gaining acquaintances with some key terms is crucial:

• Endpoints are the nodes that host have knowledge of;


lOMoARcPSD|316 591 08

• Client sends requests and replies to incoming requests;


• Server gets and forwards requests. It also gets and forwards the messages received in
response to the requests it had processed.
• Sender creates and sends the original message.
• Recipient gets the information sent by the client or forwarded by the server.

CoAP Function

The key role of CoAP is to act like HTTP wherever restricted devices are a part of
communication. While filling the gap of HTTP, it enables devices like actuators and
sensors to interact over the internet.

The devices, involved in the process, are administered and controlled by considering data
as a system’s component. CoAP protocol can operate its functions in an environment
having reduced bandwidth and extreme congestion as it consumes reduced power and
network bandwidth.

Networks featuring intense congestion and constrained connectivity are not ideal
conditions for TCP-based protocols to carry out their responsibilities. CoAP comes as a
rescuer at this place and supports the wen transfers.

Web transfers happening using satellites and covering long distances can be
accomplished with full perfection using CoAP. Networks featuring billions of nodes take
the help of the CoAP protocol for information exchange.
lOMoARcPSD|316 591 08

Regardless of the function handled or role played, CoAP promised security of highest
grade as DTLS parameters as default security parameter; the counterpart of 128 bit RSA
keys.

Speaking of its deployment, it’s simple and hassle-free. It can be implemented from
scratch for a straightforward application.

For the application ecosystem where CoAP is not desirable, generic implementations are
offered for various platforms. Most of the CoAP implementations are done privately
while few are published in open-source libraries like MIT license.

CoAP Features

The defining features that place CoAP protocol separate from other protocols are as
stated next. As it shares great similarities with HTTP, developers face bare minimum
difficulties while using it.

CoAP is an integration-friendly protocol and can be paired easily with applications using
cross-protocol proxies. Seamlessly, it integrates with JSON, XML, CBOR, and various
other data formats. In the process, the web client doesn’t get hints about a sensor
resource being accessed.

Developers are endowed with various payloads and have the freedom to make a choice to
bring the ideal payload into action.

The successful IoT device/application demands the usage of billions of nodes at a time.
CoAP is designed to handle such huge mode amounts with full perfection while keeping
the overheads under control. It can operate on tons of microcontrollers while using the
least possible resources. RAM space as low as 10KiB and code space as 100 KiB is
enough for CoAP.

As resources demanded by CoAP are on the minimum side, it keeps the wastes under
control. There is no need to deploy a hefty transport stack for web transfers. The header
and encoding, used for message processing, are compact and don’t cause any fragments
on the link layer. At a time, it supports the functions of multiple servers.

CoAP offers a comprehensive resource directory to spot the properties of the node.

CoAP is verified by RFC 7252, is developed for the future, and is able to deal with
congestion control issues.
lOMoARcPSD|316 591 08

CoAP Layer

The protocol works through its two layers:

1. CoAP Messages Model

It makes UDP transactions possible at endpoints in the confirmable (CON) or non-


confirmable (NON) format. Every CoAP message features a distinct ID to keep the
possibilities of message duplications at bay.

The 3 key parts involved to build this layer are binary header, computer option, and
payload.

As explained before, confirmable texts are reliable and easy-to-construct message that
are fast and are resent until the receipt of a confirmation of successful delivery (ACK)
with message ID.

2. CoAp Request/Response Model

This layer takes care of CON and NON message requests. Acceptance of these requests
depend on server’s availability. Cases are:

1. If idle, the server will handle the request right away. If a CON, the client will get an
ACK for it. If the ACK is shared as a Token and differs from the ID, it is essential to
map it properly by matching request-response pairs.
2. If there is a delay or wait involved, the ACK is sent but as an empty text. When its
turn arrvies, the request is processed andthe client gets a fresh CON.

The key traits of the Request/Response model are mentioned next:

• Request or response codes for CoAP are same as for the HTTP, except for the fact that
they are in the binary format (0-8 byte Tokens) in CoAP’s case.
• Request methods for making calls (GET, PUT, POST, and DELETE) are declared in
the process.
• A CON response could either be stored in an ACK message or forward as
CON/NON.
lOMoARcPSD|316 591 08

CoAP vs MQTT

As there are great similarities, we won’t blame you if you consider these two identical.
For instance, they both are used for IoT devices as they both necessitate less amounts of
network packets causing more power-optimized performance, less storage consumption,
and longer battery power.

CoAP vs MQTT

MQTT CoAP

This model has publishers and subscribers as


Uses requests and responses
main participants

Message dispatching happens on a unicasting


Central broker handles message dispatching,
basis (one-to-one). The process is same as
following the optimal publisher to client path.
HTTP.

Event-oriented operations Viable for state transfer

Establishing a continual and long-lasting TCP


Involved parties use UDP packets (async) for
connection with the broker is essential for the
message passing and communication.
client.

No message labeling but have to use diverse It defines messages properly and makes its
messages for different purposes. discovery easy.
lOMoARcPSD|316 591 08

➢ UDP
The TCP/IP protocol despite being most common protocol stack on internet is not much
suitable for IoT applications due to large overhead. It is more suitable for applications where
reliable delivery of data with high bandwidth in hand is required. The IoT applications
generally have limited bandwidth and need swift transfer of small data packets. In such case,
the UDP/IP stack is far better than TCP/IP.

The User Datagram Protocol (UDP) is the simplest transportation layer protocol used
primarily for establishing low-latency and loss tolerating connections between applications
on the communication network. Both TCP and UDP run on the top of Internet Protocol (IP)
that is why they are referred as TCP/IP and UDP/IP.

UDP is a connectionless protocol which means the sender just transmits the data without
waiting for the connection with the receiver. It is an unreliable protocol when compared with
TCP. There is no error checking mechanism or correcting mechanism involved in data
transmission which results in using less bandwidth. UDP protocol just sends the packets (or
datagram). There is no acknowledgement guarantee of packet received by the other end. It
allows for less data overhead and delays.

To achieve higher performance, the protocol allows individual packets to be dropped (with no
retries) and UDP packets to be received in a different order than they were sent, as dictated by
the application.

Features of UDP –

The UDP protocol stack has the following features –

UDP can be used when acknowledgement of data does not hold any significance.

2) It is great for data flowing in one direction.

3) It is connectionless protocol.

4) It does not provide any congestion control mechanism.

5) It is a suitable protocol for streaming applications such as video conference applications,


computer games etc.

UDP Datagrams –

UDP traffic works through packets called datagram, with every datagram consisting of a
single message unit. The header details are stored in the first eight bytes, but the rest is what
holds onto the actual message. The UDP datagram header can be divided into four parts each
of which is two bytes long. These parts are as follow –

1) Source Port – This 16 bits (2 bytes) information is used to identify the sender port which
will send the data. A valid UDP port number ranges from 0 to 65535.
lOMoARcPSD|316 591 08

2) Destination Port – This 16 bits information is used to identify the receiver’s port on
which the data will be received. A valid UDP port number ranges from 0 to 65535. This field
identifies the receiver’s port and is required.

3) Length – The length field specifies the entire length of the UDP packet (UDP header and
UDP data). This individual field is 16-bits field. The minimum length of the Length field is 8
bytes in case of no UDP data.

4) Checksum – This field stores the checksum value generated by the sender before sending
the data to the receiver. UDP checksums protect message data from being corrupted. The
checksum value represents an encoding of the datagram data calculated first by the sender
and later by the receiver. In UDP, checksum is optional, as opposed to TCP where checksum
is mandatory.

Advantages of UDP –

The UDP/IP has the following advantages over TCP/IP stack –

1) It is better than TCP for applications that require constant data flow, bulk data and which
require more swiftness than reliability.

2) For multicast and broadcast purposes, UDP is best suited because it supports point to
multipoint transmission method. The sender does not need to keep track of retransmission of
data for multiple receivers in contrast with the TCP/IP where sender needs to take care of
each packet.

3) There is small packet header overhead in UDP (only 8 bytes) whereas TCP has 20 bytes of
header.

You might also like