Overview

Skill Level: Any Skill Level

Makers, manufacturers and vendors of things Developers keen to understand how connect a thing

Ingredients

A "thing" to connect to the cloud

Step-by-step

  1. Introduction

    By 2020 analysts predict that many billions of things will be connected to the internet. Things come in all shapes and sizes from tiny sensors monitoring flood plains sending a few bytes of data to jet engines that generate gigabytes of data and a whole plethora of things in between. The tutorial guides you through approaches for connecting the silicon or “thing” to the Bluemix cloud using theIBM Watson IoT service. Once connected data can flow in both directions enabling powerful IoT solutions to be created.

  2. The Basics

    Internet of Things is a Bluemix micro service that acts as the connectivity point for “things” to connect to the cloud. On one side devices connect to the service and send data and on the other side Bluemix applications connect and consume the data from the devices. The tutorial focuses on how to get a device connected to Watson IoT and to flow data both from the device to the cloud and from the cloud to the device.

    For an introduction and demonstration of Watson IoT head to the Bluemix Internet of Things solution page here

    There are three stages to get a thing connected :-

    1. Connect and send data to the IBM Watson IoT Platform Quickstart service

      The quickstart service is a public sandbox instance of Watson IoT that runs 24 hours a day. It is be used to test device connectivity and to visualise data flowing from the device. With quickstart a device can be connected without creating an account in Bluemix

    2. Connect and send data to your own Watson IoT Service

      Quickstart enables a device to be quickly connected but with limited security. Once basic connectivity has been proven create your own Watson IoT service and connect the thing to it. Using your own instance of Watson IoT enables connectivity from the device to the cloud to be secured and access to both the device and data from the device to be controlled.

      To create your own Watson IoT instance you must register for an account on Bluemix. There is a 30 day trial period where access is provided to all features of Bluemix. Each micro service in the Bluemix catalog offers a free tier. The free tier still operates once the trial period expires. If the free tier is exceeded then a pay for what you use model is used. In the case of the Watson IoT service 20 active devices can connect for free and transfer upto 100Mb of data per month. If that threshold is reached then the monthly bill increases incrementally as more devices are connected and more data flows.

      For a device to connect to your own Watson IoT service it must be registered to the service. Devices can be registered from the Watson IoT console or programmatically. This is covered in recipe https://developer.ibm.com/recipes/tutorials/how-to-register-devices-in-ibm-iot-foundation/

    3. Send commands to the thing
      With the thing connected and data flowing to the cloud the final stage is to enable the thing to receive commands sent from the cloud. This step is optional and dependant on the “thing” supporting the ability to receive data such as control commands.
  3. Is the “Thing” already connected?

    DeveloperWorks Recipes is a site that among other things contains a rich set of tutorials and recipes for connecting things to Watson IoT. A good starting point is to use the Recipes search facilty to see if there is a guide on how to connect your “thing”. To stand a good chance of finding a tutorial try search criteria including the device type or manufacturer. If the search turns up trumps head off to the tutorial and away you go.

  4. Utilise a Programming Guide

    If no tutorial exists there are a set of programming guides and libraries in a variety of programming languagues to help connect your “thing”. Head to the IBM Watson IoT Platform documentation site here and look for a programming guide that is suited to your “thing”. Most of the guides provide:-

    • A library and API suited to devices that enables devices to connect, flow data and receive commands.
    • Documentation on how to use the API
    • Sample programs
    • All the neccessary code and documentation to implement the 3 stages descibed in the Basics section above

    Once the ability to connect is in place first try the Quickstart service, a public sandbox instance of Watson IoT before testing with you own Watson IoT organisation

    Once your “thing” is connected and working with Watson IoT why not help others by creating / remixing a tutorial for your “thing” and publishing it on the Recipe site? One last thing, if you are a manufacturer or vendor of things consider joining the IBM partner program PartnerWorld to help spread the word about the “thing”.

  5. Back to raw building blocks

    In the unlucky event that a turorial does not exist and a programming guide cannot be found it is back to basics. Devices connect to the Watson IoT service using the MQTT protocol. MQTT is an open standard protocol designed to connect anything from small constrained devices upwards. Once an MQTT connection is established events including data and commands can be send efficiently over many network types. There are a set of rules for how to use MQTT to connect to the Watson IoT service to send data and to receive commands. These rules can be found in the MQTT section of the IBM Watson IoT Platform documentation site here

    MQTT is a protocol with a a large ecosystem. Within the ecosystem there are wide variety of MQTT programming libraries designed for devices. A good source of MQTT programming libraries (clients) can be found in the Eclipse Paho project here. Libraries include (but not limited to) a tiny footprint MQTT client that is designed for portability to multiple systems to more main stream JavaScript and Java clients. If a suitable MQTT client cannot be found then head to the software section of mqtt.org here

    Using a combination of an MQTT client and the MQTT rules for working with Watson IoT you can now develop the client side code to connect your thing. A good test is to first connect to Quickstart service, a public sandbox instance of Watson IoT before testing with you own Watson IoT organisation.

    Once your “thing” is connected and working with Watson IoT why not help others by creating / remixing a tutorial for your “thing” and publishing it on the Recipe site? One last thing, if you are a manufacturer or vendor of things consider joining the IBM partner program PartnerWorld to help spread the word about the “thing”.

  6. If all else fails

    Not having much luck then head to the “Internet of Things” question and answer site here. When posting a question make sure it the IoT tag is used

Expected Outcome

  • Knowledge of how to get the "thing" connected to the cloud
  • A connected "thing"
  • Optionally a new Remix tutorial

2 comments on"How to Connect a Device to the Cloud"

  1. Fantastic very helpful!

  2. The Link ( in the MQTT section of the IBM Watson IoT Platform documentation site here) mentioned in the document is broken

Join The Discussion