Skip to main content

How do I connect my BB-400 to IBM Cloud?

Cloud computing is the process by which information can be sent over the internet using a variety of different "pay-as-you-go" services. The BB-400 has a number of cloud services integrated, and this FAQ will explore one of these options: IBM Cloud.

For more information regarding the other cloud services please refer to the FAQ What Cloud services are available on the BB-400?

IBM Cloud, IBM Watson and Node-RED

IBM Cloud is a popular cloud platform, and supports the tool: IBM Watson IoT Platform is a cloud service that can connect IoT sensors using IBM Cloud.

It is possible to connect the BB-400 to IBM Watson using Node-RED (link to Node-RED FAQ), and as Node-RED is already set up on the BB-400 by default, this is a great method in which to connect your device to the cloud.

Create an IBM Cloud account and IBM Watson IoT Platform

The first step is to create an IBM Cloud account: https://cloud.ibm.com/, and then you need to 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 dashboard showing resource summary, planned maintenance, and the Create resource button highlighted in the top right

IBM Cloud catalog with Internet of Things category selected, showing the Internet of Things Platform service tile

Once you have created the IoT resource, you can launch the IBM Watson IoT Platform:

IBM Watson IoT Platform resource page with the Launch button highlighted, showing Lite plan tier options

Add Device

Within the IBM Watson IoT Platform you can add your device, by clicking on the "Add Device" button at the top of the screen:

IBM Watson IoT Platform Browse Devices page with the Add Device button highlighted in the top right corner

  1. Identity The first step is to add information regarding your device type and assigning your device a unique ID: Add Device Identity tab with Device Type set to BB-400 and Device ID set to BB-400-XXXX, with Next button highlighted
  2. Device Information You can provide device information in the next section, but it is fine to keep all the boxes blank and proceed to the next section: Add Device Information tab with optional fields for serial number, manufacturer, model, and firmware version left blank
  3. Security The next stage is to create a device authentication token. You can choose to either auto-generate a 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: Add Device Security tab showing auto-generated and self-provided authentication token options with a token input field Review the information provided so far before the authentication token is created: Add Device Summary tab showing BB-400 device type, BB-400-XXXX device ID, and security token to be generated with Done button
  4. Summary The summary page provides an overview of your device's credentials. You will need the credentials for connecting your device to the IBM Watson IoT Platform. As mentioned previously, it is important to keep a note of your authentication token as you will not be able to recover its details when proceeding past this stage: ** **BB-400 device credentials page showing Organization ID, Device Type, Device ID, Authentication Method, and Authentication Token****You should now see your device on the IBM Watson IoT Platform device section: IBM Watson IoT Platform Browse Devices list showing the BB-400 device registered with its Device ID, Type, and Date Added

Create Node-RED app

Now you have added your device to the IBM Watson IoT Platform, the next step is to create a IBM Cloud Node-RED application to connect to your device's Node-RED instance. Navigate back to IBM cloud and click on "Create resource":

IBM Cloud dashboard with Create resource button highlighted to create a new Node-RED application

Within "Starter Kits" you will find the Node-RED Starter application:

IBM Cloud catalog Starter Kits section with the Node-RED Starter application highlighted in a red box

Follow the instructions to create your Node-RED application.

Connect IBM Watson IoT Platform to your IBM Cloud Node-RED application

Once your IBM Node-RED application has been created it is important to connect your IBM Watson IoT Platform to the Node-RED application, so that you can connect your device as a registered device:

BB-400NodeRED app overview showing IoT Platform connection highlighted under Connections, with Visit App URL link

You can open Node-RED by clicking on "Visit App URL":

IBM Cloud navigation menu with Resource List highlighted, showing Cloud Foundry Apps and other resource categories

And clicking on "Go to your Node-RED flow editor":

Node-RED on IBM Cloud welcome page with Go to your Node-RED flow editor button and description of the platform

Will take you to your IBM Cloud Node-RED instance and you can now start creating flows.

So far we have created an IBM cloud account, an IBM Watson IoT platform and a IBM Node-RED application. We have also added our device to the IoT platform.

The next section will explain how to connect your BB-400 to the IBM cloud's Node-RED application, and a basic example will be provided so you can send data to the IBM cloud and IBM cloud will receive the data.

Connecting Node-RED

Open your BB-400 and IBM cloud Node-RED applications

First we need to connect the BB-400's Node-RED to the IBM Cloud's Node-RED. In a web browser open up your BB-400's Node-RED instance by selecting the apps section on the BB-400 webadmin page or by typing in http://YOUR-BB400-IP-ADDRESS:1880/; the port number for Node-RED is 1880.

You can open up the IBM Cloud's Node-RED by going to IBM Cloud, clicking on the Navigation Menu, and selecting Resource List.

