Documentation
Configuration Example for an eNetCube

In order to connect an eNetCube device to a MQTT broker, the broker has to be installed and configured first. For testing purposes we use the mosquitto v2.0.14 an a local windows PC.

The test configuration for mosquitto broker
listener 1883
allow_anonymous true

The first line defines a listener on the port 1883.
The second line allows connections without any authentication.
For security reasons this configuration should not be used in a network which could be compromised, since anybody and anything could connect to the broker and access/change the data. For more security a password file can be used.

Starting the broker with the config file we are getting the following output:

> .\mosquitto.exe -v -c .\mosquitto.conf
1666685128: mosquitto version 2.0.14 starting
1666685128: Config loaded from .\mosquitto.conf.
1666685128: Opening ipv6 listen socket on port 1883.
1666685128: Opening ipv4 listen socket on port 1883.
1666685128: mosquitto version 2.0.14 running

The next step is to configure the eNetCube device to connect to the broker. This can be done on eNetCube's homepage under Settings tab.

eNetCube configuration
  • The root topic can be set to anything.
  • We have to enable the the MQTT client.
  • The address is the address of the mosquitto broker/the windows PC.
  • The port is the port defined in the mosquitto configuration.
  • The keepalive value can be set according to the use. 60 seconds is the default.
  • Username and password can be ommited, since we do not use any authentication in this test.

Clicking on the "set" Button, we should immidiately see output from the mosquitto broker

mosquitto broker output

Using wireshark the messages can be examined more closely.

wireshark output

As we can see, the eNetCube is publishing all it's messages to "myroottopic/enetcube-170a97".

setting a digital output (relay) of the eNetCube

The device used here is an eNetCube-01-01-01. Its main IOs are two relays. In order to switch one relay on/off, we need to connect to the broker first.

For that we use the free tool "MQTT Explorer".

connecting to broker with MQTT Explorer

We set the address, port etc. just like in the eNetCube configuration. After clicking on "connect" we should see a tree view of all the retained messages on the broker.

treeview in the MQTT Explorer

The node for Relay1 is located under "myroottopic/enetcube-170a97/6".
As we can see the property "pin" is currently "false" and it is settable (the $settable attribute under "pin"). This means, the eNetCube listens to the topic "myroottopic/enetcube-170a97/6/pin/set", and will switch the pin if the correct data is sent to it.

On the right side of the MQTT Explorer we can publish messages. There we enter the topic "myroottopic/enetcube-170a97/6/pin/set" and as data we send "true" (without the quotes).

publishing data with MQTT Explorer

Clicking on publish will switch the relay1 from off to on. After switching the relay, the device will publish the new state to the "myroottopic/enetcube-170a97/6/pin" topic.

mosquitto output while setting relay

In wireshark we also see the messages

wireshark output while setting relay

Note, that in wireshark, we only see the communication between broker and the eNetCube. The communication between the MQTT Explorer and the broker is not visible in this image.