...
The protocol is an implementation of the MQTT 3.1.1 standard (October 2014) and the MQTT 5.0 standard (March 2019). MQTT protocol is a client/server protocol of a subscribe/publish type. It is simple, has little overhead, and is easy to implement. It is used for M2M communication (Machine to Machine) and in the IoT context (Internet of Things). The MQTT server is also called the MQTT broker.
D2000 KOM implements the client part of the protocol. The protocol is implemented on a TCP/IP-TCP and TCP/IP line-TCP Redundant lines. MQTTS (Secure MQTT, MQTT over TLS) is also supported - either directly in the D2000 KOM process (using TLS settings on on TCP/IP-TCP and TCP/IP-TCP lineRedundant lines) or via the tunnelstunnel utility.
For the transfer of LoRaWAN data encapsulated within the MQTT protocol, see LoRaWan protocol description.
...
- Connecting to the MQTT broker as a Host Application (data consumer, in Payload Type = Sparkplug Host mode):
- reading simple value types
- reading arrays (with support for the Destination column)
- writing simple value types
- reading of template items (UDT)
- reading of dataset items
- support for metric aliases
- compression support (GZIP, DEFLATE)
- browsing - finding a list of metrics
- Connecting to an MQTT broker as an Edge Node (data producer, in Payload Type = Sparkplug Edge Node mode):
- publishing values with simple types
- processing commands (NCMD, DCMD) with simple value types
- processing commands (NCMD, DCMD) with template (UDT) items
- processing commands (NCMD, DCMD) with dataset items
- processing commands (NCMD, DCMD) with arrays
- processing of the NCMD command with the Node Control/Next Server metric (connecting to the next MQTT server, if several are configured on the line)
- processing of the STATE message with the content online=false, which comes from the Primary Host Application (disconnecting from the MQTT server and trying another one, if several are configured on the line - searching for an MQTT server with a connected Primary Host Application)
- support for metric aliases
The communication was tested/deployed with:
...
Sparkplug's MQTT protocol defines 3 groups of applications:
- Edge Node - supports Supports the MQTT protocol and connects to the MQTT server. It sends him data obtained from the Device, its own, or aggregated data.
- Device/Sensor - represents Represents a physical or logical device connected to an Edge Node and providing data, process data , or metrics.
- Host Application - represents Represents a data consumer (SCADA/MES system, Historian, analysis tool) that connects to the MQTT server and receives MQTT data from the Edge Node/Device and, if necessary, commands.
...
- If the MQTT server supports Topic aliases, use MQTT Version = MQTT 5.0, and set Topic Alias Maximum to a value greater than the number of stations on the line (for Payload Type = Sparkplug Edge Node) or greater than the number of topics expected from the MQTT broker (for Payload Type = Text only / JSON). On the MQTT broker side, ensure that its Topic Alias Maximum value is greater than the number of topics that will be sent to the D2000 KOM process, so that numeric aliases can be used instead of text topics.
Note: the Topic Alias Maximum value that the MQTT broker sends when connecting as a parameter of the CONNACK message is visible in the communication logs:
09:31:12.086 13-05-2025|D|MQTT> CONNACK Property # 1 Topic Alias Maximum ( 34)
09:31:12.087 13-05-2025|T|MQTT> Recv:<00><0A>
09:31:12.088 13-05-2025|D|MQTT> CONNACK Property value= 10 - Set Subscribe QoS = QoS_0 to not require acknowledgments for PUBLISH messages (unless they are needed for some reason). Additionally, if TLS is also active, this will cause a small packet (e.g., PUBACK for QoS_1) to be encrypted and result in a larger encrypted packet.
- Use aliases for metrics (for for Payload Type = Sparkplug Edge Node): automatically using the Sparkplug Alias Mode=Automatic (HOBJ) parameter or manually using the SAL=alias item in the I/O tag address. If you use manual aliases, use low numbers (aliases 10-127 are encoded as 1 byte).
- For Payload Type = Sparkplug Edge Node: if there are many changes to the output I/O tags, we recommend setting the Batch Size parameter to a larger value than the default (10) and possibly increasing the Delay parameter in the station's time parameters. This will cause fewer messages to be generated (and each will contain multiple metrics), which reduces the overhead required to transmit one metric. If specific I/O tags change frequently, the message may contain several values for the same I/O tag (with timestamps). The disadvantage is the delay in the values.
...
If the TCP/IP-TCP Redundant line is configured, two TCP connections are created (to 2 MQTT brokers), each of which can be directed to one of multiple configured IP addresses. The D2000 KOM process receives values from both MQTT brokers and sends all values of the output I/O tags to both MQTT brokers. The write is considered successful if the value is successfully sent to at least one MQTT broker (in the case of confirmation, if "Subscribe QoS" > QoS_0, if it is confirmed by at least one of the MQTT brokers). Such a configuration allows you to configure a redundant system in which the D2000 KOM connects to two redundant MQTT brokers and the other side to at least one MQTT broker, while the MQTT brokers do not have to form a "cluster", i.e. synchronize messages with each other (so the simple and free Eclipse Mosquitto can can also be used - see configuration example).
Forced disconnection: If all stations on the line are in the simulation mode or the communication is stopped for them, the line will be disconnected (the communication socket will be closed). If the simulation is disabled for at least one station and the communication is not stopped for it (the Parameters tab of the Station type object), the line will be connected again.
In Payload Type = Sparkplug Edge Node mode, if communication on the Edge Node station is stopped, the line will be disconnected (even if Device type substations have communication stopped). If communication on the Device station is stopped and the Edge Node station is communicating, the D2000 KOM will send a DDEATH message and after turning on the Device station, it will send a DBIRTH message.
| Kotva | ||||
|---|---|---|---|---|
|
...
| Info | ||
|---|---|---|
| ||
You can read a blog about the MQTT protocol |
| Kotva | ||||
|---|---|---|---|---|
|
...