Overview

Skill Level: Intermediate

This receipe explains how to configure the MQTT publisher module of the Softing dataFEED edgeGate or the uaGate to send PLC data to the Watson IoT.

Ingredients

You need at least one of this two kind of PLCs as data source:

  • A PLC or other automation device which uses the ModbusTCP protocol
  • A Siemens S7 (300, 400, 1200, 1500 series)

You need at least one of this Softing gateway devices:

The dataFEED edgeGate or uaGate should be already configured to connect to the PLC and have access to the data to publish into the Watson IoT.

Step-by-step

  1. Register your Devices and Gateway in Watson IoT Platform

    Carry out the steps in this recipie to register your device(s) in IBM Watson IoT Platform then perform the following steps to register your gateway.

     

    register-device1

    1. On the Devices page, click the Add Device button.
    2. Click the Create device type button.

      1

    3. Click the Create device type button.

      2

    4. Enter a name and description for the type of device that you are registering, then click Next.

      3

    5. In this step a template can be created that automatically assigns a predefined set of parameters for each newly created device of this device type. Change settings as needed and then click on “Next”.

      4

    6. Click through and add extra metadata in JSON format if needed, then click Create.

      6

    7. You will now see your gateway type automatically selected, click Next.

      7

    8. Optionally: Add any additional information about the specific gateway on the Add Device page, then click Next.

      8

    9. Optionaly: Add any extra JSON metadata here, then click Next.
    10. You can now decide how you want to generate the gateways authentication token, if you leave the field blank, one will be generated for you, else type the token into the field then click Next.

      10

    11. Confirm the gateway configuration, then click Next.

      11

    12. You will now see the generated configuration for the gateway, it’s important that you copy and save the information shown to you, expeically the Authentication token if you did not pre-define it as this is the only oppertunity to save it.

      12

  2. Configure MQTT Broker connection from your dataFEED edgeGate or uaGate device to Watson IoT

    • Connect with a browser to the configuration web pages of the device.
    • Login as administrator or itadmin.
    • Navigate to the MQTT Broker configuration page, as in the screenshot below:

      watson-edgate-mqtt1

    • Insert the hostname of the Watson IoT with your Organisation-Id in the beginning, followed by .messaging.internetofthings.ibmcloud.com
      In this example the hostname is l24utt.messaging.internetofthings.ibmcloud.com
    • Insert the port: For unsecure tcp connection insert 1883. For secure ssl/tls connection insert 8883.
    • Insert the MQTT client-ID:

      For the IBM Bluemix cloud the Client-ID is composed as follows:

      d:<Organisation-ID>:<Device type>:<Device-ID>

      The corresponding values for each parameter can be seen in the last step of the IBM Watson IoT configuration. Please use the values that match your configuration of the IBM Watson IoT.

      In this example the values are

      Organisation-ID: l24utt

      Device type: edgeGate

      Device-ID: edgeGate004f
      and that results in the below Client-Id

      d:l24utt:edgeGate:edgeGate004f

    • Choose Authentication type “Username and password”.
    • Insert user name “use-token-auth”
    • Insert the password, which you have hopefully copied in the last step of the device registration above. Otherwise you need to delete and reregister your device for Watson IoT.
    • Finally use the “Save” button to update the configuration.
  3. MQTT Topic configuration

    Navigate to the MQTT Topic configuration page, as shown in the image below.

    watson-edgate-mqtt2

    • Set the MQTT Root Topic to: “iot-2/evt”
    • Select flattened PLC hierarchy.
    • Set the MQTT Suffix Topic to “/fmt/json”.
    • Set the MQTT QoS to 0.
    • Disable MQTT retain.
    • Optionally enable “Publish on value change” to publish only value updates.
    • Set the minimum polling interval to a reasonable value. If the checkbox “Publish on value change” above is enabled, 0 may be a valid choice. But even in this case, it may cause an high amount of expensive data traffic.
    • Set the publish format to:

      { “d” : {“timestamp”:”@TIME@”,

      “value”:”@VALUE@”,

      “quality”:”@QUALITY@”,

      “source”:”@ITEM@”

      }}

      The double quotes (“) are requiered. So that the published data is a valid json string.

    • Finally use the “Save” button to update the configuration.
  4. MQTT Topic Selection

    Navigate to the MQTT Topic Selection, as shown in the image below.

    watson-edgate-mqtt3

    • Select the PLC data which you want to send to Watson IoT.
    • Use the “Save” button to update the configuration.
    • Finally use the “Click here to apply all settings” button.
  5. Verify

    Navigate to the gateway status page, as shown in the image below.

    watson-edgate-mqtt4

    The gateway status page above indicates, that the connection to the MQTT broker of Watson IoT has been successfully established.

    To verify, that Watson IoT receives the PLC data, open the device page within Watson IoT:

    watson-edgate-mqtt5

3 comments on"Send PLC data via Softing dataFEED edgeGate or uaGate to Watson IoT"

  1. Hi,

    thanks for blog,
    I get the status “disconnected” and “failed to establich MQTT connection”. I have but a proxy. How can I set the proxy-setting in IBM Bluemix IoT platform?

  2. thank you JuergenKosel for good plog.
    Can this recipe work with plc LS (xec-dr28ua )type knowing that it has embedded web server.

Join The Discussion