Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

English

Connect a machine via MQTT

If a machine is to be connected to an asset, there are now 2 options available.

  1. Indirect connection via x4remote, which is described in the article https://ll-public.atlassian.net/wiki/spaces/X4/pages/303988737.

  2. Direct connection to the platform via MQTT.

The connection via MQTT using the example of the Lenze x500 is the topic of this article.

General

An MQTT telegram consists of a topic and a payload. In addition, a router also requires connection data such as URL and access data in order to be able to send its telegrams to a broker. All this information - URL, access data, server certificate and topic - is specified by the Asset Performance Platform and must be set in the router.

The Asset Performance Platform provides a broker that only allows an encrypted and authenticated connection.

The MQTT protocol specification does not define how the payload must be designed. This gap is filled by the Sparkplug B specification for MQTT user data.

Info

Sparkplug is an open-source specification hosted at the Eclipse Foundation that provides MQTT clients the framework to seamlessly integrate data from their applications, sensors, devices, and gateways within the MQTT Infrastructure.

You can find the specification here: https://sparkplug.eclipse.org/specification/

The Lenze x500 transmits its data Sparkplug B compliant. The Asset Performance Platform can read the payload in Sparkplug B format. With the restriction that the payload must be formatted as plain text JSON. The use of the Google Protocol Buffer Schema, as described in the specification, is in preparation.

A payload in Sparkplug B format is as follows:

Code Block
languagejson
{
  "timestamp": <send timestamp>,
  "metrics": [{
    "name": <metric_name>,
    "alias": <alias>,
    "timestamp": <collect timestamp>,
    "dataType": <datatype>,
    "value": <value>
  }],
  "seq": <sequence_number>
}

The keys from top to bottom are to be understood as follows:

Key

Bedeutung

<send timestamp>

mandantory

Timestamp when the telegram was send.

metrics

mandantory

Array von Datenpunktobjekten. Es können 1..n Datenpunktojekte hier eingefügt werden.

<metric_name>

mandantory

Name of the datapoint

<alias>

optional

Alias for the datapoint.

<collect timestamp>

mandantory

Timestamp when the datapoint was requested/deliverd.

<datatype>

mandantory

Datatype of the datapoint. You can find a list at the end.

<value>

optional

Value of the datapoint. If a value shall be published.

<sequence_number>

mandantory

continuous sequence number

Example payload:

Code Block
languagejson
{
	"metrics": [
		{
			"alias": 2,
			"datatype": 9,
			"name": "scCloud_rOEErt",
			"timestamp": 1721829360000,
			"value": 75.28211975097656
		},
		{
			"alias": 11,
			"datatype": 10,
			"name": "scCloud_lrQuantityOK",
			"timestamp": 1721829360000,
			"value": 3589.0
		}
	],
	"seq": 215,
	"timestamp": 1721829360042
}

Settings in the Asset Performance Platform

To create a connection for an asset, the configuration dialog can be called up via the connection icon.

grafik-20240724-145323.png

The connection type can be selected in this dialog. The entry “x500 via MQTT” must be selected here.

grafik-20240724-145415.png

The selection can then be confirmed with “Save”, as no further settings are required. The connection data is now generated by the system. This connection data must now be set in the router, which depends on the router manufacturer. The next section describes this for the x500 as an example.

In addition to the access data, the server certificate can be downloaded here. This is necessary so that the client can check the connection.

grafik-20240724-145607.png

These connection settings can be displayed again at any time in the same way.

Settings in the x500 or x4remote

comming soon.

Data type list

Expand
titleSparkplug Datatypes - Datentypen
Code Block
Unknown   = 0;
Int8      = 1;
Int16     = 2;
Int32     = 3;
Int64     = 4;
UInt8     = 5;
UInt16    = 6;
UInt32    = 7;
UInt64    = 8;
Float     = 9;
Double    = 10;
Boolean   = 11;
String    = 12;
DateTime  = 13;
Text      = 14;
UUID      = 15;
DataSet   = 16;
Bytes     = 17;
File      = 18;
Template        = 19;
PropertySet     = 20;
PropertySetList = 21;
Int8Array       = 22;
Int16Array      = 23;
Int32Array      = 24;
Int64Array      = 25;
UInt8Array      = 26;
UInt16Array     = 27;
UInt32Array     = 28;
UInt64Array     = 29;
FloatArray      = 30;
DoubleArray     = 31;
BooleanArray    = 32;
StringArray     = 33;
DateTimeArray   = 34