Skip to main content

BP Sensors to MQTT

Loading...

In this step, we modify the previous project to publish the sensor data to the MQTT server instead of saving it into the log.

MQTT is a popular protocol for machine-to-machine communications. It is often used to transmit sensor data. This project publishes the seven data streams from four Bus Probe sensors to a test server located at 104.40.239.93.

MQTT is configured on the MQTT page of the Features tab. Here is this application's configuration:

MQTT configuration modal for Bus Probes on TPS, with configuration for topics, debug print, server port, password, username, and client ID.

Publishing of MQTT data is performed using the MQTT Publish block. This application has four such blocks, one for each data stream. Click on any block to inspect its properties:

Flowchart for application logic publisihng an MQTT message, with sidebar displaying configurable parameters for data, topic, QoS, and retain.

Testing MQTT

To see the application in action, you will need an MQTT client. We rely on the MQTT Explorer software -- it is free and simple to use. You can download it here:

http://mqtt-explorer.com/

Launch the MQTT Explorer and click + to create a new connection. Fill in the connection parameters as shown below:

MQTT client connection configuration modal to connect with device.

Click CONNECT. The sensor data will be under demo > devices > bpmqtt:

MQTT explorer showing the connected device with modbus sensor readings published to a topic.
Note

There is no way to influence the environment of Cloud ADK sensors, and their output remains virtually constant.