Skip to content

MQTT plugin


MQTT is an OASIS standard messaging protocol for the Internet of Things (IoT). It is designed as an extremely lightweight publish/subscribe messaging transport that is ideal for connecting remote devices 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, etc.

This plugin connects to the uBrigde server, subscribes for all the available sensor's data, and publish the incoming data into the configured MQTT Broker.

Source code and Installation

The source code and installation instructions can be found here.

Configuration file

The configuration file is installed here: /etc/ubridge/mqtt-plugin-config.json

Here is the default configuration:

    "ubridge": /* socket configuration for the uBridge side: */
        "configSockUrl" : "ipc:///tmp/ubridgeReqResp",/* The sockets for the Request Response Server and data Streamer*/
        "streamSockUrl" : "ipc:///tmp/ubridgeStream"/* If the client app runs in the same machine, IPC is 
                        more efficient. If a different host is used (as with a client running in a Docker instance)
                        use TCP host:port ("tcp://localhost:8001")*/
    "mqtt":  /* configuration for the MQTT side: */
        "mqttServerAddress" : "tcp://",/* The MQTT address and port*/
        "username" : "",/* username (in some platforms a token is provided here for authentication purposes)*/
        "password" : "",/* mqtt password (if provided), depends on broker */
        "baseTopic" : "v1/uThing",/* base topic, the device name and measurements will follow */
        "clientId" : "uBridgeMqttPlugin",/* client ID name*/
        "breakDownJson" : true/* True: each measurement is Published in a different topic.
                                False: the entire JSON is sent in a single Publish*/
  • "configSockUrl and streamSockUrl": These have to be the same as in the uBridge configuration.

  • "mqttServerAddress": Address:port of the MQTT Broker.

  • "username": Client user name. In some platforms, a "token" is provided here instead for authentication purposes.
  • "password": Client's password (if provided), depends on the broker.
  • "baseTopic": Base "topic". The device name and measurements will be added to form the full topic. In some platforms, an UUID can be provided here, so the Subscriber can access the data published by this user, i.e. "/v1/123e4567-e89b-12d3-a456-426614174000"
  • "clientId": MQTT Client ID

  • "breakDownJson": When "true", each measurement is Published in a different topic (i.e. "/v1/lab1/uThing::MNL_D657/noise/rms"). If "false" the entire received JSON will be published in a single message.

NOTE: Remember to restart the service after changing the configuration file (sudo systemctl restart ubridge-mqtt-plugin.service).

HiveMQ Public Broker

For a quick validation, the HiveMQ platform provides a public broker and a web-based client that can be used to experiment and test the plugin. The default configuration provides already the address of this broker.

If the Plugin was installed and the service started, go to the webclient, click on "Connect", and Subscribe to the Topic of interest, or use the wildcard # to subscribe to all the topics coming from the plugin, for example: "/v1/uThing/#":



Check running status of the service

 systemctl status ubridge-mqtt-plugin.service

mosquito client CLI

Tip: mosquitto_sub

We can use the "mosquitto" client to connect to the broker and subscribe to the messages that the plugin is publishing.

sudo apt-get install mosquitto-clients

Then we can run it providing the url, port and we use the wildcard # to subscribe to those topics. The "-v" option shows the topic also. For example:

mosquitto_sub -h -p 1883 -v -t "v1/uThing/#"

This is an example of data received:

v1/uThing/uThing::VOC_F8B6/gasResistance 120986
v1/uThing/uThing::VOC_F8B6/IAQ 108.5
v1/uThing/uThing::MNL_D657/noise/rms 31.5
v1/uThing/uThing::VOC_F8B6/eqBreathVOC 4.97
v1/uThing/uThing::MNL_D657/pir/detPerHour 120
v1/uThing/uThing::MNL_D657/light/average 742.19
v1/uThing/uThing::VOC_F8B6/humidity 22.61

Log file

The log files for the uBridge and plugins are located in the /tmp directory:

tail /tmp/ubridge-mqtt.log