The MQTT driver requires the Driver MQTT Client, Driver MQTT Broker or Full licence. Without it the gateway does not start and its log shows
missing license.
MQTT is designed as an extremely lightweight publish/subscribe messaging transport that is ideal for connecting remote devices to the cloud with a small code footprint and minimal network bandwidth. MQTT today is used in a wide variety of industries, such as automotive, manufacturing, telecommunications, oil and gas, building automation, etc...
MQTT has typically a central endpoint, the MQTT broker (server), that gets information from MQTT clients (TCP clients) such as sensors and retransmits the data to other MQTT clients, such as a smartphone applications or building management systems. Each MQTT client can publish data into its corresponding MQTT topics, and/or subscribe to MQTT topics of interest. Note that the MQTT broker acts mainly as a communication hub redistributing the data between the clients.

In most cases, the universal IoT gateway acts as a MQTT client and connects to the IoT Cloud of a third-party company. For a step-by-step setup in either role, see Publishing gateway points over MQTT (broker or client). The following article Airthings To Bacnet shows a use case where the MQTT driver is connected as client to the Airthings cloud (Airthings MQTT broker).
Some IoT clouds add their own authentication and topic rules on top of MQTT (Microsoft Azure IoT Hub, AWS IoT Core); others use their own web API (Google Nest). The gateway has dedicated drivers for them: Microsoft Azure IoT Hub, Amazon AWS IoT, ClearBlade IoT Core and Google Nest (see Drivers): use them first. The generic MQTT client covers other brokers that only need a client certificate (section 2.2) or that refuse subscriptions on their telemetry topics (address option Publish only, section 3.1), for example to publish telemetry to Azure IoT Hub.
This section shows how to establish connection with the mosquitto public MQTT broker. Two MQTT clients are configured, the first MQTT will be connected with simple MQTT (no encryption) and publish data to the broker, while the second client will be connected through WSS (WebSocket Secure) and subscribe to receive the published data.
The screenshot below shows the parameters for the connection. The first MQTT client gateway is named "MQTT demo" and it uses the standard MQTT protocol version 4 on the MQTT port 1883 without encryption.
A MQTT topic address can easily be added by selecting the Addresses menu and clicking on "Insert address". Here the MQTT topic is named "IoT_gateway". As we will later add subtopics to publish different kind of data (air temperature, air quality, and air humidity), the datatype "parentJson" is selected.

After creating the parent topic, a child address named %mqtt:IoT_gateway/temperature is added. This new topic will be used to publish temperature data, so its datatype must be "number".

In the same manner, two additional addresses are added %mqtt:IoT_gateway/airQualityIndex and %mqtt:IoT_gateway/humidity. Once the 3 addresses are added, you can manually publish new values (here 53, 60, and 23.4) on the topics. Note that because the parent topic %mqtt:IoT_gateway is configured with the datatype "parentJson", it gets automatically updated with a JSON object containing the children values.

In the following screenshot, a second MQTT client gateway over WebSocket Secure (WSS) is created. This new MQTT client will subscribe to our IoT_gateway MQTT topics. To do so, the address with name %mqtt:IoT_gateway/+ is created. The + symbol is a wild card single level subscription. It means that the MQTT client subscribes to all topics following this pattern IoT_gateway/[XYZ], where XYZ does not contain additional levels (/ character). The addresses (here %mqtt:IoT_gateway/airQualityIndex, %mqtt:IoT_gateway/humidity, and %mqtt:IoT_gateway/temperature) are automatically added when the broker transmits the new messages to the client. Note that some MQTT brokers do not automatically send the last known message on topic subscription, in this case it is needed to wait for a new message to be published. When you publish manually new messages from the first MQTT client named "MQTT demo", you can notice that the new values are received on the second MQTT client. If you want to subscribe to multi-level topics, the # wildcard symbol can be used. Check this article about best practices for more explanations about MQTT wildcards subscriptions.

