MQTT

As part of the Edge Xpert distribution, IOTech provides a Message Queuing Telemetry Transport (MQTT) Device Service. This allows Edge Xpert to subscribe to data from MQTT devices and to issue commands.

The MQTT Device Service provides a means of integrating MQTT devices with Edge Xpert. For more information, refer to the MQTT website.

The Edge Xpert MQTT Device Service is based on Eclipse Paho, a well-used, open source implementation of the MQTT version 3.1.1 written in Go.

The MQTT Device Service supports the following key features:

  • Asynchronous read. Data can be read from an MQTT topic asynchronously
  • Synchronous read. The MQTT Device Service can send a read request to an MQTT topic and listen to another MQTT topic for the result
  • Write. The MQTT Device Service can send a write request to an MQTT topic, to which the MQTT devices listen

The MQTT Device Service supports the JSON text format and parsing the reading value to the following data types:

  • Boolean
  • String
  • UInt8, UInt16, UInt32, UInt64
  • Float32
  • Float64

MQTT Examples

These examples use a device simulator, implemented using mqtt-scripts. mqtt-scripts is a script runner based on Node.js for use in MQTT smart homes. To use the device simulator, follow the steps in the following topic:

The following examples illustrate how the MQTT Device Service can be used:

The following example shows how to test the setup for any of the methods:

These examples assume that the Edge Xpert services have been started with at least the --ui --device-mqtt and mqtt-broker parameters. A suitable startup command would be as follows:

edgexpert up --xpert-manager --device-mqtt --mqtt-broker