Skip to content

How to connect your device to IBM Watson Cloud Platform using TapNLink IoTize Primer

Introduction

IoT platforms provide many integrated services and infrastructures like data storage, connectivity, display, control etc. Hence, they reduce the amount of investment required to deploy IoT solutions and this is one of the main reasons behind some of the most successful IoT solutions around. IBM Watson IoT platform is an industry grade IoT platform frequently used by big industries to store and analyze the data gathered from IoT devices.
TapNLink could be used as a facilitator for connecting your device to IBM Watson IoT Platform. In this tutorial we will setup an IBM Watson account, send 'Sensor Demo' data to it, and visualize this data using the platform's tools.

IBM Watson integration
IBM Watson Architecture

Prerequisites

  • TapNLink Primer WiFi Evaluation Kit: this kit allows IoT designers to evaluate all the advantages of IoTize TapNLink products for building a connected electronic system. You can purchase a TapNLink Primer Evaluation Kit from Digikey.

  • IoTize Studio: the PC-based configuration software that configures the TapNLink Primer to communicate with IBM Watson IoT Platform. You can download and install the software from IoTize website.

Step1: Setup your IBM Watson IoT Platform account

The first step is to create an IBM Cloud account: https://cloud.ibm.com/.

Then create an IBM Watson IoT Platform, by going to "Create resource" on the IBM Cloud Dashboard and selecting the Internet of Things platform.

IBM Cloud Account
IBM Watson IoT

Step2: Register your device on your IoT Platform

In this step we will create a device twin in Watson IoT Platform service that represents your physical device.

Watson IoT Platform service includes a device twin feature. This cloud-based digital representation of your device is connected to Watson IoT Platform service. Once it is defined and instantiated, the device twin provides a consistent means of interacting with your device from the IoT hub.

  • Within your IBM Watson IoT Platform, select Devices tab and click on Add Device button.
Watson Io Platform Devices
  • Fill in the device details, the DeviceID will be a unique identifier for your device. You can use the DeviceType to group your devices.
Device Information
  • You may provide additional information about your device but it is not mandatory. Select the security tab to set up your device authentication token. You can either choose an auto-generate token or provide your own authentication token. It is very important that you keep a note of your token when it appears on the summary screen, as when you proceed past the summary stage, the token will not appear again. You will need to provide the information displayed on the summary page when configuring your TapNLink to communicate with Watson IoT Platform.
    Device Twin summary

The STM32 Blue Pill board that is included in the TapNLink Primer Evaluation Kit is pre-programmed with the STM32_Sensor application which demonstrates a few simple features like blinking the LED, measuring the internal temperature and voltage etc. In this guide, we will configure TapNLink to send some information to Watson IoT Platform.

Launch IoTize Studio and open sensor_demo.iotz config file installed in the Sensors_STM32_Demo subdirectory of the installed examples.

Select IoT Platform and setup the configuration:

  • Select IoT Generic
  • Minimal period for Cloud Transmission: frequency (in seconds) of the Twin Status Update sent to the platform.
  • Cloud Profile: A specific profile to control access privileges of the connected 'IoT Platform'.
  • Device to Cloud Connectivity: Provide the previously created Device Twin information to enable TapNLink to connect directly to your Watson IoT Platform.
    • Host name:< OrganizationID >.messaging.internetofthings.ibmcloud.com (edited)
    • Service name/Port: 1883
    • ClientID: d:< OrganizationID >:< DeviceType >:< DeviceID >
    • Username: use-token-auth
    • Password: < yourDeviceToken >

The Data sent to IBM Watson IoT Platform corresponds to the datalog variables' values. To select a Variable to be included in the datalog, select its Bundle container and setup the corresponding Datalog Period. To remove a Bundle from the datalog list, set its Datalog Period to 0.

Set Tap | Store variable information to Yes.

Set External (Wireless) Communication | WiFi:

  • Network mode to 'Network(Station)'
  • SSID to your WiFi network
  • WEP key to your WiFi network's security key,
  • MQTT Communication Relay to No (if Yes, you must use java machine).

Click on the "Configure" button to re-configure TapNLink, then use Test|Reboot Tap to retart TapNLink. Now TapNLink will dynamically connect to your IBM Watson IoT Platform and update your registered device twin with the datalog information you set during this configuration.

Step5: Display Sensor_0000B data in your Watson IoT Dashboard

TapNLink is now configured and running. Every 60 seconds it will send the values of the selected variables. We will now setup a gauge to visualize the values of the logged "Temperature" directly from Watson IoT Platform.

To build a Custom Dashboard for your IoT device, go to your Watson IoT Platform and select 'Boards' .

  • Click Add New Board to create a new board for displaying Sensor_000B data. Setup this new Board to be your landing page.
Dashboard
  • Once the board is created, we will add a Gauge Card to the board to display the current Temperature data sent from your device.
Card
  • As TapNLink is continuously sending a status message to the platform, you can select status from the Event field. Once this type of message is selected you can click on the Property field to list the available values. Select Temp from this list. Change the Type to Number and select °C as Unit.
Card
  • Setup the other settings with a 'Gauge' and a color for your card then click Submit.
Card

Et Voilà! The Temperature gauge displays the reported Temperature from Sensor_0000B. The value of the gauge will be refreshed every 60 seconds according to the way we configured TapNLink.

To go further