The MQTT driver can be configured either as a MQTT broker (server) or as a client. The mode parameter lets you select if you want to be "broker" or "client" (see table below).
| Label | JSON Key | Description |
|---|---|---|
| Mode | mode | The parameter is a string and its value is either "broker" or "client". A MQTT broker acts as a server and a communication hub between MQTT clients. On the other hand MQTT clients connect to their MQTT broker and subscribe / publish to MQTT topics. |
| Label | JSON Key | Description |
|---|---|---|
| useAuthenticate | serverOptions.useAuthenticate | When ticked, clients must give a user name and a password to connect. Unticked: every client is accepted. |
| Authenticate | serverOptions.authenticate | List of the users allowed to connect: click Add user, then fill in Username and Password. In JSON it is an object keyed by user name, each value being {"username": "...", "password": "..."}, stored as a JSON string: "authenticate": "{\"alice\":{\"username\":\"alice\",\"password\":\"S3cret!\"}}". Only the password is checked: every authenticated user may publish and subscribe to all topics (there are no per-topic rights). |
| Interfaces | serverOptions.interfaces | A list of interfaces for the MQTT broker server to listen to. There are 3 types of supported protocols for server sockets TCP (mqtt), TLS (mqtts), WS (mqtt over websocket). Each interface type has its own set of sub parameters. |
| Label | JSON Key | Description |
|---|---|---|
| Port | serverOptions.interfaces[n].port | TCP port on which the broker listens. Default: 1883. |
| Label | JSON Key | Description |
|---|---|---|
| Port | serverOptions.interfaces[n].port | TLS port on which the broker listens. Default: 8883 (set automatically when Type is switched to TLS). |
| Auto manage certs. | serverOptions.interfaces[n].auto | Boolean, specifies if security keys and certificates are managed automatically or manually. |
| Key | serverOptions.interfaces[n].key | Private key in PEM format, only used if security keys are managed manually. |
| Cert | serverOptions.interfaces[n].cert | Cert in PEM format, only used if security keys are managed manually. |
| Label | JSON Key | Description |
|---|---|---|
| Port | serverOptions.interfaces[n].port | Specifies the TCP port number on which the web server listens for new websockets. Defaults to 8888 |
The broker listens on all network interfaces. There is no Host field in the form; a
hostkey (for example"host": "192.168.1.99") can only be added to an interface in the gateway JSON (import or API).
json). Messages published on topics starting with $ are ignored.mqtt sub-protocol on that port are handed over to the broker. This is the way to offer MQTT over wss://, through the HTTPS port of the gateway.| Label | JSON Key | Description |
|---|---|---|
| Host | clientOptions.host | Domain name or ip address of the MQTT broker. |
| Port | clientOptions.port | Port of the MQTT broker (usually 1883 for MQTT, and 8883 for MQTTS) |
| Protocol | clientOptions.protocol | MQTT transport layer: "mqtt" (TCP unencrypted), "mqtts" (TLS encrypted), "ws" (websocket over HTTP), "wss" (websocket over HTTPS). |
| Protocol version | clientOptions.protocolVersion | MQTT protocol level: 3 (MQTT 3.1) or 4 (MQTT 3.1.1, default). MQTT 5 is not offered. |
| Client id | clientOptions.clientId | It is often not necessary to specify a client id. However some applications / brokers require you to configure a specific client id. |
| Username | clientOptions.username | The username is not always needed but can be necessary for authentication. The text [hostname] is replaced by the host name of the gateway, so that the same configuration can be deployed on several gateways. |
| Password | clientOptions.password | Defining a password can be necessary for authentication. The text [hostname] is replaced by the host name of the gateway. |
| URL Path | json.clientOptions.path | URL path for the websocket (only applies to ws and wss protocols) |
| rejectUnauthorized | clientOptions.rejectUnauthorized | mqtts and wss only. When ticked, the broker certificate must be signed by a trusted authority (the public CAs, or the ones given in ca); otherwise the connection is refused. Unticked by default. Tick it for every connection that leaves the local network, so that the gateway verifies the identity of the broker. |
| cert | clientOptions.cert | Optional TLS cert in PEM format. |
| servername | clientOptions.servername | Optional TLS server name for the SNI (Server Name Indication). When empty, the broker host name is used (not when Host is an IP address). |
| passphrase | clientOptions.passphrase | TLS optional shared passphrase used for a single private key and/or a PFX. |
| ca | clientOptions.ca | Optional TLS trusted CA certificates. Optionally override the trusted CA certificates. Default is to trust the well-known CAs curated by Mozilla. For self-signed certificates, the certificate is its own CA, and must be provided. |
| pfx | clientOptions.pfx | Optional TLS PFX or PKCS12 encoded private key and certificate |
| key | clientOptions.key | Optional TLS private keys in PEM format |
| ECDHCurve | clientOptions.ecdhCurve | Optional TLS ECDH curve. Shown for wss only. The form offers auto (default) and secp521r1, needed by brokers whose certificate uses the P-521 curve. |
| SCEP | clientOptions.scep | mqtts and wss only. When ticked, the client certificate and its private key are requested from a SCEP server and renewed automatically before they expire. The ca, key and cert fields are then hidden. |
| SCEP URL | clientOptions.scepURL | URL of the SCEP server. |
| SCEP CN | clientOptions.scepCN | Common name requested for the client certificate. |
| SCEP challenge | clientOptions.scepChallenge | Challenge password of the SCEP server. |
Certificates in PEM format, how to build them with openssl and how SCEP works: see TLS certificates and SCEP.
Examples taken from the 2 MQTT clients in the getting started tutorial.
{
"name": "MQTT demo",
"driver": "mqtt",
"description": "",
"active": 1,
"json": {
"mode": "client",
"serverOptions": {
"useAuthenticate": false,
"authenticate": "{}",
"interfaces": [
{
"type": "tcp",
"port": 1883
}
]
},
"clientOptions": {
"host": "test.mosquitto.org",
"port": 1883,
"path": "",
"protocol": "mqtt",
"protocolVersion": "4",
"clientId": "",
"username": "",
"password": "",
"rejectUnauthorized": false,
"servername": "",
"passphrase": "",
"ca": "[]",
"pfx": "[]",
"key": "[]",
"cert": "[]",
"ecdhCurve": "auto"
}
}
}
{
"name": "MQTT over WSS",
"driver": "mqtt",
"description": "",
"active": 1,
"json": {
"mode": "client",
"serverOptions": {
"useAuthenticate": false,
"authenticate": "{}",
"interfaces": [
{
"type": "tcp",
"port": 1883
}
]
},
"clientOptions": {
"host": "test.mosquitto.org",
"port": 8081,
"path": "",
"protocol": "wss",
"protocolVersion": "4",
"clientId": "",
"username": "",
"password": "",
"rejectUnauthorized": false,
"servername": "",
"passphrase": "",
"ca": "[]",
"pfx": "[]",
"key": "[]",
"cert": "[]",
"ecdhCurve": "auto"
}
}
}
MQTT addresses start with the prefix %mqtt:, and the rest of the address name is the MQTT topic. MQTT topics can have multiple levels like a tree structure. Each level is separated by the slash / character. Example of valid address names: %mqtt:IoT_gateway/airQualityIndex, %mqtt:IoT_gateway/humidity, %mqtt:IoT_gateway/temperature, %mqtt:MQTT_TOPIC/X/Y/Z. A leading slash is accepted (%mqtt:/A), but an empty level in the middle (%mqtt:X//A) or a trailing slash (%mqtt:X/A/) is refused with Bad MQTT address. The wildcards + (exactly one level) and # (all remaining levels, last position only) are accepted for subscriptions.
| Label | JSON Key | Description |
|---|---|---|
| Datatype | datatype | How the payload (UTF-8 text) is interpreted: number, string, json, parentJson or parentJsonAutoInsert (see below). |
| QOS | qos | Client mode. Quality of Service used for the subscription and for the publications of this topic: At most once (0), At least once (1), Exactly once (2). In broker mode each subscriber gets the QoS it asked for. |
| Retain | retain | Client mode only. Publish with the MQTT retain flag, so that the broker keeps the last message for future subscribers. |
| Store value | remanent | Broker mode only. Keep the last value across restarts: never, always or a duration. |
| Not a topic (local, no MQTT publish) | notatopic | Values written to this address stay inside the gateway: nothing is published. Useful for a JSON parent or for children that must not appear on the broker. Children created automatically inherit the option. |
| Publish only (no subscribe) | publishOnly | Client mode. The gateway publishes on this topic but never subscribes to it; the published value becomes the value of the address. Needed with brokers that refuse subscriptions on telemetry topics. |
Datatypes. The payload is converted as follows:
| Datatype | Received payload | Published value |
|---|---|---|
number |
Converted to a number (the raw text is kept if it is not a number). | The number as text. |
string |
Raw text, unchanged. | Unchanged. |
json, parentJson, parentJsonAutoInsert |
Parsed as JSON (the raw text is kept if it is not valid JSON). | Serialized as JSON; a string is published as is, without quotes. |
| (none) | Same as json. |
Same as json. |
Objects and arrays are always published as JSON text, whatever the datatype. Addresses created automatically (wildcard subscription, write or read on an unknown topic, broker mode) get the datatype json. Changing the Datatype of an address recomputes how its log is stored.
JSON parents. parentJson and parentJsonAutoInsert link a topic carrying a JSON object to child addresses named <parent>/<key>:
parentJson only updates children that already exist; parentJsonAutoInsert creates the missing ones, recursively for nested objects. In client mode, an object received from the broker is split into children only with parentJsonAutoInsert;/, +, #, %) are percent-encoded in the child name (a/b becomes a%2Fb).{
"name": "%mqtt:IoT_gateway",
"description": "",
"json": {
"qos": 0,
"retain": false,
"datatype": "parentJson"
},
"value": {"airQualityIndex":12,"humidity":22,"temperature":23.4},
"value_string": "{\"airQualityIndex\":12,\"humidity\":22,\"temperature\":23.4}",
"value_date": 1696943247274
}
{
"name": "%mqtt:IoT_gateway/temperature",
"description": "",
"json": {
"qos": 0,
"retain": false,
"datatype": "number"
},
"value": 23.4,
"value_string": "23.4",
"value_date": 1696943247274
}
Select one or several addresses of another gateway (BACnet, Modbus, KNX...) and drop them on the address list of the MQTT gateway. A topic is proposed for each of them: its name is the source address without the driver prefix (%bac:... becomes %mqtt:..., an alias $name becomes %mqtt:name) and its datatype follows the value (number, string, otherwise json). The import window can also create the routes between the source addresses and the new topics.
An address whose topic contains + or # is a subscription, not a single topic (client mode):
json);{"<topic>": "<payload>"};{"<topic>": <value>} to it publishes <value> on that topic, provided the topic already exists as an address.Writing to a %mqtt: address that does not exist creates it (datatype json) and publishes the value.
| Property | Value |
|---|---|
| Readable | Yes — returns the last value received or published. Reading an unknown topic creates the address and subscribes to it (client mode). |
| Writable | Yes — the value is published on the topic, e.g. writing {"value": 22.5, "unit": "C"} to %mqtt:building/floor1/temperature. Nothing is published when Not a topic is ticked. |
| Routable | Yes |
| Loggable | Yes |
| Auto-creation | Yes (wildcard subscriptions, writes and reads on unknown topics) |
| Symptom | Cause and fix |
|---|---|
| The gateway keeps restarting and never shows CONNECTED (client mode) | The broker cannot be reached or refuses the connection: the driver restarts and tries again after every failure. Check host, port, protocol, user name and password and, for mqtts / wss, the certificates. The gateway log shows client offline, broker unreachable. |
| Bad MQTT address when saving an address | The name does not follow the topic syntax: missing %mqtt: prefix, empty level, trailing /, or # not in last position. |
| A subscribed topic stays empty | The broker has no retained message for it: the value arrives with the next publication. |
The log shows subscribe failed for topic ... - will retry in 30s |
The broker refuses the subscription (access rights). If the topic may only be published, tick Publish only on the address. |
The log shows missing license |
The gateway has no MQTT licence (see the note at the top of this page). |