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.
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:
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)
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.
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
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.
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.
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