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: Azure. For more information regarding the other cloud services please refer to the FAQ What Cloud services are available on the BB-400? 

Create Azure account

In this section we will explain how to set up a free Azure account, if you would like to buy an Azure account then create an account using the following link: https://azure.microsoft.com/en-gb/pricing/purchase-options/pay-as-you-go/.

Go to the Azure website https://azure.microsoft.com/ and click on Start for free.

Enter your details, you will have to undergo the verification process by phone and card, and then verify your account by email.

Once you have created and verified your account the initial screen will look like as follows:

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-initial-screen.png

Setup IoT Hub

In the search bar at the top of the Azure portal, type IoT Hub and click on the result.

We will add a new IoT Hub

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-add-new-iot-hub.png

and fill in the following details and click save.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-iot-hub.png

Then your IoT Hub is ready to be deployed.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-iot-hub-2.png

You will need to use your access keys in the next section. They can be found by going to Shared access policies and clicking on iothubowner.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-iot-hub-primary-key.png

Create IoT device

Now we will add our BB-400 to the IoT Hub. Click on the IoT Hub you have just created and scroll down to ioT devices. We will click on New to add our device.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-add-new-device.png

Fill in the details and click save,

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-iot-hub-connect-device.png

you will now be able to see your device on your IoT Hub.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-iot-hub-connect-device-list.png

Your device will also come with access keys, and they can be found by clicking on your device.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-device-access-keys.png

Connect your device to Azure using Node-RED

Now we are ready to connect our device to Azure using Node-RED. We firstly need to install the Azure IoT Hub nodes and there are 2 ways in which to do this, via command line or manually.

Command Line

The first way is to navigate to the Node-RED directory within your BB-400 terminal:

$ cd node-red-data

type the following command to install the nodes

$ npm install node-red-contrib-azure-iot-hub

and finally, you will need to restart the Node-RED app so the installed nodes will load up on Node-RED:

$ node-red-restart

Manually install nodes

The other method is to add the nodes using Manage Palette within the Node-RED application.

Click on Manage palette

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/Node-REDapp-manage-palette.png

select the Install tab, type in "node-red-contrib-azure-iot-hub" and click on Install.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-azure-iot-hub.png

Once installed, you will see the Azure IoT nodes http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-azure-nodes.png on the left hand side of your workspace.

Send BB-400's IO status to Azure

We will firstly drag a websockets input node http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-amazon-web-services-websocket-input-node.png onto our workspace to send the IO status. Double click on the node and configure it as follows:

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-amazon-web-services-websocket-input-node-configuration.png

Next, add a function node http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-function-node.png to the workspace, connect it to the WebSockets input node and configure it to set up Azure credentials and to send the BB-400's IO data as follows

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-function-primary-key-blanked-out.png

The device ID is the one you assigned when create your device on the IoT Hub.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-device-id.png

The "Key" which has been blanked out in the above example, refers to the primary key of your device and can be found by going to your IoT Hub, clicking on shared access policies and then clicking on your device.

Next drag a Azure IoT Hub node http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-iot-hub-node-node.png and configure it as follows

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-iot-hub-node.png

your host name can be found by going to your IoT Hub and clicking on Overview.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-host-name.png

Finally drag a debug node http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-debug-node.png and connect it to the Azure IoT Hub node. The full node configuration to send IO status to Azure looks as follows:

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-complete-flow-to-send.png

Click deploy and you should see the IO status being sent to Azure. The Azure node will also have a "Sent message" notification underneath it, as you can see in the image above, if everything has been connected properly.

The debug output looks as follows

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-message-sent-debug.png

Receive the BB-400's IO status from Azure

We will use a Azure IoT Hub Receiver node http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-receiver-node.png to receive the IO status messages sent from the BB-400. Configure the node as follows

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-iot-hub-receiver-node.png

The connection string refers to your IoT Hub's primary key and can be found here:

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-iot-hub-primary-key.png

Next drag a json node http://www.brainboxes.com/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 Azure IoT Hub Receiver node. Finally add a debug node and connect it to the json node and click on deply.

If everything is connected successfully, the full flow should look like below, including underneath the IoT Hub Receiver node the message "Received",

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-node-red-receive-io-status.png

you should also see the BB-400's IO status being received by Azure in the debug messages section.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-azure-message-received.png

 

 

This FAQ has allowed you to successfully connect your BB-400 to Azure using Node-RED, you have sent your device's IO status to the cloud, and the cloud has been able to receive the messages.