Iot Unit3
Iot Unit3
2. Publisher-Subscriber Model –
This model comprises three entities: Publishers, Brokers, and Consumers.
• Publishers are the source of data. It sends the data to the topic which are
managed by the broker. They are not aware of consumers.
• Consumers subscribe to the topics which are managed by the broker.
• Hence, Brokers responsibility is to accept data from publishers and send it to
the appropriate consumers. The broker only has the information regarding the
consumer to which a particular topic belongs to which the publisher is unaware
of.
3. Push-Pull Model –
The push-pull model constitutes data publishers, data consumers, and data queues.
• Publishers and Consumers are not aware of each other.
• Publishers publish the message/data and push it into the queue. The consumers,
present on the other side, pull the data out of the queue. Thus, the queue acts as
the buffer for the message when the difference occurs in the rate of push or pull
of data on the side of a publisher and consumer.
• Queues help in decoupling the messaging between the producer and consumer.
Queues also act as a buffer which helps in situations where there is a mismatch
between the rate at which the producers push the data and consumers pull the
data.
4. Exclusive Pair –
• Exclusive Pair is the bi-directional model, including full-duplex communication
among client and server. The connection is constant and remains open till the
client sends a request to close the connection.
• The Server has the record of all the connections which has been opened.
• This is a state-full connection model and the server is aware of all open
connections.
Analog Sensors
Analog sensors use a sensor and an associated electronic analog circuit. Analog
sensors generate analog outputs as per the physical environmental parameters, such as
temperature, strain, pressure, force, flex, vapours, magnetic field, or proximity.
Digital Sensors
Examples of Sensors
Temperature
A component called thermistor, shows larger changes in resistance within narrow
environment temperature range (120°C to –90°C). An NTC thermistor shows negative
temperature coefficient which means a drop in the resistance value with rise in
temperature.
A temperature sensor is called PTC, when it exhibits a Positive Temperature
Coefficient. Resistance value of a PTC resistor rises with rise in temperature.
Humidity
Humidity is measured in percentage. It is the relative percentage ratio (RH%) of
content of water vapours in air compared to one in a situation of maximum possible
water vapour content for the air temperature at the instance of measurement.
Distance
Infrared (IR) sensor is useful for a 0.15 m to 0.8 m range of object. IR sensor works on
the principle that when a narrow beam IR LED sends radiation at an inclined angle, the
nearby phototransistor FPT receives the reflected radiation after travelling two times
the object distance
Light
A photoconductor can be used to detect light in the vicinity. The sensor shows a drop in
resistance with surrounding light.
Acceleration
A Micro-Electro-Mechanical Sensor (MEMS) detects linear accelerations ax, ay and az
along three axes x, y and z, respectively. An MEMS moves when a mass moves along a
direction.
Vibrations and Shocks
Alternatively, MEMS may use piezoelectric effect in place of capacitive change
effects. The effect observed in certain specific materials is accumulation of electric
changes on surfaces due to mechanical compression of the piezoelectric material.
Angular Acceleration and Change in Direction (Angle)
Gyroscope is a sensor which measures the change in angular velocity (angular
acceleration) and the change in direction (angle). An application takes measurements
using a gyroscope or accelerometer and the system initiates actions as programmed. For
example, mobile gaming application uses in-motion gestures of a player when
deploying a gyroscope.
Orientation and Direction Compass
A gyroscope can be used as an electronic compass or a digital compass as it shows the
change in direction (angle).
Electric Current
Alternating Current (AC) is detected by a miniature transformer and its associated
circuitry. A Direct Current (DC) flows in one direction at all instances. It detects using a
sensor circuit, which detects the magnetic field by flowing current.
Sound
A microphone is used to sense sound. A readily available electronic board with a
microphone connects to the microcontroller, which can control an actuator for actions
based on the sensed sound, or recognise the voice and then take required action, such as
dialing a number using the actuator circuit or switching on the car.
Pressure Sensors
Pressure P is measured as force per m2 . Pressure can be sensed in a number of ways.
The sensor is called pressure transducer, pressure transmitter, pressure sender or
pressure indicator. Piezometer pressure transducer uses a piezoelectric object between
two surfaces. The compression creates electric charges on the opposite surfaces of the
object.
GPS
Location determination can be done using a Global Positioning System (GPS), also
known as Geographical Positioning System. A user can receive the location from a
service provider.
Camera
Camera is an image sensor. The camera uses CCD, which consists of a large number of
pixels, exposed to the light from the image. It accumulates charges on each of the pixel
present at a large number of horizontal and vertical coordinates.
ACTUATOR:
An actuator is a device that takes actions as per the input command, pulse or state (1 or 0), or
set of 1s and 0s, or a control signal. An attached motor, speaker, LED or an output device
converts electrical energy into physical action.
● Light sources
● LEDs
I/O INTERFACES:
Input/output (I/O) interfaces in the Internet of Things (IoT) are the physical and logical
connections that allow IoT devices to communicate with each other and with the outside
world. I/O interfaces can be wired or wireless, and they can be used to connect to a variety of
sensors, actuators, and other devices.
• Serial interfaces: Serial interfaces, such as RS-232 and RS-485, are commonly used to
connect IoT devices to sensors and actuators. Serial interfaces are relatively simple to
implement and they can be used to transmit data over long distances.
• Parallel interfaces: Parallel interfaces, such as the General-Purpose Input/Output
(GPIO) interface, are commonly used to connect IoT devices to multiple sensors and
actuators. Parallel interfaces can transmit data faster than serial interfaces, but they are
more complex to implement and they have a shorter range.
• Wireless interfaces: Wireless interfaces, such as Bluetooth, Wi-Fi, and ZigBee, are
commonly used to connect IoT devices to each other and to the internet. Wireless
interfaces are convenient and flexible, but they can be more susceptible to
interference than wired interfaces.
The choice of I/O interface for an IoT device depends on a number of factors, including the
type of sensors and actuators being used, the required data rate, the desired range, and the
cost and complexity of the implementation.
Here are some examples of how I/O interfaces are used in IoT:
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.
Protocols-MQTT
MQTT (Message Queuing Telemetry Transport) is an IBM-developed lightweight
messaging protocol that was initially introduced in 1999. It interprets
communications between devices, servers, and applications using the pub/sub
pattern.
The MQTT protocol was established with the goal of connecting sensors on oil
pipelines to communications satellites with the least amount of battery loss and
bandwidth use possible.
MQTT has been evolving since its creation, with version 5.0 being released in May
2018. Version 3.1.1 was accepted as an ISO standard after being submitted to the
OASIS consortium in 2013.
Advantages
The following are some of the advantages of MQTT:
● Lightweight code footprint - The MQTT protocol requires only a few lines of code
to get up and running on devices.
● Minimized data packets - MQTT is a low-energy protocol. If a device is batterypowered or
has a low CPU, this is ideal.
● Speed - Outside of QoS, MQTT functions in real time with no delays.
● Ease of Implementation - MQTT includes libraries in a number of programming
languages, including Elixir and Python.
● Last will and testament - If a client disconnects abruptly, you can send a message
to all subscribers with information on how to fix the problem.
● Retained messages - When a client subscribes to a topic, it will automatically get
one retained message for that subject (like a pinned post on social media).
MQTT architecture
In the MQTT protocol, connected devices are known as "clients," and they
communicate with a server known as the "broker." Data communication between
clients is handled by the broker.
When a customer (known as a "publisher") wants to disseminate information, it
publishes to a specific topic, which the broker then distributes to any clients who have
subscribed to that topic (known as "subscribers").
The publisher does not require information on the number of subscribers or their
locations. As a result, subscribers do not require any information about the publisher.
Any client can be both a publisher and a subscriber. The clients are usually unaware
of each other and are only aware of the broker who acts as an intermediary. The
“pub/sub model” is a popular term for this structure.
MQTT messages
A “publish” occurs when a customer wishes to submit data to the broker. A client will
"subscribe" to a subject or topics if they desire to get data from the broker. When a
client subscribes to a topic, it will get all future messages that are published on that
subject.
The publisher additionally sends a QoS (Quality of Service) level along with the
message. This level specifies the message's delivery guarantee. The following are the
levels of QoS:
● At most once - The broker will only get the message "at most once" after it is
published. This level should not be utilized for mission-critical information since it
increases the danger of the message not being received by the intended recipients.
● At least once - The publisher will continue to resend the message until it obtains a
response from the broker on the specific message. In other words, ensuring that the
message is received is more critical than ensuring that it is only received once. This is
most likely the most used QoS level.
● Exactly once - The publisher and the broker collaborate to ensure that the broker
receives and acts on messages only once. This necessitates some more effort in the
form of a four-part handshake. This is the safest QoS level, but it's also the slowest,
therefore, it's only used when absolutely required.
ZigBee
ZigBee is a Personal Area Network task group with low rate task group 4. It is a technology
of home networking. ZigBee is a technological standard created for controlling and sensing
the network. As we know that ZigBee is the Personal Area Network of task group 4 so it is
based on IEEE 802.15.4 and is created by Zigbee Alliance.
ZigBee is an open, global, packet-based protocol designed to provide an easy-to-use
architecture for secure, reliable, low power wireless networks. Flow or process control
equipment can be place anywhere and still communicate with the rest of the system. It can
also be moved, since the network doesn’t care about the physical location of a sensor, pump
or valve.
IEEE802.15.4 developed the PHY and MAC layer whereas, the ZigBee takes care of upper
higher layers.
ZigBee is a standard that addresses the need for very low-cost implementation of Low power
devices with Low data rates for short-range wireless communications.
IEEE 802.15.4 supports star and peer-to-peer topologies. The ZigBee specification supports
star and two kinds of peer-to-peer topologies, mesh and cluster tree. ZigBee-compliant
devices are sometimes specified as supporting point-to-point and point-to-multipoint
topologies.
Types of ZigBee Devices:
Zigbee Coordinator Device: It communicates with routers. This device is used for connecting
the devices.
Zigbee Router: It is used for passing the data between devices.
Zigbee End Device: It is the device that is going to be controlled.
Physical layer: The lowest two layers i.e the physical and the MAC (Medium Access
Control) Layer are defined by the IEEE 802.15.4 specifications. The Physical layer is closest
to the hardware and directly controls and communicates with the Zigbee radio.
Medium Access Control layer (MAC layer): The layer is responsible for the interface
between the physical and network layer. The MAC layer is also responsible for providing
PAN ID and also network discovery through beacon requests.
Network layer: This layer acts as an interface between the MAC layer and the application
layer. It is responsible for mesh networking.
Application layer: The application layer in the Zigbee stack is the highest protocol layer and
it consists of the application support sub-layer and Zigbee device object. It contains
manufacturer-defined applications.
Zigbee Applications:
Home Automation
Medical Data Collection
Industrial Control Systems
meter reading system
light control system
Commercial
Government Markets Worldwide
Home Networking
CoAP(constrained application protocol):
CoAP stands for Constrained Application Protocol and it is defined in RFC 7252. CoAP is a
simple protocol with low overhead specifically designed for constrained devices (such as
microcontrollers) and constrained networks. This protocol is used in M2M data exchange and
it is very similar to HTTP
The main features of CoAP protocols are:
Web protocol used in M2M with constrained requirements
Asynchronous message exchange
Low overhead and very simple to parse
URI and content-type support
Proxy and caching capabilities
some features are very similar to HTTP even if CoAP must not be considered a compressed
HTTP protocol because CoAP is specifically designed for IoT and in more details for M2M
so it is very optimized for this task.
From the abstraction protocol layer, CoAP can be represented as:
there are two different layers that make CoAp protocol: Messages and Request/Response.
The Messages layer deals with UDP and with asynchronous messages. The Request/Response
layer manages request/response interaction based on request/response messages.
CoAP supports four different message types:
• Confirmable
• Non-confirmable
• Acknowledgment
• Reset
CoAP Messages Model
This is the lowest layer of CoAP. This layer deals with UDP exchanging messages between
endpoints. Each CoAP message has a unique id, this is useful to detect message duplicates. A
CoAP message is built by these parts:
a binary header
a compact option
payload
The CoAP protocol uses two kinds of messages:
• Confirmable message
• Non-confirmable message
A confirmable message is a reliable message. When exchanging messages between two
endpoints, these messages can be reliable. In CoAP a reliable message is obtained using a
Confirmable message (CON). Using this kind of message, the client can be sure that the
message will arrive at the server. A Confirmable message is sent again and again until the
other party sends an acknowledge message (ACK). The ACK message contains the same ID
of the confirmable message (CON).
If the server has troubles managing the incoming request it can send back a Rest message
(RST) instead of the Acknowledge message (ACK):
The other message category is the Non-confirmable (NON) messages. These are messages
that don’t require an Acknowledge by the server. They are unreliable messages or in other
words messages that do not contain critical information that must be delivered to the server.
To this category belongs messages that contain values read from sensors.
If the server can answer immediately to the client request then if the request is carried using a
Confirmable message (CON) then the server sends back to the client an Acknowledge
message containing the response or the error code:
TCP/IP PROTOCOL:
TCP/IP was designed and developed by the Department of Defense (DoD) in the 1960s and is
based on standard protocols. It stands for Transmission Control Protocol/Internet Protocol.
The TCP/IP model is a concise version of the OSI model. It contains four layers, unlike the
seven layers in the OSI model.
The main work of TCP/IP is to transfer the data of a computer from one device to another.
The main condition of this process is to make data reliable and accurate so that the receiver
will receive the same information which is sent by the sender. To ensure that, each message
reaches its final destination accurately, the TCP/IP model divides its data into packets and
combines them at the other end, which helps in maintaining the accuracy of the data while
transferring from one end to another end.
Layers of TCP/IP Model
• Application Layer
• Transport Layer (TCP/UDP)
• Network/Internet Layer (IP)
• Data Link Layer (MAC)
• Physical Layer
1. Physical Layer
It is a group of applications requiring network communications. This layer is
responsible for generating the data and requesting connections. It acts on behalf of the
sender and the Network Access layer on the behalf of the receiver.
2. Data Link Layer
The packet’s network protocol type, in this case, TCP/IP, is identified by the data-link
layer. Error prevention and “framing” are also provided by the data-link layer. Point-
to-Point Protocol (PPP) framing and Ethernet IEEE 802.2 framing are two examples
of data-link layer protocols.
3. Internet Layer
This layer parallels the functions of OSI’s Network layer. It defines the protocols
which are responsible for the logical transmission of data over the entire network. The
main protocols residing at this layer are as follows:
IP: IP stands for Internet Protocol and it is responsible for delivering packets from the
source host to the destination host by looking at the IP addresses in the packet
headers. IP has 2 versions: IPv4 and IPv6. IPv4 is the one that most websites are using
currently. But IPv6 is growing as the number of IPv4 addresses is limited in number
when compared to the number of users.
ICMP: ICMP stands for Internet Control Message Protocol. It is encapsulated within
IP datagrams and is responsible for providing hosts with information about network
problems.
ARP: ARP stands for Address Resolution Protocol. Its job is to find the hardware
address of a host from a known IP address. ARP has several types: Reverse ARP,
Proxy ARP, Gratuitous ARP, and Inverse ARP.
Example: Imagine that you are using a computer to send an email to a friend. When
you click “send,” the email is broken down into smaller packets of data, which are
then sent to the Internet Layer for routing. The Internet Layer assigns an IP address to
each packet and uses routing tables to determine the best route for the packet to take
to reach its destination. The packet is then forwarded to the next hop on its route until
it reaches its destination. When all of the packets have been delivered, your friend’s
computer can reassemble them into the original email message.
In this example, the Internet Layer plays a crucial role in delivering the email from
your computer to your friend’s computer. It uses IP addresses and routing tables to
determine the best route for the packets to take, and it ensures that the packets are
delivered to the correct destination. Without the Internet Layer, it would not be
possible to send data across the Internet.
4. Transport Layer
The TCP/IP transport layer protocols exchange data receipt acknowledgments and
retransmit missing packets to ensure that packets arrive in order and without error.
End-to-end communication is referred to as such. Transmission Control Protocol
(TCP) and User Datagram Protocol are transport layer protocols at this level (UDP).
TCP: Applications can interact with one another using TCP as though they were
physically connected by a circuit. TCP transmits data in a way that resembles
character-by-character transmission rather than separate packets. A starting point that
establishes the connection, the whole transmission in byte order, and an ending point
that closes the connection make up this transmission.
5.Application Layer
This layer is analogous to the transport layer of the OSI model. It is responsible for
end-to-end communication and error-free delivery of data. It shields the upper-layer
applications from the complexities of data. The three main protocols present in this
layer are:
HTTP and HTTPS: HTTP stands for Hypertext transfer protocol. It is used by the
World Wide Web to manage communications between web browsers and servers.
SSH: SSH stands for Secure Shell. It is a terminal emulations software similar to
Telnet. The reason SSH is preferred is because of its ability to maintain the encrypted
connection.
NTP: NTP stands for Network Time Protocol. It is used to synchronize the clocks on
our computer to one standard time source. you carry out a transaction, where your
computer reads the time at 2:30 PM while the server records it at 2:28 PM. The server
can crash very badly if it’s out of sync.
BLUETOOTH SMART CONNECTIVITY
Bluetooth overview
i. Bluetooth is a short-range wireless technology standard that is used for exchanging data
between fixed and mobile devices over short distances using Ultra high frequency radio
waves in the ISM (industrial, scientific and medical) bands, from 2.402 to 2.48 GHz, and
building personal area networks (PANs). ii. It is mainly used as an alternative to wire
connections, to exchange files between nearby portable devices and connect cell phones
and music players with wireless headphones. In the most widely used mode, transmission
power is limited to 2.5 milliwatts, giving it a very short range of up to 10 metres (33 ft).
a. Bluetooth links
i. To provide effective mechanisms for the data transfer over a Bluetooth link, there are
number of protocols and different types of link. There are two main types of Bluetooth link
that are available and can be set up:
SCO Synchronous Connection Orientated communications link
ACL Asynchronous Connectionless communications Link
The Bluetooth link that is used is determined by the type of Bluetooth data transfer
required.
i. SCO: The SCO or Synchronous Connection Orientated communications link is
used where data is to be streamed rather than transferred in a framed format. The
SCO can operate alongside the ACL channels
ii. ACL: The ACL or Asynchronous Connectionless Communications Link is possible
the most widely used form of Bluetooth link. The ACL Bluetooth link is used for
carrying framed data - i.e. data submitted from an application to logical link control
and adaptation protocol channel. The channel may support either unidirectional or
bidirectional Bluetooth data transfer.
Bluetooth 1.1
i. Ratified as IEEE Standard 802.15.1 ii. Many errors
found in the v1.0B specifications were fixed. iii. Added
possibility of non-encrypted channels. iv. Received
Signal Strength Indicator (RSSI).
Bluetooth 1.2
Major enhancements include:
• Faster Connection and Discovery
• Adaptive frequency-hopping spread spectrum (AFH), which improves resistance to
radio frequency interference by avoiding the use of crowded frequencies in the
hopping sequence.
• Higher transmission speeds in practice, up to 721 kbit/s.
• Extended Synchronous Connections (eSCO), which improve voice quality of audio
links.
• Host Controller Interface (HCI) operation with three-wire UART.
• Ratified as IEEE Standard 802.15.1
Bluetooth 5.2
Enhanced Attribute Protocol (EATT), an improved version of the Attribute Protocol (ATT)
Table 1: Comparition of Bluetooth Low Energy (LE) to Bluetooth Classic
Bluetooth Low Energy (LE) Bluetooth Classic
Frequency Band 2.4GHz ISM Band 2.4GHz ISM Band
Channels 40 channels with 2 MHz spacing 79 channels with 1 MHz spacing
1. Physical Layer
The physical (PHY) layer is the part that actually contains the analog communications
circuitry, capable of modulating and demodulating analog signals and transforming them into
digital symbols. The radio uses the 2.4 GHz ISM (Industrial, Scientific, and Medical) band to
communicate and divides this band into 40 channels from 2.4000 GHz to 2.4835 GHz. As
shown in Figure 2, 37 of these channels are used for connection data and the last three
channels (37, 38, and 39) are used as advertising channels to set up connections and send
broadcast data.
The standard uses a technique called frequency hopping spread spectrum, in which the radio
hops between channels on each connection event using the following formula:
channel = (curr_channel + hop) mod 37
The value of the hop is communicated when the connection is established and is therefore
different for every new established connection. The modulation chosen to encode the
bitstream over the air is Gaussian Frequency Shift Keying (GFSK), the same modulation used
by classic Bluetooth. The modulation rate for Bluetooth Low Energy is fixed at 1 Mbit/s,
which is therefore the upper physical throughput limit for the technology.
2. Link Layer
The Link Layer is directly interfaces with the PHY, and it is usually implemented as a
combination of custom hardware and software.
The Link Layer defines the following roles:
Advertiser: A device sending advertising packets.
Scanner: A device scanning for advertising packets.
Master: A device that initiates a connection and manages it later.
Slave: A device that accepts a connection request and follows the master’s timing. These
roles can be logically grouped into two pairs: advertiser and scanner
A BLE device can be a master, a slave, or both, depending on the use case and requirements.
Devices that initiate connections will be masters and devices that advertise their availability
and accept connections will be slaves. A master can connect to multiple slaves and a slave
can be connected to multiple masters. Typically, devices such as smartphones or tablets tend
to act as a master, while smaller, simpler, and memory-constrained devices such as standalone
sensors usually adopt the slave role.
Features
PSoC 4100/4200 families have these major
components: i. 32-bit Cortex-M0 CPU with 48 MHz
ii. Up to 32-KB flash and 4-KB SRAM
iv. Four independent pulse-width modulators (PWMs) and synchronized analog-to-
digital converter (ADC) operation
iv. Up to 1 Msps 12-bit ADC
v. Up to two opamps with comparator mode and successive approximation register (SAR)
input buffering capability vi. Two low-power comparators
vii. Two serial communication blocks (SCB) to work as SPI/ UART/I2C serial
communication channels
1. CPU System
i. Processor: The heart of the PSoC 4 is a 32-bit Cortex-M0 CPU core running up to
48MHz. It is optimized for low-power operation. It uses 16-bit instructions and executes a
subset of the Thumb-2 instruction set. ii. Interrupt Controller: The CPU subsystem of
PSoC includes a nested vectored interrupt controller (NVIC) with 32 interrupt inputs and a
wakeup interrupt controller (WIC), which can wake the processor from deep-sleep mode.
The Cortex-M0 implements non-maskable interrupt (NMI) input.
2. Memory
The PSoC 4 memory subsystem consists of flash and SRAM. A supervisory ROM,
containing boot and configuration routines.
• Flash: The PSoC 4 has a flash module with a flash read accelerator tightly
coupled to the CPU to improve average access times from the flash block.
• SRAM: The PSoC 4 provide SRAM, which is engaged during hibernate mode
3. System-Wide Resources
i. Clocking System: The clock system for the PSoC 4100/4200 consists of the internal main
oscillator (IMO) and internal low-speed oscillator (ILO) as internal clocks and has provision
for an external clock. The default IMO frequency is 24 MHz and it can be adjusted between 3
MHz and 48 MHz in steps of 1 MHz. The ILO is a low-power, less accurate oscillator and is
used to generate clocks for peripheral operation in deep-sleep mode. Its clock frequency is 32
kHz with ±60 percent accuracy. ii. Power System: The PSoC 4100/4200 operates with a
single external supply over the range of 1.71 V to 5.5 V. PSoC 4100/4200 has several low-
power modes – sleep, deep-sleep, hibernate, and stop modes – besides the default active
mode. iii. GPIO: Every GPIO in PSoC are capable to disables of input and output. A high-
speed I/O matrix is used to multiplex between various signals that may connect to an I/O pin.
4. Programmable Digital
The PSoC 4200 has up to four universal digital block (UDB). Each UDB contains structured
data-path logic and uncommitted programmable logic devices (PLD) logic with flexible
interconnect. The UDB array provides a switched routing fabric called the Digital System
Interconnect (DSI). The DSI allows routing of signals from peripherals and ports to and
within the UDBs.
5. Analog System
i. SAR ADC: PSoC 4 has a configurable SAR ADC. The ADC provides the choice of
three internal voltage references (VDD, VDD/2, and VREF) and an external reference
through a GPIO pin.
ii. Continuous Time Block mini (CTBm): The CTBm block provides continuous time
functionality at the entry and exit points of the analog subsystem. The CTBm has two
highperformance opamps.