Email Us at [email protected]

Download N3uron

Back to videos

MQTT Client / Configuring MQTT Client

Configuring MQTT Client

Description

In this video of our N3uron Academy, we’re going to explore how to configure the N3uron MQTT Client module. Let’s get started!

  • [09:29] Configuring MQTT Client

Transcription

[00:00] Hello everyone! Today, we’re going to explore how to configure the N3uron MQTT Client module. MQTT Client is designed to connect to any MQTT broker to send and receive events. It implements bidirectional connections to brokers, and each connection may have one or more publishers, which send information from tags to the broker, and subscribers, which receive events from remote devices via MQTT. To begin the configuration, navigate to the “Config” tab in the “System” section. Click on “Modules” and then select “New Module.” Assign a meaningful name to the instance, such as “MqttClient,” and set the Module Type to “MqttClient.” Once done, save the changes. In the Explorer panel, locate your newly created module and click on it.

[01:00] Next, navigate to the Model header, open the burger menu, and select “New Connection.” Finally, assign it a descriptive name. The first setting you need to configure is the MQTT version. Choose between MQTT 3, which is widely supported, or MQTT 5, which introduces features like session expiry, message expiry, and user properties for enhanced message management. Selecting MQTT 5 unlocks additional options for enhanced messaging and connection control. In this example, we’re going to choose MQTT 3. Next, configure the destination broker. N3uron supports pre-configured connections to Azure IoT Hub, AWS IoT Core, Google IoT Core compatible brokers, or any Custom broker. If you select a pre-configured broker destination, certain settings will be locked to meet its requirements. If you select “Custom,” all configuration options will be available.

[02:00] In this example, we are going to proceed with a Custom broker configuration, and specific brokers such as AWS IoT Core and Azure IoT Hub will be covered in future videos. Next, enter the Client ID that uniquely identifies your MQTT connection. You can generate this ID randomly if needed. Now, let’s move on to authentication. Select an authentication mode based on your broker’s requirements. Available options include None, Password, Certificate, Password with Certificate, or JSON Web Tokens (JWT). If JWT is selected, additional fields will appear to define token duration, signing algorithm, and other properties. In this case, we will select Password and Certificate authentication. Enter the username and password, then provide the certificate. Certificates can either be embedded directly or selected via a file path.

[03:13] For security and communication, select whether to use standard MQTT or MQTTS, which encrypts data for secure transmission. Enter the broker’s URL, specify the port—1883 for MQTT and 8883 for MQTTS typically—and configure connection properties such as Clean Session, Reconnect Period, Keep-alive Interval, and Interval between messages. Now, let’s take a look at the Last Will and Testament (LWT). This feature ensures that if the client unexpectedly disconnects, a pre-configured message is sent to a specified topic. Enable LWT, set the topic, define the payload message, and select the Quality of Service (QoS) level for delivery reliability.

[04:02] If using MQTT 5, additional properties such as Will Delay Interval, Message Expiry Interval, and User properties can be configured. In this case, I will leave the Last Will and Testament disabled. With the connection settings complete, let’s configure the agents. Agents are responsible for publishing and subscribing to topics. Create a new agent and specify whether it will function as a Publisher or Subscriber. Since we have selected MQTT 3, the available agent will be compatible with this version. If you choose MQTT 5, additional advanced options will be available for both Publishers and Subscribers. When setting up a Publisher, choose between Events mode or Snapshot mode. In Events mode, also known as “report by exception” mode, data is sent only when a tag’s value, quality, or timestamp changes, saving bandwidth. In Snapshot mode, tag data is sent at fixed intervals regardless of changes, and timestamps can be overridden to the current publish time if necessary.

[05:05] In this case, we will select Events mode, as it is the most commonly used option. Next, Configure the Maximum Publishing Interval to determine the time between each data push to the MQTT broker or the disk, if the connection is offline and Store & Forward is enabled. Set the Events per Message parameter to specify the number of events in a message. When this number of events is reached, a new message is generated and published. Whatever happens first, Publishing Interval or Events per Message will push a message to the broker, provided there are new events to transmit. Specify the Topic to which messages will be sent, define the QoS level, and enable the Retain Flag if you want the broker to retain the last published message for new subscribers. Additionally, enable Store and Forward (S&F) to buffer messages when the connection to the broker is lost.

[06:00] Stored messages will be published automatically once the connection is reestablished. Configure the Path for S&F storage and set the Maximum Days in Disk to control the data retention period. A shortcut icon is available to quickly remove Store and Forward data if needed. The message format settings include Serialization, allowing you to choose from preconfigured JSON, Protocol Buffers, InfluxDB, or Custom payloads to suit your needs. The Data Structure setting can be either Compact or Extended. Compact groups all events for a tag together with the tag name, reducing message size, while Extended includes the tag name in every event. For Date Format, choose UNIX Epoch in milliseconds or ISO for ISO-String timestamps. Compression options include None, Gzip, and Deflate, with Compression Level settings such as Best Speed, Default Compression, and Best Compression. Finally, configure Encoding as UTF-8, Binary, Base64, or Hexadecimal to ensure compatibility with different MQTT clients.

[07:04] In this example, we are going to publish analog sensor data from several wind turbine generators, as shown in the Data > Realtime window. For our final step, we’ll set up Tag Filters to include or exclude specific tag folders or tag names using regular expressions, ensuring that only the relevant data is published to the topic.

[08:02] Next, we verify connectivity to the broker and confirm that data is being published correctly by navigating to the Diagnostics section, selecting Realtime Logs in Trace mode, and choosing the MQTT Client module. After confirming everything is working properly, we will verify that the data is successfully published to the broker using a third-party MQTT Client to subscribe to the topic.

[09:11] And that’s it! You’ve successfully configured the N3uron MQTT Client for publishing data. In the coming videos, we will cover more advanced topics for MQTT Client. Thanks for watching!

Privacy Settings
We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
Youtube
Consent to display content from - Youtube
Vimeo
Consent to display content from - Vimeo
Google Maps
Consent to display content from - Google
Spotify
Consent to display content from - Spotify
Sound Cloud
Consent to display content from - Sound