Under Cloud Foundry Apps you will find your Node-RED starter:

IBM Cloud Resource List showing Cloud Foundry Apps with BB-400NodeRED app running as a Node-RED Starter in London

Alternatively, type the following link into your browser: https://YOUR-NODE-RED-APP-NAME.eu-gb.mybluemix.net/red/, where YOUR-NODE-RED-APP-NAME is the name you assigned to your Node-RED starter app.

Installing Watson IoT nodes

You are required to use the Watson IoT input Node-RED Watson IoT input node and output Node-RED Watson IoT output node nodes to send data to IBM cloud. The Watson IoT nodes are available by default on your BB-400 Node-RED application, they can be found on the left-hand side under "input" and "output".

Sending BB-400's IO status to IBM's Node-RED instance using WebSocket

The following example is a tutorial on connecting your BB-400's Node-RED instance to IBM's Node-RED application and also sending the BB-400's IO status to IBM cloud using Node-RED via WebSocket.

Open up your BB-400's Node-RED instance. The first node we will add to our workspace is a WebSocket input node Node-RED WebSocket input nodeand we will configure the node as follows:

WebSocket input node configuration with Type set to Listen on, Path set to ws://localhost:8989, and Name set to WebSocket IO line

Note that 8989 is the port number for WebSockets.

Next drag a json node Node-RED JSON parser node onto the workspace and connect it to the WebSocket node.

Then we will use a Watson IoT output node Node-RED Watson IoT output node and double clicking on the node gives the following:

Watson IoT output node configuration showing Quickstart mode with Device connection, event type, and JSON format settings

We will change to a Registered mode, click on the pencil next to Credentials and fill in our device credentials:

Watson IoT credentials editor with Organization, Server-Name, Device Type, Device ID, Auth Token, and Keep Alive fields

Finally we will add a debug node Node-RED debug node so that we can see the output and we will connect it to the json node.

The complete flow looks as follows:

BB-400 Node-RED flow: WebSocket IO line node connected to JSON node, which feeds into both a Debug node and a Watson IoT event output node

If we navigate to IBM Watson > Devices > Click on our device > Recent Events, we can see the messages being sent to the IBM Cloud:

IBM Watson IoT Platform Recent Events tab for BB-400-00c0 showing JSON event messages with inputs and outputs arrays

In addition, when we adjust the IO status, for example on the web admin page, we see the change in IO status being sent from the BB-400's Node-RED instance to the IBM Cloud.

Receiving messages on IBM Cloud's Node-RED

Next, we will show how we can configure our IBM Cloud's instance of Node-RED, so that we can read the messages being sent from the BB-400's instance of Node-RED.

We will drag a ibmiot node Node-RED IBM IoT input node and change the settings to use the Bluemix options:

IBM IoT input node configuration with Authentication dropdown showing Bluemix Service option selected

Add your device ID, and click on the tick "All" on the other options:

IBM IoT input node configured with Bluemix Service, Device Event input type, Device ID BB-400-00c0, and All selected for Event and Type

If the Bluemix options do not appear then double check you have connected your IBM Cloud's instance of Node-RED to IBM Watson.

Then we will drag 2 function nodes Node-RED function node and change the messages so that we can read the inputs:

Function node named Inputs with code: return {payload.payload.d.inputs} to extract IO input values

And outputs:

Function node named Outputs with code: return {payload.payload.d.outputs} to extract IO output values

Finally we will add a debug node Node-RED debug node and attach it to the function node.

Below is the IBM Cloud's Node-RED flow:

IBM Cloud Node-RED flow: IBM IoT node connected to Inputs and Outputs function nodes, both feeding into a msg.payload debug node

If we click deploy on both Node-RED instances we can see the BB-400's IO status being sent from the BB-400's Node-RED instance:

BB-400 Node-RED debug panel showing msg.payload objects with inputs array[8] and outputs array[8] IO status data

And the IO status messages being received on IBM Cloud's Node-RED instance:

IBM Cloud Node-RED debug panel showing received IO status arrays like [1,1,1,1,0,0,0,0] and [0,1,0,1,1,1,1] from BB-400

Import Flows

To import the flows into your Node-RED applications, go to Import > Clipboard:

Node-RED hamburger menu with Import submenu expanded showing Clipboard option highlighted

Copy and paste the flows provided below and click on "Import". Make sure you adjust the credentials for your device and then the flows can be deployed.

BB-400 Node-RED flow:

