Samples
The following samples illustrate the communication with an MQTT broker. Messages are sent and received.
There are two different implementation options, which can be chosen based on purely subjective criteria. The two options are compared in the first two samples.
Overview
Sample | Link | Description |
---|---|---|
1 | MQTT communication based on a messages queue | |
2 | MQTT communication based on a callback method | |
3 | MQTT communication via a secure TLS connection and PSK (PreSharedKey) | |
4 | MQTT communication via a secure TLS connection and CA (certificate authority) certificate | |
5 | MQTT communication with AWS IoT | |
6 | MQTT communication with the Microsoft Azure IoT Hub | |
7 | MQTT communication with IBM Watson IoT | |
8 | MQTT communication with the ThingSpeak IoT platform from MathWorks | |
9 | MQTTv5 communication based on a messages queue | |
10 | Demonstrates the use of LastWill in interaction with the MQTTv5 function blocks. | |
11 | Demonstrates the request/response mechanism of MQTTv5, as well as the handling of UserProperties and CorrelationData | |
12 | Demonstrates the use of user properties, which are part of MQTTv5. | |
13 | Contains various samples demonstrating the use of the JSON/XML parsers from the PLC library Tc3_JsonXml. |
Downloads
Sample code and configurations for this product can be obtained from the corresponding repository on GitHub: https://www.github.com/Beckhoff/TF6701_Samples. There you have the option to clone the repository or download a ZIP file containing the sample.

- IotMqttSampleUsingQueue
- IotMqttSampleUsingCallback
- IotMqttSampleTlsPsk
- IotMqttSampleTlsCa
- IotMqttSampleAwsIoT
- IotMqttSampleAzureIotHub
- IotMqttSampleBoschIoT
- IotMqttSampleIbmWatsonIoT
- IotMqttSampleMathworksThingspeak
- IotMqttSampleAzureIotHubDeviceTwin
- IotMqttv5Sample
- IotMqttv5LastWillSample
- IotMqttv5ReqResSample
- IotMqttv5UserPropsSample
- JsonXmlSamples