HiveMQ Edge Protocol Adapters

HiveMQ Edge allows the runtime to connect to any proprietary protocol format and converts it into open standards MQTT. In HiveMQ Edge, the components that contribute this functionality are called 'protocol adapters'. To contribute new protocol adapters, you can create your own module that conforms to the requisite format and build the adapters into your runtime. When contributed, the runtime will manage the lifecycle of these components and allow you to create any number of connections to your devices.

Tags

Industry protocols are very different in how they work and how they are configured. HiveMQ Edge minimizes the configuration burden and makes the usage easy. For example, configuring ModBus registers is very different from the configuration of nodeIds for OPC UA. All protocol adapters have the MQTT destination topic in common.

Managing Tags

Tags can be defined on the workspace by clicking on the device shown in the screenshot below:

Edit Tags from Workspace

A dialog will be opened which is almost identical for every protocol adapter. The first part of a tag definition includes a name of the tag and a description. A tag name is unique across a HiveMQ Edge deployment. The definition part of a tag is different per protocol adapter, e.g., OPC UA Tags.

Editing Tags (Example OPCUA

Northbound

Table 1. Items of northboundMappings
Property Name Default Mandatory Description Format

tagName

The tag name

String (Tags), e.g., machine_EFIS10/temperature

topic

The MQTT topic

String, e.g., machine/EFIS10/temperature

maxQos

0

The maximum MQTT QoS for the outgoing messages

0,1, or 2

messageExpiryInterval

no expiry

The message expiry in seconds that is used for the MQTT message.

Integer 1 - 4294967294

Southbound

Table 2. Items of northboundMappings
Property Name Default Mandatory Description Format

tagName

The tag name

String (Tags), e.g., machine_EFIS10/temperature

topicFilter

The MQTT topic filter to read from

String, e.g., machine/+/temperature

Topic Filters

MQTT topic filters are used to read data which is then written to a tag. A topic filter must have a data schema to provide reliable operations.

Only JSON schemas are supported yet.

Topic filters can be defined on the workspace:

Edit Topic Filters from Workspace

A dialog will be opened that supports the user to create topic filters and to associate a schema with it.

Topic Filter Dialog from Workspace

Once a topic filter has been created, there are two options to assign a schema to it: Option 1: The easiest way is when you’re already sending data to a topic that is included in the topic filter. The topic filter dialog has the option to infer a schema from existing traffic.

Infer a schema from existing traffic

Option 2: You can upload a JSON schema file to HiveMQ Edge that defines the schema of the incoming data.

HiveMQ Edge makes sure that the incoming MQTT traffic is continuously checked against the defined schema before it writes to the tag and eventually to the device. All invalid messages are re-routed to the topic $invalid.

HiveMQ Edge Protocol Adapter Configuration

Adapter instances can be added to the system using API, static configuration, or the user interface. All 3 mechanisms result in the main config.xml file being updated with a new element within the <protocol-adapters> element. Each adapter type has its own element name which matches the adapter type name in the ProtocolAdapterFactory. For example, the 'Simulation' protocol has a type of 'simulation' and a <simulation></simulation> configuration element.

In the adapter configuration, each adapter instance much be identified with a unique <id> element .

The HiveMQ Edge UI and API automatically validate the uniqueness of the instance.

HiveMQ Edge Provides the following protocol adapters:

Custom adapters can be built to adapt further protocols to fit your business needs.

Simulation Adapter

The simulation adapter enables the system to be configured to publish messages with random values through the protocol adapter layer at a specific interval. This functionality enables you to observe the behavior of adapters in the system.

The example configuration publishes random data with MQTT quality of service level 1 to the destination topic called 'topic'.

Example simulation adapter configuration
  <simulation>
        <id>sim</id>

        <minDelay>0</minDelay>
        <maxDelay>0</maxDelay>
        <minValue>0</minValue>
        <maxValue>1000</maxValue>
        <simulationToMqtt>
            <pollingIntervalMillis>1000</pollingIntervalMillis>
            <simulationToMqttMappings>
                <simulationToMqttMapping>
                    <includeTagNames>false</includeTagNames>
                    <includeTimestamp>true</includeTimestamp>
                    <messageHandlingOptions>MQTTMessagePerTag</messageHandlingOptions>
                    <mqttQos>0</mqttQos>
                    <mqttTopic>sim</mqttTopic>
                </simulationToMqttMapping>
            </simulationToMqttMappings>
        </simulationToMqtt>
</simulation>

Simulation Adapter Properties

Table 3. Simulation To MQTT Mappings
Property Name Default Mandatory Description Format

id

The unique identifier of the selected adapter instance.

String [a-zA-Z0-9-_]

minValue

0

Minimum limit for the randomly generated values of the simulator.

Integer

maxValue

1000

Maximum limit for the randomly generated values of the simulator.

Integer

minDelay

0

Minimum of artificial delay before the polling method generates a value

Integer > 0

maxDelay

1000

Maximum of artificial delay before the polling method generates a value

Integer > 0

simulationToMqtt

General config of mappings from simulator to MQTT

simulationToMqtt (list)

Table 4. Simulation To MQTT
Property Name Default Mandatory Description Format

pollingIntervalMillis

10000

Time in milliseconds between the publish operations of the simulator.

Integer

simulationToMqttMappings

List of simulator to MQTT mappings

simulationToMqttMappings (List)

Table 5. Simulation To MQTT Mapping
Property Name Default Mandatory Description Format

common configurations

Common configurations

See Common Configurations

Example MQTT Payload of the Simulation Adapter
{
  "timestamp" : 1730707250320,
  "value" : 729.6615064364747
}

ModBus (TCP) Adapter

The ModBus adapter enables connections to ModBus slaves via TCP. We support reading from coils, discrete inputs, input registers and holding registers in the address range 0-65534 (incl).

The connection samples the ModBus slave on the sampling time specified in the configuration. Each connection can be configured to only publish samples when changes in values are detected.

Example ModBus (TCP) adapter configuration
<modbus>
    <id>my-modbus-protocol-adapter</id>
    <host>my.modbus-server.com</host>
    <port>502</port>
    <timeoutMillis>500</timeoutMillis>
    <modbusToMqtt>
        <pollingIntervalMillis>150</pollingIntervalMillis>
        <maxPollingErrorsBeforeRemoval>5</maxPollingErrorsBeforeRemoval>
        <publishChangedDataOnly>false</publishChangedDataOnly>
        <modbusToMqttMappings>
            <modbusToMqttMapping>
                <mqttTopic>my/topic</mqttTopic>
                <mqttQos>1</mqttQos>
                <tagName>myTag</tagName>
                <messageHandlingOptions>MQTTMessagePerSubscription</messageHandlingOptions>
                <mqttUserProperties>
                    <mqttUserProperty>
                        <name>name</name>
                        <value>value1</value>
                    </mqttUserProperty>
                    <mqttUserProperty>
                        <name>name</name>
                        <value>value2</value>
                    </mqttUserProperty>
                </mqttUserProperties>
                <includeTagNames>true</includeTagNames>
                <includeTimestamp>false</includeTimestamp>
            </modbusToMqttMapping>
        </modbusToMqttMappings>
    </modbusToMqtt>
</modbus>
Example ModBus (TCP) tag definition referenced via its name "myTag" in the config above.
<tag>
    <tagDefinition>
        <unitId>0</unitId>
        <startIdx>11</startIdx>
        <readType>HOLDING_REGISTERS</readType>
        <dataType>INT_64</dataType>
    </tagDefinition>
    <tagName>myTag</tagName>
</tag>

ModBus (TCP) Adapter Properties

Property Name Default Mandatory Description Format

id

The unique identifier of the selected adapter instance.

String [a-zA-Z0-9-_]

host

The host or IPv4/IPv6 of the ModBus device.

URI

port

The port to connect to.

Integer 1-65535

modbusToMqtt > pollingIntervalMillis

1000

Time in milliseconds between samplings.

Integer

modbusToMqtt > maxPollingErrorsBeforeRemoval

10

The number of times the adapter attempts to sample while an error condition is detected.

Integer (-1 to disable)

modbusToMqtt > publishChangedDataOnly

true

Specifies whether the adapter only publishes data when a field value change is detected.

Boolean

modbusToMqtt > includeTagNames

false

Include names of the tags with each publish

Boolean

modbusToMqtt > includeTimestamp

false

Include the timestamp of when the tag was collected

Boolean

modbusToMqtt > dataType

false

Data type to be read from the addressRange

BOOL | INT_16 | UINT_16 | INT_32 | UINT_32 | INT_64 | FLOAT_32 | FLOAT_64 | UTF_8

modbusToMqtt > modbusToMqttMappings

Specifies whether the adapter only publishes data when a field value change is detected.

Boolean

modbusToMqtt > modbusToMqttMappings > modbusToMqttMapping > mqttTopic

Topic to publish to

String

modbusToMqtt > modbusToMqttMappings > modbusToMqttMapping > mqttQos

Quality of service level for publishing

Integer 0 - 2

modbusToMqtt > modbusToMqttMappings > modbusToMqttMapping > addressRang > unitId

Unit to access on modbus

Integer

modbusToMqtt > modbusToMqttMappings > modbusToMqttMapping > addressRang > startIdx

Address of the register from where reading should start

Integer

modbusToMqtt > modbusToMqttMappings > modbusToMqttMapping > addressRang > readType

Register type being read from

COILS | DISCRETE_INPUT | INPUT_REGISTERS | HOLDING_REGISTERS

modbusToMqtt > modbusToMqttMappings > modbusToMqttMapping > addressRang > mqttUserProperties > mqttUserProperty > name

Name of a MQTT 5 property to be sent with each message

String

modbusToMqtt > modbusToMqttMappings > modbusToMqttMapping > addressRang > mqttUserProperties > mqttUserProperty > value

Value of a MQTT 5 property to be sent with each message

String

name definition length BOOL boolean

1 bit / 1 register

INT_16

integer

16 bit / 1 register

UINT_16

unsigned integer

16 bit / 1 register

INT_32

integer

32 bit / 2 registers

UINT_32

unsigned integer

32 bit / 2 registers

INT_64

integer (long)

64 bit / 4 registers

FLOAT_32

float

32 bit / 2 registers

FLOAT_64

float (double)

64 bit / 4 registers

UTF_8

utf-8 character

64 bit / 4 registers

Each sample is published as an array with each 16-bit index encoded as an 2 octet decimal value.

OPC UA Adapter

The OPC UA adapter enables connections to OPC UA servers. You can configure the adapter to read from OPC UA server and publish it to an MQTT topic (opcuaToMqtt) or write to an OPC UA server from an MQTT topic (mqttToOpcua).

Both directions require to configure basic connectivity information for OPC UA.

The connection creates subscriptions with the OPC UA server and discovers available nodes on the server.

Example minimal OPC UA adapter configuration (anonymous authentication)

The configuration below shows the basic OPC UA connectivity.

<protocol-adapters>
    <opcua>
        <config>
            <id>opcua</id>
            <overrideUri>false</overrideUri>
            <uri>opc.tcp://opcua-server:4840</uri>
        </config>
    </opcua>
</protocol-adapters>

As next step, you can configure to read an OPC UA nodeId from the server and publish it to an MQTT topic.

OPC UA to MQTT: Northbound

This section describe how to configure a OPC UA to MQTT configuration also called northbound.

HiveMQ Edge 2024.8 introduces the concept of tags. Tags are used to simplify the usage of data from any protocol adapter.
Example full OPC UA adapter configuration
<hivemq>
...
   <protocol-adapters>
        <protocol-adapter>
            <adapterId>simulation-server-2</adapterId>
            <protocolId>opcua</protocolId>
            <config>
                <uri>opc.tcp://CSM1.local:53530/OPCUA/SimulationServer</uri>
                <opcuaToMqtt>
                </opcuaToMqtt>
            </config>
            <northboundMappings>
                <northboundMapping>
                    <tagName>temperature/for/machine_1</tagName>
                    <topic>machine/1/temperature</topic>
                </northboundMapping>
            </northboundMappings>
            </southboundMappings>
            <tags>
                <tag>
                    <name>temperature/for/machine_1</name>
                    <description>This tag is about sensor data</description>
                    <definition>
                        <node>ns=1;i=1004</node>
                    </definition>
                </tag>
            </tags>
        </protocol-adapter>
    </protocol-adapters>
...
</hivemq>

The config defines a connection to an OPC UA server and a northbound mapping. The mapping defines to read data from tag temperature/for/machine_1, which connected to the nodeId ns=1;i=1004. The read tag is published as MQTT message into the topic machine/1/temperature. The tags are defined in the <tags> section.

Example MQTT messages for a northbound connection (OPC UA to MQTT)
{
  "value": 1000
}
Example MQTT message payload resulting from subscribing to a nodeId with a more complex object structure.
{
  "value": {
    "Position_Reached": false,
    "Target_Position": 2700,
    "Increment": 0,
    "Actual_Position": 0,
    "Config": {
      "Ref_Pos": 0,
      "Loop_Value": 0
    }
  }
}

OPC UA to MQTT: Southbound

HiveMQ Edge can write to OPC UA nodes from any MQTT data sources. Mapping an MQTT topic filter to OPC UA data points works like the northbound mapping. The southbound mapping consists of a topic filter that includes a data schema of the MQTT payload and a tag to be written. An example configuration is shown below:

Example OPC UA southbound mapping
<hivemq>
    <protocol-adapters>
        <protocol-adapter>
            <adapterId>simulation-server-2</adapterId>
            <protocolId>opcua</protocolId>
            <config>
                <uri>opc.tcp://CSM1.local:53530/OPCUA/SimulationServer</uri>
                <overrideUri>true</overrideUri>
                <auth>
                    <basic>
                        <username>edge</username>
                        <password>password</password>
                    </basic>
                    <x509>
                        <enabled>true</enabled>
                    </x509>
                </auth>
                <tls>
                    <enabled>true</enabled>
                    <keystore>
                        <path>path/to/keystore</path>
                        <password>keystore-password</password>
                        <privateKeyPassword>private-key-password</privateKeyPassword>
                    </keystore>
                    <truststore>
                        <path>path/to/truststore</path>
                        <password>truststore-password</password>
                    </truststore>
                </tls>
                <security>
                    <policy>BASIC128RSA15</policy>
                </security>
                <opcuaToMqtt>
                    <publishingInterval>12</publishingInterval>
                    <serverQueueSize>13</serverQueueSize>
                </opcuaToMqtt>
            </config>
            </northboundMappings>
            <southboundMappings>
                <southboundMapping>
                    <tagName>ns=1;i=1004</tagName>
                    <topicFilter>data/area1/#</topicFilter>
                    <fromNorthSchema>{}</fromNorthSchema>
                </southboundMapping>
                <southboundMapping>
                    <tagName>ns=2;i=1004</tagName>
                    <topicFilter>data/area2/#</topicFilter>
                    <fromNorthSchema>{}</fromNorthSchema>
                </southboundMapping>
            </southboundMappings>
            <tags>
                <tag>
                    <name>ns=1;i=1004</name>
                    <description>description1</description>
                    <definition>
                        <node>ns=1;i=1004</node>
                    </definition>
                </tag>
                <tag>
                    <name>ns=2;i=1004</name>
                    <description>description2</description>
                    <definition>
                        <node>ns=2;i=1004</node>
                    </definition>
                </tag>
            </tags>
        </protocol-adapter>
    </protocol-adapters>
</hivemq>
Writing to OPC UA Arrays data types is not supported yet.

OPC UA Adapter Properties

Table 6. OPC UA Protocol Adapter Properties (config)
Property Name Default Mandatory Description Format

uri

URI of the OPC-UA server to connect to.

URI

overrideUri

Override the URI provided by the OPC UA server

Boolean

auth

The auth mechanism to connect the OPC UA server

Authentication mechanism More information

tls

no TLS

TLS configuration

Boolean

security > policy

NONE

OPC UA Security Policy to use.

NONE, BASIC128RSA15, BASIC256, BASIC256SHA256, AES128_SHA256_RSAOAEP, AES256_SHA256_RSAPSS.

opcuaToMqtt

Configuration of OPC UA to MQTT (Northbound)

OPC UA Northbound

OPC UA Northbound config details

Table 7. OPC UA to MQTT (Northbound) (opcuaToMqtt)
Property Name Default Mandatory Description Format

publishingInterval

1000

Publishing Interval [ms]

Integer > 0

serverQueueSize

1

Server queue size

Integer > 0

Tag Definitions for OPC UA

The general structure of tags is defined identically for each protocol adapter as described in Tags. The precise definition is different as listed below. In OPC UA, nodeIds are configured to address specific data points.

Example tags definition
<hivemq>
    <protocol-adapters>
        <protocol-adapter>
            <adapterId>...</adapterId>
            <protocolId>opcua</protocolId>
            <config>
              ...
            </config>
            <tags>
                <tag>
                    <name>boiler/temperature</name>
                    <description>Provides the temperature inside the boiler</description>
                    <definition>
                        <node>ns=1;s=Temperature</node>
                    </definition>
                </tag>
            </tags>
        </protocol-adapter>
    </protocol-adapters>
</hivemq>

The definition field is specific for OPC UA and contains the nodeId definition, e.g., ns=1;s=Temperature. Tags are defined over a list of tag-items.

Table 8. Tag definition for OPC UA nodeIds
Property Name Default Mandatory Description Format

definition > node

The nodeId of OPC UA

OPC UA nodeId adressing schema

OPC UA Authentication

HiveMQ Edge supports basic authentication and x509 authentication against OPC UA servers.

OPC UA Authentication Basic

Basic auth example
<opcua>
    <config>
    ...
        <auth>
            <basic>
                <username>edge</username>
                <password>password</password>
            </basic>
        </auth>
    ...
    </config>
</opcua>
OPC UA Authentication X509
To use x509 authentication, the TLS configuration must be set and a keystore must be configured.
X509 auth example
<opcua>
    <config>
    ...
    <auth>
        <x509>
            <enabled>true</enabled>
        </x509>
    </auth>
    ...
    </config>
</opcua>

OPC UA TLS configuration

HiveMQ Edge supports connections to OPC UA servers with TLS and mutual TLS. To utilize mTLS, specify a keystore and enable x509 authentication.

Minimal TLS example using system truststore
<opcua>
    <config>
    ...
        <tls>
            <enabled>true</enabled>
        </tls>
    ...
    </config>
</opcua>
TLS example with mutual TLS and custom truststore
<opcua>
    <config>
    ...
        <tls>
            <enabled>true</enabled>
            <keystore>
                <path>/path/to/my/keystore.jks</path>
                <password>keystore-password</password>
                <private-key-password>key-password</private-key-password>
            </keystore>
            <truststore>
                <path>/path/to/my/truststore.jks</path>
                <password>truststore-password</password>
            </truststore>
        </tls>
    ...
    </config>
</opcua>
Table 9. Properties to configure TLS
Property Name Default Mandatory Description

enabled

false

Defines whether TLS is enabled.

keystore

Keystore that contains the private key and certificate chain for the client certificate.

truststore

System truststore

Truststore to verify the server certificate against.

S7 Adapter

The S7 adapter enables connections to Siemens S7 PLCs. S7 tags and data blocks can be read by the adapter.

The S7 protocol is also using the term tags. Those tags are different from those used in the broader context of HiveMQ Edge. We will refer them in the following as S7 tags.
S7 PUT/GET must be enabled on the PLC (Programmable Logic Controller), otherwise a connection with the S7 adapter is not possible. The setting can be found on your TIA Portal in the General tab, under Protection & SecurityConnection mechanismsPermit access with PUT/GET communication from remote partner.
Example minimal S7 adapter configuration
<hivemq>
    <protocol-adapters>
        <protocol-adapter>
            <adapterId>my-s7-protocol-adapter</adapterId>
            <protocolId>s7</protocolId>
            <config>
                <host>my.s7-device</host>
                <port>102</port>
                <controllerType>S7_1500</controllerType>
            </config>
            <northboundMappings>
                <northboundMapping>
                    <topic>motor/speed</topic>
                    <tagName>motor_speed</tagName>
                </northboundMapping>
            </northboundMappings>
            <tags>
                <tag>
                    <name>motor_speed</name>
                    <description>The speed of the moto</description>
                    <definition>
                        <tagAddress>%ID103</tagAddress>
                        <dataType>DINT</dataType>
                    </definition>
                </tag>
            </tags>
        </protocol-adapter>
    </protocol-adapters>
</hivemq>

S7 Adapter Properties (config)

Table 10. S7 Protocol Adapter properties for config
Property Name Default Mandatory Description Format

host

The host or IPv4/IPv6 of the S7 device.

URI

port

The port to which the adapter connects.

Integer 1-65535

controllerType

The series of the S7 PLC (Programmable Logic Controller).

one of: S7_300, S7_400, S7_1200, S7_1500, LOGO

remoteRack

0

Rack value for the remote main CPU.

Integer

remoteSlot

0

Slot value for the remote main CPU.

Integer

remoteRack

0

Rack value for the remote secondary CPU.

Integer

remoteSlot

0

Slot value for the remote secondary CPU.

Integer

remoteTsap

0

Remote TSAP value. The TSAP (Transport Services Access Point) mechanism is used as a further addressing level in the S7 PLC network. Usually, the value is only required for PLCs from the LOGO series.

Integer

S7 Northbound config

Table 11. OPC UA to MQTT (Northbound) (s7ToMqtt)
Property Name Default Mandatory Description Format

publishChangedDataOnly

true

Specifies whether the adapter only publishes data when a field value change is detected.

Boolean

publishingInterval

1000

Time in milliseconds between samplings.

Integer

maxPollingErrorsBeforeRemoval

10

The number of times the adapter attempts to sample while an error condition is detected.

Integer

Tag Definitions for OPC UA

The general structure of tags is defined identically for each protocol adapter as described in Tags. The precise definition is different as listed below. In OPC UA nodeIds are configured to address specific data points.

Example tags definition
<hivemq>
    <protocol-adapters>
        <protocol-adapter>
            <adapterId>...</adapterId>
            <protocolId>opcua</protocolId>
            <config>
              ...
            </config>
            <tags>
                <tag>
                    <name>boiler/temperature</name>
                    <description>Provides the temperature inside the boiler</description>
                    <definition>
                        <node>ns=1;s=Temperature</node>
                    </definition>
                </tag>
            </tags>
        </protocol-adapter>
    </protocol-adapters>
</hivemq>

The definition field is specific for OPC UA and contains the nodeId definition, e.g., ns=1;s=Temperature. Tags are defined over a list of tag-items.

Table 12. Tag definition for OPC UA nodeIds
Property Name Default Mandatory Description Format

definition > node

The nodeId of OPC UA

OPC UA nodeId adressing schema

S7 Tag Address

The general structure of tags is defined identically for each protocol adapter as described in Tags. The precise definition is different as listed below. In the following the S7 tags addresses are described. The S7 tag address for an S7 variable can be found in TIA Portal.

PLC (Programmable Logic Controllers) Tags

The address for tags can be found in TIA Portal in the Address column of the PLC Tags table . For PLC tags, this value can be used as it is directly in HiveMQ Edge.

a27cd79f e6f6 4632 b949 b7484213a102

If you cannot get the addresses directly from TIA Portal, you can use the following format to construct the address:

Format for bit addresses:

%<Memory-Area-Code><Byte-Offset>.<Bit-Offset>

Format for byte addresses

%<Memory-Area-Code><Memory-Size-Code><Byte-Offset>

Example: %I205.0 or ´ %QB207

Where the Memory-Area-Code is one of I(Inputs), Q(Outputs), D(Direct peripheral access), M(Markers), C(Counter), T(Timer), DB(Data block).

And Memory-Size-Code describes the size of the variable value. The codes are X(1 bit or 8 bytes), B(1 byte), W(2 bytes), D(4 bytes).
For detailed information on which code maps to which type, see S7 Types.

Data blocks

The data block addressing scheme is:

%DB<Data-Block-Number>:<Byte-Offset>.<Bit-Offset>

%DB<Data-Block-Number>:<Byte-Offset>

Example: %DB10:20.0 or %DB10:22

The Data-Block-Number is displayed in the tree view on the left in your TIA Portal, behind the name of your data block, enclosed in [] brackets or on the top of the data block view.

The Byte-Offset (and Bit-Offset) can be found in TIA Portal in the Offset column in the data block view

13030c6c b52d 4112 a461 48961f655cfa
Fixed offsets are only available for variables in data blocks if Optimized block access is turned off.

The setting for optimizing block access can be found in the properties of the data block in TIA Portal.

e06d9b94 ae36 4b51 9a84 2bc7278fd4e2

S7 Types

Type Description Memory size code MQTT payload example Value range

BOOL

1 bit

X

{"value": true}

true/false

BYTE

1 byte unsigned

B

{"value": 255}

0-255

SINT

1 byte signed

B

{"value": -75}

-128-127

USINT

1 byte unsigned

B

{"value": 255}

0-255

INT

2 byte signed

W

{"value": -3450}

-32768-32767

UINT

2 byte unsigned

W

{"value": 3450}

0-65535

DINT

4 byte signed

D

{"value": -3450}

-2147483648-2147483647

UDINT

4 byte unsigned

D

{"value": 123232}

0-4294967295

LINT

8 byte signed

X

{"value": -123232000}

-9223372036854775808-9223372036854775807

ULINT

8 byte unsigned

X

{"value": 123232000}

0-18446744073709551615

WORD

2 byte unsigned

W

{"value": 1024}

0-65535

DWORD

4 byte unsigned

D

{"value": 123456789}

0-4294967295

LWORD

8 byte unsigned

X

{"value": 1234567890000}

0-18446744073709551615

REAL

4 byte floating point signed

D

{"value":123.456789} or {"value":3.4028235E38}

1.4E-45-3.4028235E38

LREAL

8 byte floating point signed

X

{"value":123.456789} or {"value":4.9E-324}

4.9E-324-1.7976931348623157E308

CHAR

1 byte character

B

{"value":"a"}

ascii alphabet

WCHAR

2 byte character

W

{"value":"a"}

unicode alphabet

STRING

ascii string

X

{"value":"abcdefgh"}

ascii alphabet

WSTRING

unicode string

X

{"value":"abcdefgh"}

unicode alphabet

TIME

4 byte signed, millisecond duration

D

{"value":-1234}

-2147483648-2147483647

LTIME

8 byte signed, nanosecond duration

D

{"value":-1234}

-9223372036854775808-9223372036854775807

DATE

Date

X

{"value":"2020-03-12"}

(ISO 8601) "1990-01-01"-"2168-12-31"

TIME_OF_DAY

Time of day milliseconds

X

{"value":"01:23:45.678"}

(ISO 8601) "00:00:00.000"-"23:59:59.999"

LTIME_OF_DAY

Time of day nanoseconds

X

{"value":"01:23:45.678901234"}

(ISO 8601) "00:00:00.000"-"23:59:59.999999999"

DATE_AND_TIME

DateTime milliseconds

X

{"value":"2020-03-12"}

(ISO 8601) 1970-01-01T00:00:00.000-2089-12-31T23:59:59.999

LDATE_AND_TIME

DateTime nanoseconds

X

{"value":"2020-03-12T23:59:59.123456789"}

(ISO 8601) 1970-01-01T00:00:00.000-2089-12-31T23:59:59.999

Table 13. Tag definition for S7 tags (definition)
Property Name Default Mandatory Description Format

tagAddress

The defined address of the tag

String

dataType

The data type

Selection of S7 data types

ADS / TwinCAT Adapter

The ADS adapter enables connections to Beckhoff and other TwinCAT 3 capable PLCs.

Example minimal ADS adapter configuration
<hivemq>
    <protocol-adapters>
        <protocol-adapter>
            <adapterId>my-ads-protocol-adapter</adapterId>
            <protocolId>ads</protocolId>
            <config>
                <host>my.ads-server.com</host>
                <port>1234</port>
                <targetAmsPort>123</targetAmsPort>
                <sourceAmsPort>124</sourceAmsPort>
                <targetAmsNetId>1.2.3.4.5.6</targetAmsNetId>
                <sourceAmsNetId>1.2.3.4.5.7</sourceAmsNetId>
            </config>
            <northboundMappings>
                <northboundMapping>
                    <topic>my/topic</topic>
                    <tagName>tag-name</tagName>
                </northboundMapping>
            </northboundMappings>
            <tags>
                <tag>
                    <name>tag-name</name>
                    <description>description</description>
                    <definition>
                        <tagAddress>123</tagAddress>
                        <dataType>BOOL</dataType>
                    </definition>
                </tag>
            </tags>
        </protocol-adapter>
    </protocol-adapters>
</hivemq>
Example full ADS adapter configuration
<hivemq>
    <protocol-adapters>
        <protocol-adapter>
            <adapterId>my-ads-protocol-adapter</adapterId>
            <protocolId>ads</protocolId>
            <config>
                <host>my.ads-server.com</host>
                <port>1234</port>
                <targetAmsPort>1234</targetAmsPort>
                <sourceAmsPort>12345</sourceAmsPort>
                <targetAmsNetId>1.2.3.4.5.6</targetAmsNetId>
                <sourceAmsNetId>1.2.3.4.5.7</sourceAmsNetId>
                <adsToMqtt>
                    <pollingIntervalMillis>10</pollingIntervalMillis>
                    <maxPollingErrorsBeforeRemoval>9</maxPollingErrorsBeforeRemoval>
                    <publishChangedDataOnly>false</publishChangedDataOnly>
                </adsToMqtt>
            </config>
            <northboundMappings>
                <northboundMapping>
                    <topic>my/topic</topic>
                    <maxQos>1</maxQos>
                    <includeTagNames>true</includeTagNames>
                    <includeTimestamp>true</includeTimestamp>
                    <messageHandlingOptions>MQTTMessagePerSubscription</messageHandlingOptions>
                    <tagName>tag-name</tagName>
                    <mqttUserProperties>
                        <mqttUserProperty>
                            <name>name</name>
                            <value>value1</value>
                        </mqttUserProperty>
                        <mqttUserProperty>
                            <name>name</name>
                            <value>value2</value>
                        </mqttUserProperty>
                    </mqttUserProperties>
                </northboundMapping>
                <northboundMapping>
                    <topic>my/topic/2</topic>
                    <maxQos>1</maxQos>
                    <includeTagNames>true</includeTagNames>
                    <includeTimestamp>true</includeTimestamp>
                    <messageHandlingOptions>MQTTMessagePerSubscription</messageHandlingOptions>
                    <tagName>tag-name</tagName>
                    <mqttUserProperties>
                        <mqttUserProperty>
                            <name>name</name>
                            <value>value1</value>
                        </mqttUserProperty>
                        <mqttUserProperty>
                            <name>name</name>
                            <value>value2</value>
                        </mqttUserProperty>
                    </mqttUserProperties>
                </northboundMapping>
            </northboundMappings>
            <tags>
                <tag>
                    <name>tag-name</name>
                    <description>description</description>
                    <definition>
                        <tagAddress>123</tagAddress>
                        <dataType>WORD</dataType>
                    </definition>
                </tag>
            </tags>
        </protocol-adapter>
    </protocol-adapters>
</hivemq>

ADS Adapter Properties Config

Property Name Default Mandatory Description Format

host

The host or IPv4/iIPv6 of the ModBus device.

URI

port

48898

The port to connect to.

Integer 1-65535

targetAmsNetId

The AMS Net ID of the device to connect to.

Integer 1-65535

targetAmsPort

The AMS port number on the device to connect to.

Integer 1-65535

sourceAmsNetId

The AMS Net ID of HiveMQ Edge.

Integer 1-65535

sourceAmsPort

The local AMS port number HiveMQ Edge uses.

Integer 1-65535

ADS Tag Address

The general structure of tags is defined identically for each protocol adapter as described in Tags. The precise definition is different as listed below. In the following the S7 tags addresses are described. The ADS tag address is the program name followed by the variable name separated by a dot, in the format: <program-name>.<variable-name> .

Example program:

PROGRAM MAIN
VAR
    iCounter          : INT     := 41;
    MiCounter AT %MW2 : INT     := 21;
    QstrText AT %QB20 : STRING  := 'abcdefg';
END_VAR

The variable addresses for the protocol adapter are then:

  • MAIN.iCounter

  • MAIN.MiCounter

  • MAIN.QstrText

ADS Types

Type Description MQTT payload example Value range

BOOL / BIT

1 bit

{"value": true}

true/false

BYTE

1 byte unsigned

{"value": 255}

0-255

SINT

1 byte signed

{"value": -75}

-128-127

USINT

1 byte unsigned

{"value": 255}

0-255

INT

2 byte signed

{"value": -3450}

-32768-32767

UINT

2 byte unsigned

{"value": 3450}

0-65535

DINT

4 byte signed

{"value": -3450}

-2147483648-2147483647

UDINT

4 byte unsigned

{"value": 123232}

0-4294967295

LINT

8 byte signed

{"value": -123232000}

-9223372036854775808-9223372036854775807

ULINT

8 byte unsigned

{"value": 123232000}

0-18446744073709551615

WORD

2 byte unsigned

{"value": 1024}

0-65535

DWORD

4 byte unsigned

{"value": 123456789}

0-4294967295

LWORD

8 byte unsigned

{"value": 1234567890000}

0-18446744073709551615

REAL

4 byte floating point signed

{"value":123.456789} or {"value":3.4028235E38}

1.4E-45-3.4028235E38

LREAL

8 byte floating point signed

{"value":123.456789} or {"value":4.9E-324}

4.9E-324-1.7976931348623157E308

STRING

ascii string

{"value":"abcdefgh"}

ascii alphabet

WSTRING

unicode string

{"value":"abcdefgh"}

unicode alphabet

TIME

4 byte unsigned, millisecond duration, UDINT

{"value":1234}

0-4294967295

LTIME

8 byte unsigned, nanosecond duration, ULINT

{"value":12345}

0-18446744073709551615

DATE

Date, UDINT

{"value":"2020-03-12"}

(ISO 8601) "1990-01-01"-"2168-12-31"

LDATE

Date, ULINT

{"value":"2020-03-12"}

(ISO 8601) "1970-01-01"-"2554-07-21"

TIME_OF_DAY

Time of day milliseconds, UDINT

{"value":"01:23:45.678"}

(ISO 8601) "00:00:00.000"-"23:59:59.999"

LTIME_OF_DAY

Time of day nanoseconds, ULINT

{"value":"01:23:45.678901234"}

(ISO 8601) "00:00:00.000"-"23:59:59.999999999"

DATE_AND_TIME

DateTime milliseconds, UDINT

{"value":"2020-03-12"}

(ISO 8601) 1970-01-01T00:00:00.000-2089-12-31T23:59:59.999

LDATE_AND_TIME

DateTime nanoseconds, ULINT

{"value":"2020-03-12T23:59:59.123456789"}

(ISO 8601) 1970-01-01T00:00:00.000-2554-7-21-23:34:33.709551615

Table 14. Tag definition for ADS tags (definition)
Property Name Default Mandatory Description Format

tagAddress

The defined address of the tag

String

dataType

The data type

Selection of ADS data types

EtherNet/IP Adapter

The EtherNet/IP adapter enables connections to Rockwell / Allen-Bradley PLCs (Programmable Logic Controllers) from the ControLogix and CompactLogix series.

Example minimal EtherNet/IP adapter configuration
<hivemq>
    <protocol-adapters>
        <protocol-adapter>
            <adapterId>my-eip-protocol-adapter</adapterId>
            <protocolId>eip</protocolId>
            <config>
                <port>1234</port>
                <host>my.eip-server.com</host>
            </config>
            <northboundMappings>
                <northboundMapping>
                    <topic>my/topic</topic>
                    <tagName>tag-name</tagName>
                </northboundMapping>
            </northboundMappings>
            <tags>
                <tag>
                    <name>tag-name</name>
                    <description>description</description>
                    <definition>
                        <address>addressy</address>
                        <dataType>BOOL</dataType>
                    </definition>
                </tag>
            </tags>
        </protocol-adapter>
    </protocol-adapters>
</hivemq>
Example full EtherNet/IP adapter configuration
<hivemq>
    <protocol-adapters>
        <protocol-adapter>
            <adapterId>my-eip-protocol-adapter</adapterId>
            <protocolId>eip</protocolId>
            <config>
                <host>my.eip-server.com</host>
                <port>1234</port>
                <backplane>4</backplane>
                <slot>5</slot>
                <eipToMqtt>
                    <pollingIntervalMillis>10</pollingIntervalMillis>
                    <maxPollingErrorsBeforeRemoval>9</maxPollingErrorsBeforeRemoval>
                    <publishChangedDataOnly>false</publishChangedDataOnly>
                </eipToMqtt>
            </config>
            <northboundMappings>
                <northboundMapping>
                    <topic>my/topic</topic>
                    <maxQos>1</maxQos>
                    <includeTagNames>true</includeTagNames>
                    <includeTimestamp>true</includeTimestamp>
                    <messageHandlingOptions>MQTTMessagePerSubscription</messageHandlingOptions>
                    <tagName>tag-name</tagName>
                    <mqttUserProperties>
                        <mqttUserProperty>
                            <name>name</name>
                            <value>value1</value>
                        </mqttUserProperty>
                        <mqttUserProperty>
                            <name>name</name>
                            <value>value2</value>
                        </mqttUserProperty>
                    </mqttUserProperties>
                </northboundMapping>
                <northboundMapping>
                    <topic>my/topic/2</topic>
                    <maxQos>1</maxQos>
                    <includeTagNames>true</includeTagNames>
                    <includeTimestamp>true</includeTimestamp>
                    <messageHandlingOptions>MQTTMessagePerSubscription</messageHandlingOptions>
                    <tagName>tag-name</tagName>
                    <mqttUserProperties>
                        <mqttUserProperty>
                            <name>name</name>
                            <value>value1</value>
                        </mqttUserProperty>
                        <mqttUserProperty>
                            <name>name</name>
                            <value>value2</value>
                        </mqttUserProperty>
                    </mqttUserProperties>
                </northboundMapping>
            </northboundMappings>
            <tags>
                <tag>
                    <name>tag-name</name>
                    <description>description</description>
                    <definition>
                        <address>addressy</address>
                        <dataType>BOOL</dataType>
                    </definition>
                </tag>
            </tags>
        </protocol-adapter>
    </protocol-adapters>
</hivemq>

EtherNet/IP Adapter Properties Config

Property Name Default Mandatory Description Format

host

The host or IPv4/IPv6 of the EtherNet/IP device.

URI

port

48898

The port to connect to.

Integer 1-65535

backplane

1

The ID of the backplane.

Integer 1-65535

slot

0

The ID of the slot.

Integer 1-65535

EtherNet/IP Tag Address

The general structure of tags is defined identically for each protocol adapter as described in Tags. The precise definition is different as listed below. In the following the S7 tags addresses are described. The tag address for EtherNet/IP is the name of the Controller Tag <tag-name> that is shown in Logix/Studio 5000.

040ff166 6984 4d38 881a 35e92ba969bd

Example: at_int_tag

EtherNet/IP Types

Type Description MQTT payload example Value range

BOOL

1 bit

{"value": true}

true/false

SINT

1 byte signed

{"value": -75}

-128-127

USINT

1 byte unsigned

{"value": 255}

0-255

INT

2 byte signed

{"value": -3450}

-32768-32767

UINT

2 byte unsigned

{"value": 3450}

0-65535

DINT

4 byte signed

{"value": -3450}

-2147483648-2147483647

UDINT

4 byte unsigned

{"value": 123232}

0-4294967295

LINT

8 byte signed

{"value": -123232000}

-9223372036854775808-9223372036854775807

ULINT

8 byte unsigned

{"value": 123232000}

0-18446744073709551615

REAL

4 byte floating point signed

{"value":123.456789} or {"value":3.4028235E38}

1.4E-45-3.4028235E38

LREAL

8 byte floating point signed

{"value":123.456789} or {"value":4.9E-324}

4.9E-324-1.7976931348623157E308

STRING

ascii string

{"value":"abcdefgh"}

ascii alphabet

TIME

4 byte unsigned, millisecond duration, UDINT

{"value":1234}

0-4294967295

LTIME

8 byte unsigned, nanosecond duration, ULINT

{"value":12345}

0-18446744073709551615

Table 15. Tag definition for EIP tags (definition)
Property Name Default Mandatory Description Format

tagAddress

The defined address of the tag

String

dataType

The data type

Selection of EIP data types

HTTP(s) Adapter

The HTTP adapter is useful when data points can be gathered via HTTP even when other IoT protocols are not available or other software systems should be integrated. The HTTP adapter polls data from a configurable endpoint and converts it into an MQTT message.

Example HTTP Protocol Adapter Configuration
<hivemq>
    <protocol-adapters>
        <protocol-adapter>
            <adapterId>my-protocol-adapter</adapterId>
            <protocolId>http</protocolId>
            <config>
            </config>
            <southboundMappings>
                <southboundMapping>
                    <tagName>tag2</tagName>
                    <topicFilter>my/#</topicFilter>
                    <fromNorthSchema>{}</fromNorthSchema>
                </southboundMapping>
            </southboundMappings>
            <northboundMappings>
                <northboundMapping>
                    <tagName>tag1</tagName>
                    <topic>my/destination</topic>
                    <maxQos>1</maxQos>
                </northboundMapping>
            </northboundMappings>
            <tags>
                <tag>
                    <name>tag1</name>
                    <description>description1</description>
                    <definition>
                        <url>http://lol1.com</url>
                    </definition>
                </tag>
                <tag>
                    <name>tag2</name>
                    <description>description1</description>
                    <definition>
                        <url>http://lol1.com</url>
                    </definition>
                </tag>
            </tags>
        </protocol-adapter>
    </protocol-adapters>
</hivemq>

HTTP Adapter Properties

Table 16. Parameters for top-level configuration
Property Name Default Mandatory Description Format

allowUntrustedCertificates

false

Defines whether untrusted HTTP sources such as expired certificates can be accepted.

true, false

maxPollingErrorsBeforeRemoval

10

The number of times the adapter attempts to sample while an error condition is detected. If the configured maximum is exceeded, the sampling job ceases to execute until the connection is re-established.

Integer > 0

pollingIntervalMillis

1000

Time in milliseconds that the endpoint is polled.

Integer > 0

url

The URL to the HTTP server for data requests.

URL

destination

The topic to which the response is published.

MQTT topic

id

the unique identifier of the protocol adapter.

String

httpRequestMethod

GET

The method to be used to make the HTTP request.

GET, POST, PUT

httpConnectTimeout

5

The length of time to wait for HTTP response (in seconds).

Integer > 0

httpPublishSuccessStatusCodeOnly

true

Specifies whether to Publish message only when the HTTP code is successful (200 - 299).

true, false

qos

The QoS to be used for publish.

MQTT QoS 0, 1, 2

Table 17. Configuration for HTTP headers
Property Name Default Mandatory Description Format

name

The name of the HTTP header.

String

value

The value of the HTTP header.

String

File Adapter

File adapters add functionality to read files from the file system on which HiveMQ Edge runs. The adapter supports different input formats and makes it possible to read information from systems that cannot communicate via the network or defined APIs.

HiveMQ Data Hub can extract specific information from the content of a file or transform a payload to fit your business needs.

Example configuration to read a file from /tmp/sensor.json.

<hivemq>
    <protocol-adapters>
        <protocol-adapter>
            <adapterId>my-file-protocol-adapter</adapterId>
            <protocolId>file</protocolId>
            <config>
                <fileToMqtt></fileToMqtt>
            </config>
            <northboundMappings>
                <northboundMapping>
                    <topic>my/topic</topic>
                    <tagName>tag1</tagName>
                </northboundMapping>

            </northboundMappings>
            <tags>
                <tag>
                    <name>tag1</name>
                    <description>decsription</description>
                    <definition>
                        <filePath>pathy</filePath>
                        <contentType>BINARY</contentType>
                    </definition>
                </tag>
            </tags>
        </protocol-adapter>
    </protocol-adapters>
</hivemq>

Example

Suppose a file named /tmp/sensor.json has the following example content:

{ "value": "42" }

Create the config as introduced above, the following MQTT payload is generated and shown below:

You can use any MQTT tool that is capable of showing an MQTT topic’s content. In the example, we use mqtt sub -t 'file-input'
{
  "timestamp" : 1730122091809,
  "value" : {
    "value" : "42"
  },
  "tagName" : "value",
  "contentType" : "application/json"
}
Table 18. Tags definition for file adapter
Property Name Default Mandatory Description Format

filePath

The local path to the file to read

Path

contentType

The content type of the file. The following types are supported: BINARY, TEXT_PLAIN, TEXT_JSON, TEXT_XML, and TEXT_CSV

Enum

common configurations

Common configurations

See Common Configurations

Common Configurations

Table 19. List of Common Configurations
Property Name Default Mandatory Description Format

mqttTopic

The topic to which the response is published.

MQTT topic

mqttQos

MQTT Payload QoS

MQTT QoS

includeTagNames

false

Include the name of the Tag

MQTT QoS

includeTimestamp

false

Add a timestamp to the MQTT payload

boolean

mqttUserProperties

List of mqttUserProperty defined over MQTT user properties for Protocol Adapters

publishChangedDataOnly

true

Specifies whether the adapter only publishes data when a field value change is detected. (Not available for all protocol adapters)

Boolean

MQTT User Properties for Protocol Adapters

MQTT User Properties can be added to each MQTT message created out of a Protocol Adapter payload. Any number of User Properties can be created. For more information of MQTT User Properties, read MQTT 5 User Properties.

Table 20. List of properties for MQTT User Properties for Protocol Adapters
Property Name Default Mandatory Description Format

name

Name of the Key of the MQTT User Property

String

value

Name of the Key of the MQTT User Property

String

Contribute a Custom Adapter

The HiveMQ Edge protocol adapter SDK (Java Doc) can be utilized to implement a custom protocol adapter. For a step-by-step tutorial, see How to Build a File-based Protocol Adapter for HiveMQ Edge.