Header Ads

MQTT, how it is different from HTTP and SOMEIP, Where and Why it is used

 

What is MQTT?

Definition:

MQTT is a lightweight, publish-subscribe messaging protocol designed for devices with:

  • Low bandwidth
  • Limited CPU and memory
  • Unreliable or intermittent network connections

Unlike HTTP, devices do not communicate directly with each other. Instead, they communicate through a broker.


MQTT Architecture

           Publisher
                |
                |
         Publish Message
                |
         +--------------+
         | MQTT Broker  |
         +--------------+
          /     |      \
         /      |       \
Subscriber  Subscriber  Subscriber

Example:

Temperature Sensor
        |
 Publish: 32°C
        |
 MQTT Broker
      /      \
 Mobile App  Cloud Dashboard

The publisher doesn't know who receives the message.


Main Components

1. Broker

The central server that:

  • Receives messages
  • Filters them by topic
  • Sends them to subscribers

Examples:

  • Eclipse Mosquitto
  • EMQX
  • HiveMQ
  • AWS IoT Core
  • Azure IoT Hub

2. Publisher

A device that sends data.

Example:

  • Temperature sensor
  • Vehicle ECU
  • Battery Management System (BMS)

3. Subscriber

Receives messages from topics.

Example:

  • Mobile app
  • Cloud analytics
  • Dashboard
  • Service center

4. Topic

Messages are organized using hierarchical topics.

Examples:

car/speed

car/engine/rpm

car/battery/soc

factory/line1/motor/temp

Subscribers receive only the topics they subscribe to.


Example

Vehicle publishes:

Topic

vehicle/engine/temp

Message

95°C

Subscribers:

Cloud Dashboard

↓

Receives

95°C
Mobile App

↓

Receives

95°C
Analytics Engine

↓

Receives

95°C

The ECU publishes once; the broker distributes to all subscribers.


How MQTT Works

Step 1

Client connects to Broker.

CONNECT

Broker replies

CONNACK

Step 2

Client subscribes

SUBSCRIBE

vehicle/speed

Broker replies

SUBACK

Step 3

Publisher sends

PUBLISH

vehicle/speed

80 km/h

Broker forwards to all subscribers.


MQTT Packet Types

PacketPurpose
CONNECTConnect client
CONNACKConnection acknowledgement
PUBLISHSend data
SUBSCRIBESubscribe to topic
SUBACKSubscription acknowledgement
UNSUBSCRIBERemove subscription
PINGREQKeep-alive request
PINGRESPKeep-alive response
DISCONNECTClose connection

Quality of Service (QoS)

One of MQTT's biggest strengths.

QoS 0 — At Most Once

Send once

No acknowledgement

Fastest, but messages may be lost.

Example:

  • Live temperature updates

QoS 1 — At Least Once

Send

↓

ACK?

↓

If No

Resend

Guaranteed delivery, but duplicates are possible.

Example:

  • Sensor readings
  • Diagnostics

QoS 2 — Exactly Once

Four-step handshake

Guarantees no duplicates.

Used when duplicate messages are unacceptable, such as financial transactions.


MQTT vs HTTP

FeatureMQTTHTTP
CommunicationPublish-SubscribeRequest-Response
Header SizeVery smallLarger
BandwidthLowHigher
Power ConsumptionLowHigher
ConnectionPersistent TCPTypically new request/response cycles
LatencyVery lowHigher
Real-Time UpdatesExcellentRequires polling or additional technologies
IoT FriendlyYesLess suitable

MQTT vs SOME/IP (Automotive)

FeatureMQTTSOME/IP
DomainIoT, CloudIn-vehicle Ethernet
CommunicationPublish-SubscribeClient-Server + Publish-Subscribe
TransportTCP (optionally WebSockets)TCP and UDP
Internet FriendlyYesNo (primarily in-vehicle)
Cloud IntegrationExcellentLimited
Automotive ECU CommunicationUsually indirectPrimary use

Example:

Inside vehicle:

ADAS ECU

↓

SOME/IP

↓

Body ECU

Vehicle to Cloud:

Telematics ECU

↓

MQTT

↓

Cloud

MQTT vs CAN

CANMQTT
Vehicle busApplication protocol
8–64 byte payload (depending on CAN/CAN FD)Larger application messages
Real-timeNear real-time
Local networkInternet capable
ECU communicationCloud communication

Why MQTT?

MQTT was designed for:

  • Low bandwidth networks
  • High latency links
  • Intermittent connectivity
  • Low-power devices
  • Battery-operated systems

It minimizes overhead while maintaining reliable messaging.


Automotive Use Cases

Modern connected vehicles use MQTT for:

  • Remote diagnostics
  • OTA software updates (status/control)
  • Vehicle health monitoring
  • Battery monitoring
  • Fleet management
  • Vehicle tracking
  • Predictive maintenance
  • Telemetry

Example:

Vehicle

↓

MQTT

↓

Cloud

↓

AI predicts battery failure

Industrial IoT Use Cases

  • Smart factories
  • PLC communication
  • SCADA integration
  • Smart meters
  • Energy monitoring
  • Building automation
  • Agriculture sensors

Security

MQTT supports:

  • TLS/SSL encryption
  • Username/password authentication
  • Client certificates
  • Access control lists (ACLs)
  • Topic-level authorization

Advantages

  • Very lightweight protocol
  • Low bandwidth consumption
  • Low power usage
  • Supports one-to-many communication
  • Scales to millions of connected devices
  • Reliable delivery with configurable QoS
  • Ideal for cloud and IoT ecosystems

Limitations

  • Requires a broker
  • Not a hard real-time protocol
  • Depends on TCP, which adds some overhead
  • Topic hierarchy must be designed carefully in large systems

Real-World Automotive Example

Consider a connected electric vehicle:

  1. The Battery Management System (BMS) measures:
    • State of Charge (SOC)
    • Battery temperature
    • Voltage
  2. The Telematics Control Unit (TCU) publishes these values to MQTT topics such as:

    vehicle/123/battery/soc
    vehicle/123/battery/temp
  3. The MQTT broker distributes the data to:
    • Fleet dashboard
    • Mobile app
    • AI analytics platform
    • Service center
  4. An AI model analyzes trends and predicts battery degradation or maintenance needs.

Interview Answer (2–3 Minutes)

**MQTT (Message Queuing Telemetry Transport) is a lightweight publish-subscribe messaging protocol designed for constrained devices and unreliable networks. Unlike HTTP's request-response model, MQTT uses a broker that receives messages from publishers and distributes them to subscribers based on topics. It supports three Quality of Service levels, enabling applications to balance performance and reliability. MQTT is widely used in IoT, industrial automation, and connected vehicles because it has low bandwidth overhead, maintains persistent connections, and scales efficiently. In automotive systems, MQTT is commonly used between the telematics unit and cloud services for telemetry, remote diagnostics, fleet management, and predictive maintenance, while protocols like SOME/IP are used for communication between ECUs inside the vehicle.