Supported MQTT brokers and StrideLinx hardware
- Azure IoT Hub
- Azure Event Grid
- Amazon Web Services (AWS) IoT Core
- Eclipse Mosquitto broker
Supported StrideLinx hardware:
- StrideLinx router3, firmware 3.24 and up (upgrade)
With Datalogging to MQTT broker, you log your machine data directly to a 3rd party MQTT broker instead of the StrideLinx Cloud. As such, it's an alternative to the feature Historical data, where the machine data is logged to the StrideLinx Cloud. The MQTT broker can either be self-hosted or it can be run at an online service like Azure or Amazon Web Services (AWS). From there, you can process, analyze, visualize, and use the data in any way that your project requires.
If there is no internet connection available for the StrideLinx router, your data is not lost. The StrideLinx router will then continue logging data and can store it locally for months at a time, depending on how much data you log. This data is locally not accessible. Once the internet connection has been restored, the logged data will be sent to your MQTT broker.
Notes
- The machine data is ONLY sent to your MQTT broker and not to the StrideLinx Cloud. If you also wish to log your machine data to the StrideLinx Cloud, simply create a second similar data source without selecting an MQTT broker. Do note that logging to the StrideLinx Cloud requires a module. More information: Configure and use historical data.
- If you have a Live data or Alarming module in your StrideLinx Cloud company (or a legacy Cloud Logging or Cloud Notify license on this device), the Run test, Live data, and Alarming features still work via the StrideLinx Cloud. As a result, the data logging connection between the StrideLinx router and the StrideLinx Cloud remains active.
- The Run test feature, to test your variables after you've added them, is only available if you have a Live data module in your StrideLinx Cloud company ( or a legacy Cloud Logging or Cloud Notify license on this device).
Add an MQTT broker
First you'll need to set up an MQTT broker for the StrideLinx router to send data to.
- Set up an MQTT broker.
- You can host one yourself or run it at an online service like Azure or AWS. For instructions, please consult the service provider's documentation.
- The MQTT broker needs to support encrypted connections. Unencrypted connections are not supported by Datalogging to MQTT broker.
- With Azure IoT Hub, Azure Event Grid, and AWS IoT Core, the MQTT Client ID in the MQTT broker (sometimes called Device ID) needs to be equal to the StrideLinx router's public ID. You can find the StrideLinx router's public ID in the URL by going to the device in the StrideLinx Cloud Fleet Manager. For example:
stridelinx.com/fleet-manager/device-configurator/mxLCEyXfR5Lx/...
.
Once you have an MQTT broker available, it needs to be added to the StrideLinx Cloud.
- Go to Admin > MQTT and add a custom broker.
- Enter the requested information (details below) and click on Confirm.
Field Description / instructions Name Enter a name for the MQTT broker. Host Enter the hostname or IP address of your MQTT broker.
Port Enter the port of your MQTT broker. CA certificate (optional) If your MQTT broker provider also provides a CA certificate or if you added one yourself, upload it here.
Publicly trusted certificates generally don't need to be uploaded manually.Message format The message format determines the format of the data message sent to your MQTT broker.
JSON (default)
The JSON representation of the Sparkplug B payload format (example below, details in chapters 6.4.5 and 6.4.6 of the Sparkplug B specification). Less data efficient, but human readable.Note that "alias" is the "tag ID" number, which is unique for every tag.
{ "timestamp": 1697611645, "metrics": [{ "name": "Machine state", "alias": 124, "timestamp": 1697611511, "dataType": 13, "value": "Emergency stop" }], "seq": 2 }
Sparkplug B
A binary encoded message format that uses protocol buffers to (de)serialize data. More data efficient and recommended for cellular connections.The data message will need to be decoded using protocol buffers (see chapter 6.4.1 of the Sparkplug B specification below). Alternatively, online service providers may also provide a specific Sparkplug B message decoder. However, it is important to note that the actual data message format slightly deviates from the official Sparkplug B message format. More details below.
The technical implementation is a variation on the payload format of the Sparkplug B specification (chapter 6.4). The main differences are that no separate birth message is sent and instead each data message includes the metrics' name and data type, as per the example above.Clients The MQTT client is the authorization to communicate with your MQTT broker. Multiple clients can be added to a single MQTT broker. Supported authorization methods: no authentication (leave all fields empty), username/password, certificate, key file.
Azure IoT Hub
With Azure IoT Hub, the username needs to be the following format. The API version is optional, but recommended for long-term stability. Replace{IOT_HUB_HOSTNAME}
and{IOT_HUB_DEVICE_ID}
with your IoT Hub Hostname and Device ID.{IOT_HUB_HOSTNAME}/{IOT_HUB_DEVICE_ID}/?api-version=2021-04-12
With Azure IoT Hub, the password needs to be a SAS token, which you can generate within Azure IoT Hub. For more instructions, please consult the Azure documentation.
You have now made the changes in the StrideLinx Cloud, but these are not yet active in your device. These will automatically be applied to your device later at step 9.
If you make any changes to the MQTT broker and client configuration afterwards, these will need to be manually applied by rebooting the device (either locally or remotely in the StrideLinx Cloud) or pushing a configuration to the device (if available).
Read machine data
The machine will need to be added as a data source in the StrideLinx Cloud and its variables will also need to be added.
Several communication protocols are supported. This is the protocol that the StrideLinx router will use to locally communicate with your machine. If you're unsure whether your machine supports one of these protocols, please check with the manufacturer.
- Add a new data source with variables, or use an existing one. Follow the instructions in one of the articles below to create a new one and come back here once you have.
Send machine data to the MQTT broker
Now that your data source is configured and your MQTT broker has been added to the StrideLinx Cloud, you can start sending your machine data to your MQTT broker.
- Go to Fleet Manager > Devices and click on your device name.
- In the left menu, under Services, click on the data source you previously created.
- At the bottom, under MQTT, enable Use custom broker.
- Select your MQTT broker and client, and enter a topic.
- Don't see your MQTT broker and client? Go to Admin > MQTT and make sure that a client is added to your MQTT broker. A client is required. More information at step 4.
- Some MQTT broker providers require data to be sent to a specific topic. If you're unsure, please consult the service provider's documentation.
- With Azure IoT Hub, the topic needs to be the following format. Replace
{IOT_HUB_DEVICE_ID}
with your IoT Hub Device ID.
devices/{IOT_HUB_DEVICE_ID}/messages/events/
- With Azure IoT Hub, the topic needs to be the following format. Replace
You have now made the changes in the StrideLinx Cloud, but these are not yet active in your device. You will need to push your changes to your device for them to take effect.
Log machine data
Now that the data source and variables have been set up, you can configure when you effectively want to log data. You can log data on interval (every 100ms - 1h), when the value in the machine changes, or on custom triggers. This is configured in tags.
- Add a tag for every variable that you want to log. Follow the instructions in the article below and come back here once you have.
Your Edge Gateway will now start sending machine data to your MQTT broker, according to how you configured the tags in the data source. Please note that only Historical data is sent to your MQTT broker. The Run test feature, Live data, and Alarming still work via the StrideLinx Cloud.
Troubleshooting
This chapter contains information and tips to help troubleshooting if Datalogging to MQTT broker doesn't work.
- Double check the instructions in this article. Do not skip this step, because the instructions may contain the solution to your problem. Some examples:
- The MQTT broker needs to support encrypted connections. Unencrypted connections are not supported by Datalogging to MQTT broker.
- With Azure IoT Hub, Azure Event Grid, and AWS IoT Core, the MQTT Client ID (sometimes called Device ID) in the MQTT broker needs to be equal to the StrideLinx router's public ID. You can find the StrideLinx router's public ID in the URL by going to the device in the StrideLinx Cloud Fleet Manager. For example:
stridelinx.com/fleet-manager/device-configurator/mxLCEyXfR5Lx/...
. - When selecting the MQTT broker and client at your data source: Don't see your MQTT broker and client? Go to Admin > MQTT and make sure that a client is added to your MQTT broker. A client is required. More information at step 4 of this article.
- Some MQTT broker providers require data to be sent to a specific topic. If you're unsure, please consult the service provider's documentation.
- Test if your MQTT broker is accessible and working.
- There are numerous MQTT client applications available for testing (e.g. MQTT Explorer). Have a look under "Tools and Applications" at mqtt.org/software for a complete list.
- Unsure what the status is of the MQTT connection?
- In your MQTT broker (environment) you should be able to see if there is an active MQTT connection and also if data is being received.
Frequently asked questions
Can you send data to an MQTT broker on the LAN side of the StrideLinx router?
What if the MQTT broker certificate has expired?
You'll need to upload a new, valid, certificate to your MQTT broker settings at Admin > MQTT in the StrideLinx Cloud.
The StrideLinx router will automatically download the latest configuration from the StrideLinx Cloud, which includes your uploaded certificate. So long as the MQTT connection fails, the StrideLinx router will repeat this process every few minutes, but it can also be manually triggered by rebooting the device (either locally or remotely in the StrideLinx Cloud).
While the StrideLinx router has no MQTT connection, the StrideLinx router will continue logging data and can store it locally for months at a time, depending on how much data you log. This data is locally not accessible. Once the MQTT connection has been restored, the logged data will be sent to your MQTT broker.