TwinCAT and MQTT – Part 2 JSON messages

In the previous post “TwinCAT and MQTT – Part 1 Getting started” We covered the basics for MQTT in TwinCAT.  Using the Mosquitto broker and two PLC we were quickly able to exchange messages between the PLC, and later on we read the messages with a smartphone too.

In part 1 we published a simple string indicating the room temperature. However in real life we soon want to send more data and parameters in one message. Composing such strings is hard, but decompiling it back to actual data is even harder. Luckily we can make use of one of the world most popular data formats : ‘JSON’. In this post I show how publish and receive complete data structures using JSON.

Read More