[
{"id":"9d939786.842cb8","type":"tab","label":"WebSocket IBM Watson","disabled":false,"info":""},
{"id":"2c0bde6b.e85b22","type":"json","z":"9d939786.842cb8","name":"","property":"payload","action":"","pretty":false,"x":307,"y":123,"wires":[["581f4a36.f5f5b4","24706ab1.c0d526"]]},
{"id":"581f4a36.f5f5b4","type":"debug","z":"9d939786.842cb8","name":"Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":514,"y":94,"wires":[]},
{"id":"5d1a306f.9dc8f","type":"websocket in","z":"9d939786.842cb8","name":"WebSocket IO line","server":"e685ee4f.10906","client":"","x":124,"y":125,"wires":[["2c0bde6b.e85b22"]]},
{"id":"24706ab1.c0d526","type":"wiotp out","z":"9d939786.842cb8","authType":"d","qs":"false","qsDeviceId":"","deviceKey":"1717da24.6c8e56","deviceType":"","deviceId":"","event":"event","format":"json","qos":"","name":"","x":510,"y":172,"wires":[]},
{"id":"e685ee4f.10906","type":"websocket-listener","z":"","path":"ws://localhost:8989","wholemsg":"false"},
{"id":"1717da24.6c8e56","type":"wiotp-credentials","z":"","name":"IBM-out","org":"l7wvs2","serverName":"","devType":"BB-400","devId":"BB-400-00c0","keepalive":"60","cleansession":true,"tls":"","usetls":false}
]

IBM cloud Node-RED flow:

[
{"id":"52bc0b88.446e64","type":"tab","label":"Flow 1","disabled":false,"info":""},
{"id":"65191717.2d87b8","type":"ibmiot in","z":"52bc0b88.446e64","authentication":"boundService","apiKey":"","inputType":"evt","logicalInterface":"","ruleId":"","deviceId":"BB-400-00c0","applicationId":"","deviceType":"+","eventType":"+","commandType":"","format":"json","name":"IBM IoT","service":"registered","allDevices":"","allApplications":"","allDeviceTypes":true,"allLogicalInterfaces":"","allEvents":true,"allCommands":"","allFormats":"","qos":0,"x":160,"y":140,"wires":[["ff2d47aa.bc8cb8","41c162fd.3a33ec"]]},
{"id":"f108d6d1.df2138","type":"debug","z":"52bc0b88.446e64","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":510,"y":140,"wires":[]},
{"id":"ff2d47aa.bc8cb8","type":"function","z":"52bc0b88.446e64","name":"Inputs","func":"return {payload:msg.payload.d.inputs};","outputs":1,"noerr":0,"x":330,"y":100,"wires":[["f108d6d1.df2138"]]},
{"id":"41c162fd.3a33ec","type":"function","z":"52bc0b88.446e64","name":"Outputs","func":"return {payload:msg.payload.d.outputs};n","outputs":1,"noerr":0,"x":340,"y":180,"wires":[["f108d6d1.df2138"]]}
]

Sending data from IBM Cloud's Node-RED to your BB-400

In this example we will send a message to adjust the IO lines, from IBM Cloud's Node-RED instance and receive it on your device.

We will start within the IBM Cloud's Node-RED instance.

Drag a inject node Node-RED inject node and configure the node as follows:

Inject node configured with JSON payload [1,0,1,0,1,0,1,0] named Adjust IO lines to toggle alternate outputs

The inject node has been configured to change alternate IO lines to 1, hence turning the LEDs on the front of your BB-400 off.

Now, we will send the message to the BB-400 using a ibmiot out node, Node-RED IBM IoT input node change your settings to Bluemix:

IBM IoT output node configured with Bluemix Service authentication, Device ID BB-400-00c0, and Device Event output type

Click on deploy, and click the tab next to the inject node. The payload message is being sent from IBM Cloud to your BB-400, you should see a change in the IO status of your BB-400, alternate LEDs will be switched off.

You can also check the change in IO status within the web admin IO status page:

BB-400 web admin IO Status page showing 8 digital IO lines (dio0-dio7) with alternating on/off LEDs and output/input indicators

Import flow

Feel free to copy the flow below into your IBM Cloud's Node-RED instance, making sure you update the credentials for your device:

[
{"id":"23504559.a842fa","type":"inject","z":"52bc0b88.446e64","name":"","topic":"","payload":"[1,0,1,0,1,0,1,0]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":80,"wires":[["a124cb18.61f478"]]},
{"id":"a124cb18.61f478","type":"ibmiot out","z":"52bc0b88.446e64","authentication":"boundService","apiKey":"","outputType":"cmd","deviceId":"ADDHERE","deviceType":"ADDHERE","eventCommandType":"all","format":"all","data":"all","qos":0,"name":"IBM IoT","service":"registered","x":380,"y":80,"wires":[]}
]

You have successfully connected your BB-400 to IBM Cloud using Node-RED, sent messages from your device to the cloud, and the cloud has been able to receive the messages. You have also sent a message from the cloud to your device.