nRF5 SDK v16.0.0
MQTT
This information applies to the following SoftDevices: S132, S140

Message Queue Telemetry Transport (MQTT) is a lightweight connectivity protocol for machine-to-machine communication. The protocol uses a subscribe-publish model for message exchange between the machines. All messaging takes place through a messaging broker, referred to from now on as the MQTT Broker. When referring to publishers and subscribers that use the broker for messaging, they are referred to as MQTT clients.

MQTT 3.1 is an OASIS standard and uses TCP as the transport protocol. IANA reserves port number 1883 and 8883 for MQTT and MQTT over SSL respectively.

For more details, visit mqtt.org.


MQTT_Overall.svg
Figure 1: Setup of MQTT examples.


MQTT brokers can be hosted by cloud services or can be run locally using broker implementations. Nordic devices, being resource constrained, will be the MQTT clients.

The MQTT examples in this SDK include a Publisher and a Subscriber. The topic that is published and subscribed to is a LED state. A button on the publisher is used to control the LED state which is also published to the broker. The subscriber changes its own LED state based on the published message from the publisher.

This set of examples cannot work with one another without a broker. Mosquitto is described in the examples to be the broker.

The examples use MQTT version 3.1.0. This is the version that Mosquitto supports.

Certain brokers support MQTT version 3.1.1. It is possible to enable support for 3.1.1 by defining the MQTT_3_1_1 at compile time.

Note
The MQTT examples included in this SDK do not support the Will and QoS features of MQTT.

The sequence diagram in Figure 2 illustrates how two MQTT clients connect to an MQTT broker, one as a publisher and one as a subscriber. The data source publishes data on a relevant topic to the broker as the figure depicts. The data sink can subscribe to this topic to get updates from the publisher through the broker.

msc_mqtt
Figure 2: MQTT Messaging Overview.

A detailed description of the MQTT client examples playing the Publisher and Subscriber Role is found here:

MQTT Client - Publisher

MQTT Client - Subscriber


Documentation feedback | Developer Zone | Subscribe | Updated