Contents


Overview

Skill Level: Any Skill Level

Familiarity with Watson IoT Platform

Getting Started!IBM Bluemix is a great place to begin with if you are planning on implementing the internet of things. You can make your application on this platform and bind it to some services. The services can not only be used by the run-time applications on Bluemix but also can be accessed by programs running […]

Ingredients

1. You need to register on IBM Bluemix.

2. Basic knowledge of MQTT, Spark and Scala programming.

3. Familiar with Watson IoT Platform

 

Step-by-step

  1. Getting Started!

    IBM Bluemix is a great place to begin with if you are planning on implementing the internet of things. You can make your application on this platform and bind it to some services. The services can not only be used by the run-time applications on Bluemix but also can be accessed by programs running on remote machines.

    I will be using a Spark service that will run the Scala Notebook file that will publish sample message data to a sample Watson IoT Platform service that has already been created.

    Below is the link to the Spark Scala Watson IoT Platoform Publisher.ipynb file you will use for this tutorial.

    Download the file using the link below and place it on your desktop where you can use it later in the tutorial.

    https://ibm.box.com/s/kp31ym27wrvf9a27klx62juykfn7lhq9

     

    Here is what should already be completed before starting this tutorial:

    1. Should already have a Bluemix Account

     

    Assuming that you have registered and are logged into IBM Bluemix, you will see a page similar to this:

    Screen-Shot-2016-12-07-at-4.22.28-PM

     

    First I will add the Spark Service. To do so, click on the CATALOG option on the top right side. A catalog of services will appear.

    Filter the services to only show Spark related services, and then click on the Apache Spark service. (shown below)

    Screen-Shot-2016-12-07-at-4.25.14-PM

    You will be taken to an overview of the Spark Service. The service will default to the free version. On the right bottom hand side, you will be able to create the service. For this recipe we will use the default configuration settings.

    Click on create to create your Spark Service.

    Screen-Shot-2016-12-07-at-4.27.54-PM

     

    After the Spark service is created, you will be taken to the following page where you can open the service to enter your Spark environment. Click on Notebooks

    Screen-Shot-2016-12-07-at-4.29.38-PM

     

    You will be taken to a page where you can create Notebooks which are environments where you can create and interact with your code as you build your application. We will create a notebook and copy the Scala code that is located at the bottom of this tutorial page.

    To create a notebook, click on New Notebook at the bottom of the page.

    Screen-Shot-2016-12-07-at-4.32.13-PM

     

    You will be taken to a page where you have the option to create a blank Notebook, load from a File, From URL, or use a Sample.

    Choose 'From File' and Specify a name for your Notebook such as MyScalaNotebook.

    Load the Scala Notebook that you downloaded at the end of this tutorial page.

    Click on Create Notebook to continue.

    Screen-Shot-2016-12-07-at-4.34.33-PM

     

    You will be taken to a page that has the Scala code that Spark will run. It has everything you need to immediately publish data to a sample Watson IoT Platform Service. You can run the code all at once by going to Cell->Run All as shown below.

    This sample publishes messages as a simulated device and as a regular application so you can extend in anyway that you like.

    This sample also has built-in comments so you can find where you need to replace the configuration information to work with your own IoT Service Credentials

     

    Complete!

1 comment on"IBM Bluemix with Spark Service (Scala) and Watson IoT Platform"

  1. Thank you for sharing it.

Join The Discussion