Lecture 6 – IoT Application Protocols

IoT application protocols like HTTP, MQTT, and CoAP, including message formats, QoS levels, and a hands-on MQTT publish-subscribe lab using Node-RED.

Introduction

The Internet of Things (IoT) depends on communication protocols that enable devices to send, receive, and process data efficiently. These protocols define how messages are structured, delivered, and acknowledged between connected devices.

In this lecture, you’ll explore the three most important IoT application protocols HTTP, MQTT, and CoAP and learn how they differ in terms of speed, reliability, and resource efficiency.

What Are IoT Application Protocols?

Application protocols operate at the top layer of the IoT stack. They define how devices communicate over networks like Wi-Fi, Ethernet, or cellular.

They are responsible for:

  • Structuring data into readable messages.
  • Managing requests and responses.
  • Ensuring delivery through Quality of Service (QoS).

Without these protocols, IoT devices couldn’t exchange information in a standardized, reliable way.

Common IoT Application Protocols

A. HTTP (Hypertext Transfer Protocol)

HTTP is the traditional web communication protocol used by browsers and web servers.

  • Model: Request–Response
  • Transport: TCP
  • Advantages: Simple and widely supported.
  • Disadvantages: High overhead and power usage, not ideal for low-power IoT devices.
  • Use Case: IoT dashboards, web APIs, RESTful services.

Example: A smart thermostat sends temperature data to a cloud server via an HTTP POST request.

MQTT (Message Queuing Telemetry Transport)

MQTT is the most widely used protocol for IoT. It’s lightweight, efficient, and perfect for low-power and unstable network conditions.

  • Model: Publish–Subscribe
  • Transport: TCP
  • Advantages: Low bandwidth, reliable, supports Quality of Service (QoS).
  • Disadvantages: Requires an MQTT broker (e.g., Mosquitto).
  • Use Case: Real-time sensor data, home automation, industrial IoT.

QoS Levels in MQTT

QoS LevelDescriptionUse Case
QoS 0At most once (no confirmation)Fast data like temperature updates
QoS 1At least once (acknowledged)Sensor data logging
QoS 2Exactly once (no duplicates)Financial or safety-critical data

Example: A weather station publishes temperature data to the MQTT broker, and multiple devices (subscribers) receive it instantly.

Lecture 5 – IoT Networking Fundamentals

CoAP (Constrained Application Protocol)

CoAP is a specialized IoT protocol built for low-power and resource-constrained devices.

  • Model: Request–Response (like HTTP)
  • Transport: UDP
  • Advantages: Lightweight, fast, suitable for sensors and actuators.
  • Disadvantages: No guaranteed delivery; less reliable than MQTT.
  • Use Case: Smart lighting systems, small IoT networks.

Example: A smart bulb receives ON/OFF commands via CoAP messages from a central controller.

Comparison of IoT Application Protocols

ProtocolTransportCommunication ModelPower EfficiencyReliabilityIdeal Use Case
HTTPTCPRequest–ResponseLowHighWeb APIs, REST dashboards
MQTTTCPPublish–SubscribeVery HighVery HighReal-time IoT communication
CoAPUDPRequest–ResponseHighMediumSensor networks, low-power IoT
Infographic comparing IoT Application Protocols — HTTP, MQTT, and CoAP — showing communication models, QoS levels, and data formats.

Message Formats in IoT

IoT messages often use standardized data formats to ensure devices can interpret data correctly:

  • JSON (JavaScript Object Notation) – Lightweight and human-readable.
  • XML (Extensible Markup Language) – Structured but more verbose.
  • CBOR (Concise Binary Object Representation) – Binary format used in constrained networks.

Example JSON Message:

{
  "device_id": "esp32_01",
  "temperature": 25.7,
  "humidity": 58
}

Lab Exercise MQTT Publish-Subscribe Using Node-RED

Objective

To understand how publish–subscribe communication works in IoT using the MQTT protocol and Node-RED.

Hardware & Software

  • Node-RED installed on your PC
  • Mosquitto MQTT broker
  • ESP32 or MQTT test client (e.g., MQTTX, HiveMQ)
Step 1 – Setup MQTT Broker
  1. Install Mosquitto MQTT broker or use a public broker (e.g., test.mosquitto.org).
  2. Note the Broker Address, Port (1883), and Topic name (e.g., iot/temp).
Step 2 – Configure Node-RED
  1. Open Node-RED dashboard → Add two nodes: MQTT In and MQTT Out.
  2. Connect them through a Debug node or Dashboard Gauge.
  3. Configure the broker address, topic, and QoS level.

When you publish data to the topic, the subscribed node instantly receives it, demonstrating real-time IoT communication.

Step 3 – Example ESP32 Publisher Code

#include <WiFi.h>
#include <PubSubClient.h>

const char* ssid = "YourWiFi";
const char* password = "YourPassword";
const char* mqtt_server = "test.mosquitto.org";

WiFiClient espClient;
PubSubClient client(espClient);

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) delay(500);

  client.setServer(mqtt_server, 1883);
}

void loop() {
  if (!client.connected()) client.connect("ESP32Client");
  float temp = random(20, 30);
  String payload = "{\"temperature\": " + String(temp) + "}";
  client.publish("iot/temp", payload.c_str());
  delay(3000);
}

Expected Output: Node-RED dashboard displays real-time temperature updates from the ESP32.

The approach followed at E Lectures reflects both academic depth and easy-to-understand explanations.

Summary

After completing this lecture, you will be able to:

  • Explain the purpose of HTTP, MQTT, and CoAP in IoT.
  • Understand message formats and QoS levels.
  • Set up and test an MQTT publish–subscribe model.
  • Use Node-RED for real-time IoT communication.

People also ask:

What are IoT application protocols?

IoT application protocols define how devices exchange data across networks. They determine message structure, reliability, and communication style between IoT devices, servers, and cloud applications.

Why do IoT devices need specific communication protocols?

Because IoT devices often have limited power, memory, and processing capability, they need lightweight and efficient protocols like MQTT or CoAP instead of heavy web protocols like HTTP.

What is the difference between HTTP, MQTT, and CoAP?
  • HTTP: Uses request–response; high power consumption, suitable for web apps.
  • MQTT: Uses publish–subscribe; low power, great for real-time IoT communication.
  • CoAP: Lightweight version of HTTP using UDP; perfect for constrained devices.
What does QoS mean in MQTT?

QoS (Quality of Service) defines how reliably messages are delivered between devices and the broker:

  • QoS 0: At most once (no acknowledgment).
  • QoS 1: At least once (acknowledged, possible duplicates).
  • QoS 2: Exactly once (guaranteed, no duplicates).
What is a publish–subscribe model?

In this model, devices called publishers send messages to a broker under a specific topic. Devices that subscribe to that topic receive those messages automatically.
It allows one-to-many communication without direct connections between devices.

Leave a Reply

Your email address will not be published. Required fields are marked *