How do I connect to my MQTT broker

Setting up a subscription to your MQTT broker

If your MQTT broker is not supported with a specific connection, we can use our generic MQTT subscription to connect to it.

It does make the assumption that your broker is sending messages in JSON over MQTT, which is the most common format. However, if your broker doesn't do this, then please contact support via the chat widget to discuss your requirements. Also, some MQTT brokers are just a bit twitchy, so if something doesn't seem right, please jump on the support chat and tell us, and we'll do our best to get you connected.

We have a two part process

  1. Connection details and credentials
  2. Topic subscription
  3. Message format and field mapping

1. Connection details and credentials

The following screen is shown to collect the details of the broker

MQTTBroker

Then we need to collect the access credentials for your broker:

MQTTAccess

Once we have these we can move to step 2.

2. Topic Subscription

To continue DevicePilot needs to test the connection to your broker and examine a typical payload.

Please provide the topic (+ wildcards are supported) that DevicePilot should subscribe to to receive messages from your devices. As we'll see in Step 3, if your topic name includes the device identifier, be sure to use the + wildcard to capture it as we'll need it later.

After you've entered your topic name, press Connect. DevicePilot will make sure it can subscribe using the configuration provided and wait 30 seconds to receive a payload on this topic.

MQTTConnectionDetails-1

Once the subscription is successful and message has been received the payload will be displayed for transformation in the next step.

3. Message format and field mapping

This screen has a few sections, so let's go over them one-by-one.

The goal here is to understand you message format, and ensure we can correctly map to DevicePilot properties. Also, one specific requirement is that we need to know the unique device identifier for each message.

First we see the topic we got a message on, and also the raw payload of the message

MQTTPayloadTransformation

We can also see the decoded payload

MQTTPayloadTransformed

The only configuration we need to supply is how to know the unique device id. As you can see from the payload, it is not contained in it, but instead it comes from the topic.

MQTTDeviceId-1

In your case, you might have the id included in the payload, in which case you could select that, but in this example, we are choosing the wildcard we matched in the topic.

Conclusion

Now we've configured everything, we click Create Connection and wait. DevicePilot will now subscribe to the topic and start processing the data from that stream. Our streaming engine is a pipeline, and so it can take a minute or two for everything to find its way through. Once we've seen devices created, we'll take you to the View page so you can visualise them.