Skip to content

Latest commit

 

History

History
96 lines (60 loc) · 2.31 KB

02-mqtt.md

File metadata and controls

96 lines (60 loc) · 2.31 KB
MQTT

MQTT: Basics

Message Queue Telemetry Transport

"Publish-subscribe-based "lightweight" messaging protocol, for use on top of the TCP/IP protocol."

  • Publish-subscribe
  • A message broker is required
  • Standard: ISO/IEC PRF 20922
  • Small code footprint
  • Limited network bandwidth / constrained environments
  • Developed in 1999 (and released royalty free in 2010)
  • Data agnostic

MQTT: Publish-subscribe model



MQTT: Publish-subscribe model

MQTT: Connecting to the broker


MQTT: Connecting

MQTT: Publishing to a topic



MQTT: Publishing

MQTT: Subscribing to a topic

>_ Example topics

  • Topic #1: home/groundfloor/kitchen/temperature
  • Topic #2: office/conferenceroom/luminance

>_ Wild cards

  • Single-level: home/groundfloor/+/temperature
    (to subscribe to all the temperature readings in all the rooms of the ground floor)
  • Multi-level: home/groundfloor/#
    (to subscribe to all the readings in all the rooms of the ground floor, not only the temperature)

MQTT: Quality of Service

>_ QoS can be 0, 1, or 2


  • 0: The broker/client will deliver the message once, with no confirmation.
  • 1: The broker/client will deliver the message at least once, with confirmation required.
  • 2: The broker/client will deliver the message exactly once by using a four step handshake.

MQTT: Last will and testament



MQTT: Last will

MQTT: Learn more

There are client libraries and wrappers for practically all languages used in M2M setups, as well as different brokers/servers.