MQTT Client

MQTT (Message Queuing Telemetry Transport) is an open, lightweight, publish-subscribe network protocol that transports messages between devices. The protocol usually runs over TCP/IP and is designed for connections with remote locations where a ‘small code footprint’ is required or the network bandwidth is limited.

The MQTT protocol defines two types of network entities: a message broker and a number of clients. An MQTT broker is a server that receives all messages from the clients and then routes the messages to the appropriate destination clients. An MQTT client is any device that connects to an MQTT broker over a network.

Brodersen RTUs use MQTT Client protocol to interact with field devices and MQTT brokers within IIOT (Industrial Internet of Things) networks.

MQTT Publish-Subscribe

Overview – creating an MQTT client application

The slideshow below shows how to create a MQTT client application in a Brodersen RTU. 

Note: preliminary testing has proven that the RTU is also able to run an emmbedded MQTT broker application.

1 - create an example MQTT Client Project
Add a new project in WorkSuite, then add the MQTT Client driver and add a Master Port (comms channel) and enter the IP address of the broker.
2 - create variables to publish (send)
Associate the variables that need to be sent to the broker as topics. In this example, some of the RTUs DI channels will be sent to the broker on 'change of state'.
3 - created subscribed variables (received)
Associate the variables that need to be received. In this example, some of the RTUs DO channels have been used (with 'v' defined as their value field-name').
4 - connect to the broker
Check the RTU is connected to the MQTT broker. Change the state of the DI channels and observe that messages are published/sent. Check the RTU is subscribed to the broker by sending output commands eg. "{\"v\":1}" -t "DO/Output1" -q 1 (turns ch1 ON).
5 - additional functionality
MQTT function blocks
Previous
Next

The example application above has fixed Client ID and topic names that are embedded within the logic application.  In large systems, multiple RTU sites may have a common/similar logic application and need each site to be uniquely identified.  The Client ID and/or group and variable topic names can be updated from logic using the RTU32_MQTT function blocks shown below.  These function blocks allow alternate names to be ‘passed’ to the driver from the RTU logic application.  Typically the new names/values will be read from a text file and invoked at the next RTU restart.

Demo program and app note links – soon…