Instructor Lead On-Demand Learning Courses - August Big $10 Sitewide Extravaganza All Pro Web Designs and Udemy are happy to offer this special to you, good only on dates: 08/21-08/31 Act Now!

Connecting a Raspberry Pi to IBM Watson, Bluemix and Node-RED

IBM recently helped spark the Internet of Things enthusiasm into a bunch of developers by sending out Raspberry Pi 3 computers to developers who signed up for their Bluemix platform trial. I had been eager to give Bluemix and IBM Watson a try and figured this was as good a time as any to sign up! I was lucky enough to be one of the developers who received a Raspberry Pi 3 and so, I did what I always do with new emerging technology, I began tinkering and writing about my experience.

This is the first part of a series of articles around combining the Raspberry Pi with IBM Watson and Bluemix. This article focuses on the various ways you can connect up the Raspberry Pi to IBM’s cloud services, along with my tips along the way for when things didn’t quite go to plan for me. It was a lot of fun and I highly recommend people give IBM Bluemix and Watson a try, especially if you have a spare Raspberry Pi lying around!

Setting Up a Quick Test of Watson IoT on Our Raspberry Pi

To set up the IBM Watson IoT Platform on our Raspberry Pi, we run the following commands on the Pi itself:

First, we download the Watson IoT Platform installer from IBM’s GitHub:

[code language=”bash”]
curl -LO

Instructor Lead On-Demand Learning Courses - August Big $10 Sitewide Extravaganza All Pro Web Designs and Udemy are happy to offer this special to you, good only on dates: 08/21-08/31 Act Now!

Then, we run the following command to install it:

[code language=”bash”]
sudo dpkg -i iot_1.0-2_armhf.deb

Once this has installed, it will automatically run the IBM Watson IoT Platform service on our device. In fact, the service runs automatically each time our Pi is booted up. If you aren’t sure if it is running and want to be certain, run the following command:

[code language=”bash”]
service iot status

That should bring up a response that looks something like so:

[code language=”bash”]
● iot.service – LSB: IoT service
Loaded: loaded (/etc/init.d/iot)
Active: active (running) since Fri 2016-04-29 23:33:47 UTC; 15s ago
CGroup: /system.slice/iot.service
└─11960 /opt/iot/iot /dev/null

If you see the above message, you’re good to go! In fact, we can already see Raspberry Pi data being streamed to the IBM’s cloud. To do so, type in:

[code language=”bash”]
service iot getdeviceid

It will return an ID for our device and a URL we should visit:

[code language=”bash”]
The device ID is abcdefghijkl
For Real-time visualization of the data, visit

If we head to (with our device’s ID rather than the placeholder), we should see a pretty neat visualization from IBM! In it, we can see our Raspberry Pi’s CPU temperature and other stats from the cloud.

Our data streaming through in a simple visualization

Now, let’s approach it in a different way and set up IBM Bluemix to handle our data.

Getting Started in Bluemix

To log into Bluemix, head to the IBM Bluemix login page. You can sign up for an IBM ID and BlueMix from there too if you do not already have an account.

Once Bluemix loads, we select our region by clicking the top right-hand corner account icon:

Choosing a region

Then, if Bluemix requests that we create a space in that region, we do so. I’ve named my space “dev”:

Entering the name of our space

Then, we click on “Use Services or APIs” to find a good initial service for our app.

Choosing Use Services or APIs

In this screen, we need to find the “Internet of Things Platform” service. You can do so by either clicking the “Internet of Things” checkbox on the left hand side to filter the selections down, or by typing into the search bar “Internet of Things Platform”. However we search for it, once we have it we select it for our app.

Selecting the Internet of Things Platform in Bluemix

We then click “Create” on the next screen, you could change the “Service Name” if you wanted to adjust this. It doesn’t really affect much, so for my example I just left it as is. You could name it something like “Raspberry Pi Service” if you so desired:

Choosing to create our IoT service

We scroll down on the welcome screen that appears and choose “Launch Dashboard”:

Clicking to launch Bluemix Dashboard

Now we can add our Raspberry Pi to this new service by clicking “Add Device”:

Adding device to Bluemix

Click to “Create device type”:

Choosing create device type

Another screen will appear asking whether we want to create a device type or gateway type. We want a device type:

Choosing the device type option

Finally, we name our device type. The first field is for a device type name that will be used in our APIs and such, so keep it lowercase and separated by dashes. e.g. “my-pis” or “iot-sample-devices”. Underneath that, you can write a longer and more human readable description:

Adding our device type details

The next screen gives us options for our device template, providing fields we can use for each device to define its characteristics. This is very much up to you and what device data you’d like to record in this device type. As I am using this device type to just track Raspberry Pis, I’ve chosen only to define their “Model” (e.g. Raspberry Pi 2, Raspberry Pi 3… etc).

Selecting just model and then clicking Next

Then, we set our default model type. I set my main model type for this device template to be “Raspberry Pi 3 Model B”:

Entering in Raspberry Pi 3 Model B as the model name

You can add your own custom metadata in JSON format if you would like, for our purposes in this simple tutorial, we can skip this step.

We could add sample JSON data for our device type

Now our device type is ready to be used! We should be back at the “Add Device” screen. This time, our new device type should be selected. Check that is the case and click “Next”.

Selecting a device type if not selected and clicking next

Continue reading %Connecting a Raspberry Pi to IBM Watson, Bluemix and Node-RED%

Instructor Lead On-Demand Learning Courses - August Big $10 Sitewide Extravaganza All Pro Web Designs and Udemy are happy to offer this special to you, good only on dates: 08/21-08/31 Act Now!

Leave a Reply