In this step-by-step guide we show how to connect a data source to the IoT platform from IBM via MQTT using the OPC router as MQTT client.

The IBM Watson-Internet of Things platform is IBM’s IoT solution in the Watson system. Devices can be created in the IoT platform. The devices are sent and assigned current data via MQTT. With its various plug-ins for connecting subsystems, the OPC Router is the ideal data provider for devices of the Watson IoT platform. Watson serves as MQTT Broker, which is connected with the MQTT Client Plug-in of the OPC Router.

Connection OPC Router - IBM Watson

MQTT connection of the IBM Watson IoT platform

The connection takes place in following steps, which we explain in detail below.

  1. Setup of the IoT platform in IBM Watson
  2. Configuration of the device
  3. Configuration of the MQTT Client

Setup of the IoT platform

  1. Log in to the IBM Watson interface and navigate to the “Dashboard”. Then click “Create” to create a resource:IBM IoT Console Dashboard
  2. Search in the library for “label:lite iot” to find the “Internet of Things Platform”. Then select and create:IBM IoT Watson create Ressource
  3. Name (1) and create (2) the newly created IoT platform:IBM IoT Watson Ressource Name
  4. Start the IoT platform afterwards:IBM IoT Watson Ressource Start

Creating a Device

1. After starting the platform, the device overview opens automatically. Select “Create a device” here:

IBM IoT Watson Create Device

2. The new device must be named in the next step. First name the type (1), then the device itself (2) and then continue (3).

IBM IoT Device Name

3. In the next step, meta data for the device can be maintained. It is optional. Continue with “Next”:

IBM IoT Device Meta Data

4. In the following security settings, the default settings can be accepted and continued with “Next”:

IBM IoT Watson Device Security

5. In the last step, the data are summarized and the device can be created with “Finish”:

IBM IoT Watson Finish Device

6. The created device is displayed with its access data for MQTT. These are important for the following MQTT client configuration. Here you can find the organization ID (1), the assigned type name (2), the device ID (3) and the authentication token (4):

IBM IoT Watson Device Information

Configuration of the MQTT Client

In the MQTT Client the device information must be transferred to the MQTT connection configuration. In the OPC Router (other clients are comparable) the data is used as follows:

Broker connection: The organization ID (here 7nahdt) becomes together with “.messaging.internetofthings.ibmcloud.com” the broker connection address.

Client ID: The Client ID consists of Organization ID (1), Device Type (2) and Device ID (3). the format is “d:<Device-Type>:<Device-ID>”.

Username: The fixed string “use-token-auth” (4) is used as username to indicate that a token is being used.

Password: The password is the authentication token (5) specified in the device information.

OPC Router IBM Watson MQTT Configuration

Example: Temperature transmission to the IoT platform with the OPC Router

In this example, temperature acquisition data is loaded from an SQL database and formatted as JSON and sent to the configured IBM Watson IoT device. The MQTT client integrated in the Watson IoT console displays the received data.

OPC Router IBM Watson Connection
IBM IoT Watson Client

Connect IBM Watson IoT Platform via Drag & Drop!

Connect your production systems graphically with the IBM Watson IoT platform via MQTT with the OPC Router

Request your download and test the MQTT connection