Skip to main content

General MQTT

This section explains a general approach that can be adapted to most devices supporting MQTT with certificate-based authorization.
If this approach doesn’t work for your device, please let us know via @diologiSupport.

Create a new device and get certificates

Open the Settings menu in the Diologi chatbot and select New device (refer to the Connect Your Device section for detailed instructions). You will then be prompted to download a security certificate for your device.

Depending on your device type, choose either:

  • Standard certificates: Downloadable as three separate files:
    • Client Certificate
    • Client Private Key
    • Server Certificate (CA)
  • Full-chain certificate: Downloadable as a single file containing the above certificates and private key.

For this tutorial, we will need the standard certificates pack.

tip

Keep these certificates in a secure place, or better yet, remove them after establishing the connection between your device and Diologi.

Download MQTT Explorer

For this guide, we will use MQTT Explorer, a free MQTT client useful for testing and troubleshooting MQTT connections.
You can download the latest version from mqttexplorer.com.

Set up Connection Settings

To add a new connection in MQTT Explorer, follow these steps:

  1. Click the + button to create a new connection.

  2. Give it a Name (e.g., diologi).

  3. Ensure that the Validate Certificate and Encryption (TLS) options are enabled.

  4. Set the Protocol to mqtt and enter the Host:

    mqtt.diologi.com
  5. Enter the Port:

    8883
  6. Leave the Username and Password fields blank.

MQTT Explorer Connection Settings

Upload the certificates to Device (MQTT Explorer)

  1. In the MQTT Connection window, click ADVANCED.
  2. In the window that opens, enter your Device ID in the MQTT Client ID field.
    You can find the Device ID in the chatbot Settings selecting your device from the list.

MQTT Explorer Advanced Settings - Client ID

  1. Click on CERTIFICATES.
  2. Upload the Server Certificate (CA), Client Certificate, and Client Private Key that you downloaded from the chatbot in the first step.
  3. Click BACK until you return to the initial connection settings window.

MQTT Explorer Certificate Upload

Connect to the Diologi chatbot

In the first window with connection settings, click the CONNECT button.
If everything is configured correctly, you should see the window below, showing master = online under Status in the left navigation sidebar.

MQTT Explorer Connected: Online status

note

If you don’t establish a connection, ensure that port 8883 is open on your PC or device and routers.

Communication

Once connected, you can test topics and exchange data between Diologi and MQTT Explorer.

note

Before performing publishing or subscribing requests from MQTT Eexplorer, make sure you have configured the points in the Diologi chatbot using the Points Configuration Template in Excel.

MQTT topics on your field device must exactly match the topics defined in the Excel file, including the device ID at the beginning.

Publishing Data:

  1. Enter the topic, starting with your device ID.
  2. Select json as the format.
  3. Enter the value you want to send with the topic and click the PUBLISH button.
note

The topic must not start or end with a slash (/). The slash should only be used to separate topic segments.

Subscribing to Topics:

  1. If currently connected, disconnect first.
  2. Click ADVANCED again in the MQTT Connection settings.
  3. In the window that opens, ADD the topics you wish to subscribe to.
  4. Connect again. The subscription topics will then be shown in the left sidebar.

For more detailed information, please refer to the MQTT Explorer Guide.