IoT Class U1 U3 Premid
IoT Class U1 U3 Premid
Things
Reference books:
[1]. Raj Kamal, “Internet of Things: Architecture and Design Principles”,
McGraw Hill
Textbook References:
[1] Internet of Things: Principles and paradigms, Edited by Rajkumar Buyya and
Amir Dastjerdi , Morgan Kaufmann
[2] Precision - Internet of Things Author: Timothy Chou ISBN: 9789352605385
[3] Designing the Internet of Things, Adrian McEwen and Hakim Cassimally,
Wiley.
Who introduced the term IoT?
The term "Internet of things" was likely coined by Kevin Ashton of Procter
& Gamble, later MIT's Auto-ID Center, in 1999.
• Alternate Definition:
“The Internet of Things (IoT) is the network of physical objects that contain embedded
technology to communicate and sense or interact with their internal states or the external
environment.” – Gartner Research*
* https://www.gartner.com/en/information-technology/glossary/internet-of-things
Brief History of IoT
Early 1980s at the Carnegie Melon University, a group of students created a way
to get their campus Coca-Cola vending machine to report on its contents
through a network in order to save them the track if the machine was out of
Coke.
In 1990, John Romkey, developer of the first TCP/IP stack for IBM PC in 1983,
connected a toaster to the internet for the first time.
In 1991, a group of students at the University of Cambridge used a web camera
to report on coffee available in their computer labs coffee pot.
At the beginning of the 21st Century, LG Electronics introduced the
world’s first refrigerator connected to the internet
7
Cont…
The popularity of the term IoT did not accelerate until 2010/2011 and reached mass
market in 2013-14.
Note: I2C, SPI, and RS232 are digital communication protocols used to send
data between devices in embedded systems.
They are commonly used for short-distance device communication.
Fundamental of SPI
•SPI supports Half / Full Duplex serial communication.
•It is a synchronous communication protocol.
•It is a four-wire communication protocol.
•In most cases, one master multiple slave protocol, but it also supports
multiple master configurations.
•It is on board short-range communication protocol for embedded
systems.
•It supports maximum speed up to 10Mbps
•Master provides a clock for synchronization.
•SPI supports 8 & 16 bits data frame format.
SPI Communication
42
SPI clocking: there is no “standard way”
Four clocking “modes”
◦ Two phases (CPHA)
◦ Two polarities (CPOL)
44
SPI Pros and Cons
Pros:
◦ Fast and easy
◦ Fast for point-to-point connections
◦ Easily allows streaming/Constant data inflow
◦ No addressing/Simple to implement
◦ Everyone supports it
Cons:
◦ SS makes multiple slaves very complicated
◦ No acknowledgement ability
◦ No inherent arbitration
◦ No flow control
45
I2C Communication
Two lines
◦ Serial data line (SDA)
◦ Serial clock line (SCL)
SCL SCL
• I2C is a serial communication protocol that allows multiple devices to talk to each
other using only two wires - a clock (SCL) and a data line (SDA).
• Master: The master operates as the primary controller, initiating and managing data
transfers with a central role in controlling the communication flow.
• Slave: In contrast, the slave devices act as subordinate participants, responding to the
master's commands and actively engaging in the communication process.
• SDA (Serial Data): Transfer of data takes place through this pin.
• SCL (Serial Clock): It carries the clock signal.
KeyConcepts
Data Line Behavior: In I2C, data changes when the clock is low, remains stable
when high. Both lines are open drain, needing pull-up resistors for high levels, as
I2C devices often use active-low logic.
Packet Transmission: Data is transmitted in 9-bit packets.
Start Condition (1 bit) Slave Address (8 bits)
Acknowledgment bit (1 bit)
Read/Write Bit: Included in the address frame, a low voltage level signals the master is
sending data, while a high level means it's requesting data.
Data Frame: After receiving an ACK bit, the master sends an 8-bit data frame, followed
by an ACK/NACK bit. The next frame waits for acknowledgment.
Stop Condition: The master concludes the transmission with a stop condition – a
voltage transition from low to high on SDA after a low to high transition on SCL,
keeping SCL high.
Acknowledge (ACK) and No-Acknowledge (NACK): After each frame, an ACK bit signals
successful reception, while a NACK bit indicates an unsuccessful one.
Single Master Controlling Multiple Slaves
MASTER SLAVE 1
SDA SDA
SCL SCL
SLAVE 2
SDA
RESISTORS
PULL-UP
SCL
SLAVE 3
VCC SDA
VCC
SCL
In I2C's Single Master, Multiple Slaves setup, one master communicates with several
slaves on a shared bus, addressing each for data exchange. This enables efficient
management and communication across multiple devices.
Multiple Masters with Multiple Slaves
MASTER 1 SLAVE 1
SDA SDA
SCL SCL
MASTER 2 SLAVE 2
SDA SDA
SCL
SCL
MASTER 3 SLAVE 3
SDA SDA
SCL SCL
RESISTORS
PULL-UP
VCC
VCC
Clock Stretching: Slave can hold the clock low, preventing the master from raising it until
ready.
Limitations
• Slower speed compared to other protocols.
Note: I2C, SPI, and RS232 are digital communication protocols used to send
data between devices in embedded systems.
They are commonly used for short-distance device communication.
Fundamental of SPI
•SPI supports Half / Full Duplex serial communication.
•It is a synchronous communication protocol.
•It is a four-wire communication protocol.
•In most cases, one master multiple slave protocol, but it also supports
multiple master configurations.
•It is on board short-range communication protocol for embedded
systems.
•It supports maximum speed up to 10Mbps
•Master provides a clock for synchronization.
•SPI supports 8 & 16 bits data frame format.
SPI Communication
14
SPI clocking: there is no “standard way”
Four clocking “modes”
◦ Two phases (CPHA)
◦ Two polarities (CPOL)
16
SPI Pros and Cons
Pros:
◦ Fast and easy
◦ Fast for point-to-point connections
◦ Easily allows streaming/Constant data inflow
◦ No addressing/Simple to implement
◦ Everyone supports it
Cons:
◦ SS makes multiple slaves very complicated
◦ No acknowledgement ability
◦ No inherent arbitration
◦ No flow control
17
I2C Communication
Two lines
◦ Serial data line (SDA)
◦ Serial clock line (SCL)
SCL SCL
• I2C is a serial communication protocol that allows multiple devices to talk to each
other using only two wires - a clock (SCL) and a data line (SDA).
• Master: The master operates as the primary controller, initiating and managing data
transfers with a central role in controlling the communication flow.
• Slave: In contrast, the slave devices act as subordinate participants, responding to the
master's commands and actively engaging in the communication process.
• SDA (Serial Data): Transfer of data takes place through this pin.
• SCL (Serial Clock): It carries the clock signal.
KeyConcepts
Data Line Behavior: In I2C, data changes when the clock is low, remains stable
when high. Both lines are open drain, needing pull-up resistors for high levels, as
I2C devices often use active-low logic.
Packet Transmission: Data is transmitted in 9-bit packets.
Start Condition (1 bit) Slave Address (8 bits)
Acknowledgment bit (1 bit)
Read/Write Bit: Included in the address frame, a low voltage level signals the master is
sending data, while a high level means it's requesting data.
Data Frame: After receiving an ACK bit, the master sends an 8-bit data frame, followed
by an ACK/NACK bit. The next frame waits for acknowledgment.
Stop Condition: The master concludes the transmission with a stop condition – a
voltage transition from low to high on SDA after a low to high transition on SCL,
keeping SCL high.
Acknowledge (ACK) and No-Acknowledge (NACK): After each frame, an ACK bit signals
successful reception, while a NACK bit indicates an unsuccessful one.
Single Master Controlling Multiple Slaves
MASTER SLAVE 1
SDA SDA
SCL SCL
SLAVE 2
SDA
RESISTORS
PULL-UP
SCL
SLAVE 3
VCC SDA
VCC
SCL
In I2C's Single Master, Multiple Slaves setup, one master communicates with several
slaves on a shared bus, addressing each for data exchange. This enables efficient
management and communication across multiple devices.
Multiple Masters with Multiple Slaves
MASTER 1 SLAVE 1
SDA SDA
SCL SCL
MASTER 2 SLAVE 2
SDA SDA
SCL
SCL
MASTER 3 SLAVE 3
SDA SDA
SCL SCL
RESISTORS
PULL-UP
VCC
VCC
Clock Stretching: Slave can hold the clock low, preventing the master from raising it until
ready.
Limitations
• Slower speed compared to other protocols.
Data Frame 1 Bit (Start) 7 or 8 bits (Data) Parity Bit 1 or 2 bit Stop bit
Bus arbitration
Processor and controllers both need to initiate data
transfers on the bus and access main memory.
The device that is allowed to initiate transfers on the
bus at any given time is called the bus master.
When the current bus master relinquishes its status as
the bus master, another device can acquire this status.
The process by which the next device to become the bus master is selected and
bus mastership is transferred to it is called bus arbitration.
Centralized arbitration:
A single bus arbiter performs the arbitration.
Distributed arbitration:
All devices participate in the selection of the next bus master.
Centralized Bus Arbitration
B BS Y
BR
Processor
Slave Slave
BG1 1 BG2 2
Daisy-Chain Approach
Centralized Bus Arbitration(cont.,)
• Bus arbiter may be the processor or a separate unit
connected to the bus.
• Normally, the processor is the bus master, unless it grants
bus membership to one of the controllers.
• Controller requests the control of the bus by asserting the
Bus Request (BR) line.
• In response, the processor activates the Bus-Grant1 (BG1)
line, indicating that the controller may use the bus when it
is free.
• BG1 signal is connected to all controllers in a daisy chain
fashion.
• BBSY signal is 0, it indicates that the bus is busy. When BBSY
becomes 1, the controller which asserted BR can acquire
control of the bus.
Centralized arbitration (contd..)
Controller 2
asserts the BR signal. Time
Processor asserts
BR
the BG1 signal
BBSY
Bus
master
Processor Controller 2 Processor
Arbitration process:
•Each device compares the pattern that appears on the arbitration lines to its own
ID, starting with MSB.
•If it detects a difference, it transmits 0s on the arbitration lines for that and all lower
bit positions.
•Device A compares its ID 5 with a pattern 0101 to pattern 0111.
•It detects a difference at bit position 0, as a result, it transmits a pattern 0100 on the
arbitration lines.
•The pattern that appears on the arbitration lines is the logical-OR of 0100 and 0110,
which is 0110.
•This pattern is the same as the device ID of B, and hence B has won the arbitration.
IEEE Standards
Shared Access Networks are Different
• Shared Access Networks assume multiple nodes on the
same physical link
• Bus, ring, and wireless structures
• Transmission sent by one node is received by all others
• No intermediate switches
• Need methods for moderating access (MAC protocols)
• Fairness
• Performance
• How can this be done?
41
Project 802 (IEEE 802 standards)
Ethernet
• Ethernet was first developed in the 1970s and was later standardized as IEEE
802.3.
• Ethernet is the group of LAN products covered by IEEE 802.3 that define a
wired Ethernet media access control's physical layer and data link layer.
• These standards also describe the rules for configuring an Ethernet network
and how the network elements work with one another.
• Ethernet allows computers to connect over one network—without it,
communication between devices in today’s modern world would not be
possible.
• Ethernet is the global standard for a system of wires and cables to conjoin
multiple computers, devices, machines, etc., over an organization’s single
network so that all the computers can communicate with one another.
• Ethernet began as a single cable, making it possible for multiple devices to
be connected on one network.
Ethernet evolution through four generations
802.3 MAC frame
Preamble + SFD:
• Added by the physical layer.
• Not a part of the frame.
• It is a series of bits as per 10101010 ...... 101011
Source & Destination Address:
• MAC Address of the source & destination node.
• Size of MAC is 6B = 48bits = 12 digit Hex number
Length/Type:
• It gives the length of the frame-Exclude: Preamble & SOF
Minimum and maximum lengths
Frame length:
Minimum: 64 bytes (512 bits)
Maximum: 1518 bytes (12,144 bits)
Example of an Ethernet address in hexadecimal notation
Unicast and multicast addresses
The least significant bit of the first byte defines the type of address.
If the bit is 0, the address is unicast; otherwise, it is multicast.
The broadcast destination address is a special case of the multicast address
in which all bits are 1s.
Categories of Standard Ethernet
Encoding in a Standard Ethernet implementation
10Base5 implementation
10Base2 implementation
10Base-T implementation
10Base-F implementation
Summary of Standard Ethernet implementations
CSMA/CD
Ethernet vs. Industrial Ethernet
Discrete Inputs (1X) Digital Input (On/Off) 1-bit Read-Only 10001 – 19999
Input Registers (3X) Analog Input (Sensor Data) 16-bit Read-Only 30001 – 39999
Limitations of Modbus
❌ Limited Security – No encryption, making it vulnerable to cyber threats.
❌ Slow Communication – Serial Modbus RTU has lower speeds compared to
modern protocols.
❌ Limited Data Size – Can only handle small data packets.
BACnet
BACnet Protocol
•A data communication protocol used to build an automated control network: Building
Automation and Control Network.
•Protocol is an ISO & ANSI standard for interoperability between cooperating building
automation devices.
•Bacnet Protocol includes a set of rules for governing the data exchange on a computer network
that covers all the types of cables to utilize and form a particular command or request.
•BACnet specification includes three major parts. Primary, Secondary, and tertiary.
•Primary part defines a technique to represent any kind of building automation apparatus
normally.
•Secondary part describes messages that can be transmitted across a network of computers to
check and manage such equipment.
• Tertiary part describes a set of suitable LANs that are used for conveying BACnet
communications.
Why BACnet?
•Open Standard for Building Automation –An open, vendor-neutral protocol that allows
seamless integration of different devices and systems.
•Interoperability Across Devices – Supports HVAC, lighting, fire detection, security
systems, and more, enabling devices from different manufacturers to communicate.
•Flexible Communication Options – Works over multiple transport layers, including
Ethernet (BACnet/IP), RS-485 (MS/TP), and Zigbee (wireless BACnet) for versatile
connectivity.
•Supports Distributed Control Systems – Enables decentralized control, reducing
dependency on a single central controller for improved reliability and efficiency.
•Scalability & Future-Proofing – Designed to support small to large-scale automation
systems, making it ideal for modern smart buildings and IoT integration.
•Efficient Data Sharing & Monitoring – Uses standardized object-oriented data to simplify
data exchange and remote monitoring.
•Energy Management & Cost Savings – Helps optimize energy consumption, automate
controls, and improve efficiency, leading to lower operational costs.
BACnet Architecture
BACnet Objects
• BACnet objects are the fundamental components of the BACnet protocol.
• Objects represent specific pieces of information or control mechanisms
within a BACnet system.
• Each object in BACnet has a defined structure that includes properties such
as present value, status flags, and reliability status.
BACnet Objects
Point-like objects: Scheduling/Logging Control
BACnet Object Properties
Feature Modbus vs. BACnet
Full Name Modbus: Modular Communication Bus
BACnet: Building Automation and Control Network
Developed By Modbus: Modicon, 1979
BACnet: ASHRAE, 1987
Primary Use Modbus: Industrial automation
BACnet: Building automation
Protocol Type Modbus: Master-Slave
BACnet: Peer-to-Peer
Communication Mediums Modbus: RS-232, RS-485, Ethernet
BACnet: Ethernet, RS-485, Zigbee, ARCNET
Data Structure Modbus: Register-based
BACnet: Object-oriented
Interoperability Modbus: Limited
BACnet: High
Scalability Modbus: Up to 247 devices
BACnet: Thousands of devices
Feature Modbus vs. BACnet
Speed Modbus: Up to 115.2 kbps (RTU), 10 Mbps+ (TCP)
BACnet: 10 Mbps - 1 Gbps
Complexity Modbus: Simple
BACnet: Complex but flexible
Error Handling Modbus: CRC, TCP/IP error detection
BACnet: Built-in error detection
Security Modbus: Minimal
BACnet: Enhanced with authentication, encryption
Real-Time Performance Modbus: Lower latency, slower RTU response
BACnet: Real-time, event-driven
Application Examples Modbus: SCADA, industrial control
BACnet: Smart buildings, HVAC
Advantages
• BACnet protocol is particularly designed for building automation as well as
control networks.
• Doesn’t depend on present LAN or WAN technologies.
• It is an American National Standard & a European pre-standard.
• It is scalable completely from small single building applications to universal
networks of devices.
• Implementers of BACnet can securely include non-standard extensions as well
as enhancements without influencing existing interoperability.
• In real building control applications, this protocol has a proven track record.
Disadvantages
•Interoperability Issues
•Security concerns
•Scalability challenges
•Complexity
•Dependence on Network Infrastructure
IoT COMMUNICATION
PROTOCOLS
Functional block
Communication Models of IoT
A communication model defines how device interact and share
data. It outlines the rules and methods used for device to send or
receive information.
• Client-Server
• Publisher-Subscriber
• Push-Pull
Request
SERVER Database
CLIENT
Response
PUBLISH SUBSCRIBE MODEL
PUBLISHER
Message BROKER
published
CONSUMER 1
to topic 1
SEND TOPIC 1
MESSAGES CONSUMER 2
TO TOPICS TOPIC 2
Message
published CONSUMER 3
to topic 2
Push Pull Model
EXCLUSIVE PAIR COMMUNICATION
MODEL
• loT communication protocols form the backbone of IoT systems and enable
network connectivity and coupling to applications.
• Communication protocols allow devices to exchange data over the network.
• These protocols define the data exchange formats, data encoding
addressing schemes for devices, and routing of packets from source to
destination.
Layers of IoT Protocols
Application layer
HTTP: Hypertext
Transfer Protocol
HTTP CoAP WebSockets
CoAP: Constrained
Application Protocol MQTT XMPP DDS AMQP
MQTT: Message
Queuing Telemetry
Transport
XMPP: Extensible Transport layer
Messaging and
Presence Protocol TCP UDP
DDS: Data Distribution
Service
AMQP: Advanced
Message Queuing
Protocol
Network layer
TCP: Transmission IPv4 IPv6 6LoWPAN
Control Protocol
UDP: User
Datagram Protocol
Link layer
802.3 802.16
2G/3G/LTE-
Cellular
802.11 802.15.4
HTTP
• URL
• Uniform Resource Locator
• Refers to an existing protocol
• http:, wais:, ftp:, mailto:, gopher:, news:
• Points to a document on a specific server
• URN
• Uniform Resource Name
• Globally unique, persistent identifier
• Independent of location
HTTP Server Message
HTTP Request Message HTTP Response Message
HTTP/I.1 200 OK
Connection: close
Date: Tue,18 August GMT
Server: Apache/%.2.3 (CentOS)
Last Modified: Tug18Aug
202315.•11.03GMT
Content-Length: 6821
Content-Type: text/html
(data data data data data)
200 0K
301 Moved Permanently
400 Bad Request
404 Not Found
505 HTTP Version Not Supported
HTTP Methods
• GET
• Web browser request an object from a web server.
• POST
• Submit data to the server for operation
• HEAD
• Used for debugging(Developers)
• PUT
• Upload an object to specific directory
• DELETE
• Remove object from the server
URL
• It is useful for connections with remote locations where a small code footprint is
required and/or network bandwidth is at a premium.
• Brokers:
• Is a server that receives and sends messages to subscribers,
• an Intermediate between Publisher and subscriber
• Topic:
• Is the virtual channel in which the Publisher and Subscriber send and receive message
• Message
• Client
• Publisher
• Subscriber
Publisher-Is a Client which publishes message to Mqtt Broker with a particular topic
Subscriber-Is the Client which receives message from the broker on subscription of a particular topic
MQTT-IOT-Example
Webserver
MQTT MQTT MQTT
Client Broker
MQTT Protocol Details -
Headers
MQTT protocol control packets:
• Fixed header (2 bytes)
• Variable header (optional, length varies)
• Message payload (optional, length encoded, up to 256MB)
SUBSCRIBE
Is connected, and
is awaiting Has a subscriber
messages SUBACK connected on a topic
• For M2M/IoT
CoAP Server 1
(Thermostat in Bedroom)
CoAP Client
CoAP Server 2
(Thermostat in Living room)
Name of
Port (5683 is the parameter
Name of the the default port Name of device controls
protocol CoAP uses) the device (temperature here)
coap://myhome.in:5683/nest_bedroom/temp
CoAP Layers
Reset (RST)
▶ Reset (RST) – RST message is sent when recipient fails to send
response in time.
CoAP Message Types
CON / Confirmable message
A confirmable message requires a response, either a positive acknowledgement or
a negative acknowledgement. In case acknowledgement is not received, retransmissions
are made until all attempts are exhausted.
NON / Non-confirmable message
A non-confirmable request is used for unreliable transmission (like a request for a
sensor measurement made in periodic basis. Even if one value is missed, there is not too
much impact). Such a message is not generally acknowledged.
ACK / Acknowledgement
Sent to acknowledge a confirmable (CON) message.
RST / Reset
This represents a negative acknowledgement and means “Reset”. It generally
indicates, some kind of failure (like unable to parse received data)
COAP Header
• Method calls can be made using confirmable & non-confirmable message services
• When a confirmable message is received, receiver always returns an acknowledgement.
The sender resends messages if an acknowledgement is not returned within a given time.
• No of response code has also been reduced (to make implementation simpler)
• CoAP also broke away from the Internet Media Type scheme used in HTTP and
other protocols and replaced this with a reduced set of Content.
Web Service Protocol
Advantages
Disadvantages
• When client traverses link, accesses new resource (i.e., transfers state)
• Not a protocol.
• Not a standard.
• The reason behind the popularity of REST is that the applications we use
are browser-based nowadays and top it all, REST is built on HTTP.
• Main idea: Providing the communication between client and server over
HTTP protocol rather than other complex architectures like SOAP and RPC
etc.
RESTful Web Services
• No severe restrictions on how the architectural model will be and what properties
it will have.
• Inspite of the low bandwidth, large data have been transfered with methods even
inflating the size of the data, like XML with SOAP. Why?
• Nowadays, the bandwidth is amazingly large, but we still use JSON and it shrinks
the size of our data.
RESTful Web Services
• Platform independent.
• Language independent.
▪ Client-Server
▪ Stateless
▪ Cacheable
▪ Uniform Interface/Contract
▪ Layered System
▪ Code on Demand
Client-Server
• Seperation of concerns.
• Client and server are independent from eachother.
• Client doesn’t know anything about the resource which is
kept in the server.
• Server responds as long as the right requests come in.
• Goal: Platform independency and to improve scalability.
Stateless
• Each request is independent from other requests.
• No client session data or any context stored on the server.
• Every request from client stores the required information, so
that the server can respond.
• If there are needs for session-specific data, it should be held
and maintained by the client and transferred to the server with
each request as needed.
• A service layer which doesn’t have to maintain client sessions
is much easier to scale.
• Of course there may be cumbersome situations:
• The client must load the required information to every request. And
this increases the network traffic.
• Server might be loaded with heavy work of «validation» of requests.
Cacheable
• There can be many intermediaries between you and the server you are
connecting to.
• HTTP/1.1 200 OK
• Content-Type: text/plain
• Light 123 turned ON
RESTFull HTTP
• HTTP/1.1 200 OK
• Content-Type: application/json
{
"device_id": 123, "state": "on", "message": "Light turned ON“
}
WebSocket
• Stateful protocol
• Efficient for IoT: Ideal for real-time IoT systems, such as smart home automation
and industrial monitoring.
Websocket Architecture
Example
Client sends:
Server
responds:
Limitations of WebSocket