MQTT is an OASIS standard messaging protocol for the Internet of Things (IoT).
more about MQTT see here.
This IO Connection is node-based, this worked with “MQTT Topic” nodes for receiving the data packages and “MQTT Puplish” to send data packages within the board.
MQTT IO Connection
Name | Description |
---|---|
Server Ip | Is the IP address of the MQTT server (broker). |
Mqtt port | communication port of the MQTT server (broker) |
Interface | This is the IP address of the local network interface (NIC) which should be used for this connection. |
Client ID | This is the client identifyer for this IO Connection which will be used to subscripe to data packages on the MQTT server (broker) |
Status | The feedback of the server (broker) |
connected | boolean for connection status |
Username | Username wich can be used for an authentication |
Password | password wich can be used for an authentication |
MQTT topic subscribe node
Name | Description |
---|---|
Topic | a string (path) that the server (broker) used to seperate the data packages for each connected client. |
Qos | QoS level |
Value | returns the values from the seperatet data package (broker) |
Topic:
Topics is an UTF-8 string that the broker uses to filter messages.
The topic consists of one or more levels.
Each level is separated with a slash.
mainstage/downstage/left/sensor
Single Level (+):
A single level wildcard replaces one topic level by using a “+”.
mainstage/downstage/+/sensor
Example replys:
mainstage/downstage/left/sensor
mainstage/downstage/right/sensor
mainstage/downstage/center/sensor
left, right, center will be replaced with the “+” and replys the sensor value.
The following will not match:
mainstage/downstage/left/brightness
because “brightness” dosn´t matched with “sensor”.
mainstage/upstage/left/sensor
because “upstage” dosn´t matched with “downstage”.
mainstage/downstage/left/corner/sensor
because there is one more topic level “corner” before “sensor” could be matched.
Multi Level (#):
A multi level wildcard replaces many topic levels by using a “#”.
The “#” must be placed as last character.
mainstage/downstage/#
Example replys:
mainstage/downstage/left/sensor
mainstage/downstage/right/brightness
mainstage/downstage/sensor
All topics after “downstage” will be a valid result.
The following will not match:
mainstage/upstage/left/brightness
because “upstage” dosn´t matched with “downstage”.
Best practices
- never use a leading slash
- never use spaces in a topic
- Keep the topic short and concise
- Use only ASCII characters, avoid non printable characters
- Don’t subscribe only to #
- Use specific topics, not general ones
MQTT Puplish node
Name | Description |
---|---|
Topic | a string (path) to write data to the server (broker). |
Value | value which will write to the server (broker) |
example use of puplishing simple data
To send one simple value to the server (broker) link the desired value to the MQTT puphlish node.
select the node and define the topic (path) where the data should be “stored” on the server (broker).
example use of subscribe to simple data
To subscribe to data from the server (broker) define the topic (path) where the data is “stored”.
example use of subscribe to JSON data
MQTT can also handle JSON formated string structures.
You can use a JSON extract node to access subparameter of the JSON string.
More about the JSON extract node see here.