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

FAQs

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:

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-ibm-cloud-dashboard.png

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-CreateIoTPlatform.png

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

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-LaunchIoTPlatform.png

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:

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-AddDeviceIoTPlatform.png

  1. Identity
    The first step is to add information regarding your device type and assigning your device a unique ID:
    files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-AddDevice_Name_IoTPlatform.png
  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:
    files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-AddDevice_DeviceInfo_IoTPlatform.png
  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:
    files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-AddDevice_Token_IoTPlatform.png
    Review the information provided so far before the authentication token is created:
    files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-AddDevice_Summary_IoTPlatform.png
  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:
    files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-AddDevice_SummaryInfo_IoTPlatform.png
    You should now see your device on the IBM Watson IoT Platform device section:
    files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-AddDevice_CompleteSummaryInfo_IoTPlatform.png

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”:

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-ibm-cloud-dashboard.png

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

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-Node-REDapp-create.png

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:

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-connect-iot-to_node-red-app.png

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

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-app-visit-url.png

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

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-app-initial-page.png

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:

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-app-cloud-foundry-apps.png

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 files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-iot-node.png and output files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-output-node.png 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 files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-amazon-web-services-websocket-input-node.pngand we will configure the node as follows:

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-websocket-node.png

Note that 8989 is the port number for WebSockets.

Next drag a json node files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-json-node.png onto the workspace and connect it to the WebSocket node.

Then we will use a Watson IoT output node files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-output-node.png and double clicking on the node gives the following:

files/pages/support/faqs/bb-400-faqs/how-do-i-connect-bb-400-to-ibm-watson-using-node-red-watson-iot-out-node-config.png

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

files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-output-node-config-register-credentials.png

Finally we will add a debug node files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-debug-node.png so that we can see the output and we will connect it to the json node.

The complete flow looks as follows:

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-bb-400-complete-flow.png

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

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-ibm-cloud-messages.png

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 files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-ibmiot-node.png and change the settings to use the Bluemix options:

files/pages/support/faqs/bb-400-faqs/how-do-i-connect-bb-400-to-ibm-watson-using-node-red-ibmiot-node-2.png

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

files/pages/support/faqs/bb-400-faqs/how-do-i-connect-bb-400-to-ibm-watson-using-node-red-ibmiot-node-3.png

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 files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-function-node.png and change the messages so that we can read the inputs:

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-read-inputs.png

And outputs:

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-read-outputs.png

Finally we will add a debug node files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-debug-node.png and attach it to the function node.

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

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-IBM-cloud-complete-flow.png

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:

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-bb-400-output.png

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

files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-ibm-watson-using-node-red-IBM-cloud-output.png

Import Flows

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

files/pages/support/faqs/bb-400-faqs/Node-REDapp-import-flow.png

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 files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-inject-node.png and configure the node as follows:

files/pages/support/faqs/bb-400-faqs/how-do-i-connect-bb-400-to-ibm-watson-using-node-red-adjust-io-lines.png

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, files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-ibmiot-node.png change your settings to Bluemix:

files/pages/support/faqs/bb-400-faqs/how-do-i-connect-bb-400-to-ibm-watson-using-node-red-ibmiot-send-message.png

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:

files/pages/support/faqs/bb-400-faqs/how-do-i-connect-bb-400-to-ibm-watson-using-node-red-io-status.png

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.

FAQs