Connecting a Device with Watson

Everything that can be automated will be automated -Robert Cannon - Internet Law and Policy Expert

MQTTBox

MQTTBox is a handy application for the creation and testing of the MQTT protocol. What the MQTTBox allows is connecting to MQTT brokers and performing a variety of sufficiently comprehensive tests for them and other MQTT devices to aid in the development of IoT systems. You'll be using MQTTBox in the following exercise for connecting a simulated IoT machine.

Connecting a Device

The tutorial below will act as a step-by-step guide for you on how to create a simulated device and connect it with IBM Watson while using the MQTT protocol.

The opportunity we have is to build a secure, intelligent platform that solves some of the world’s greatest problems at scale. That’s what’s possible with hundreds of billions of connections and the capabilities that we can deliver together. - Chuck Robbins, Chairman & CEO, Cisco

Connecting a Device With Watson

Step 1.

Set Your IBM Watson Security Setting

For this exercise to work, you need to allow data connections without the Transport Layer Security (TLS) protocol. This is done to allow unencrypted messages.

Please note that working without encryption means that third parties can see the information being sent in the network messages when intercepting them. NEVER include sensitive information in unencrypted messages!

Navigate to your setting on IBM Watson through the left side menu by first clicking 'Security', then 'Connection Security', and then change the Default Rule's 'Connection Security' to 'TLS Optional'. Click 'OK' on the warning popup.

Step 2.

Download and Install MQTTBox

In this exercise, you will be using the Google Chrome browser extension of MQTTBox which you can get by following this link. You can also do a search on Chrome Web Store or directly on Google. You should be able to find the MQTTBox extension using the search term 'Browser Extension MQTT'. Additionally, MQTTBox can also be found online from Microsoft Store.

Install the application.

Step 3.

Create the MQTT Client

Once you have the MQTTBox installed open the application. Click on the 'Create MQTT Client' button.

Step 4.

Setup the MQTT Client

On MQTTBox fill in the fields accordingly as described below.

MQTT Client Name

  • Input 'AWatsonTest' This can be virtually anything but do choose an immediately recognizable client name.

Protocol

  • Choose 'mqtt / tcp'

Username

  • Input 'use-token-auth' You will use the authentication token for connecting.

MQTT Client Id

  • Input 'd::A_MKR1000:F3AC' where is replaced with your unique id.

Your unique id can be found from IBM Watson's URL. Use the device type and id from the last exercises. Please also note the ids are separated by colons.

Append timestamp to MQTT client id?

  • Toggle off

Timestamping helps prevent attempts to connect to the broker with another client with the same name as another, which should not be an issue during this exercise.

Host

  • Input '.messaging.internetofthings.ibmcloud.com' where is replaced with your unique id.

This is the domain you'll be connecting the client to. Remember to add the 'messaging' part.

Password

  • Input the device's authentication token.

You should have it written down and saved, as it cannot be retrieved later after it has been given to you.

Step 5.

Send a Message to IBM Watson

After filling all the fields in the previous step hit the 'Save' button. You should see the client connecting to IBM Watson.

On MQTTBox fill in the following fields and send the message by pressing 'Publish'.

Topic to publish

  • Input 'iot-2/evt/test/fmt/json'

The last part defines that the message will use the JSON format.

Payload Type

  • Choose 'Strings / JSON / XML / Characters'

Payload

  • Input '{"VariableIntroF3AC":"Year","VariableValueF3AC":"2020"}'

The message is in JSON format. It contains the current year as a string.

Well Done!

You have set up an MQTT client that listens to your device. You can now move on to the next exercise!

TEHTÄVÄ