Node-RED* is a tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based flow editor that makes it easy to wire together flows using the wide range nodes in the palette. Flows can be then deployed to the runtime in a single-click. The light-weight runtime is built on Node.js*, taking full advantage of its event-driven, non-blocking model. This makes it ideal to run at the edge of the network. Bluemix* is a cloud platform as a service (PaaS) developed by IBM. It supports several programming languages and services, as well as integrated DevOps to build, run, deploy, and manage applications on the cloud. Bluemix is based on Cloud Foundry open technology and runs on SoftLayer infrastructure.
This document describes the steps to set up a Bluemix cloud connection to an Intel® IoT gateway.
- This solution based on the existing solution published by IBM.
- The Bluemix-solution currently does not support proxy (run behind firewall). All steps below must be executed on a gateway not behind firewall.
- IoT Gateway that uses Intel® IoT Gateway Technology
- Intel® IoT Gateway Technology version 3.1 or above.
- Node.js is installed on the IoT Gateway (installed by default).
- Node-RED is installed on the IoT Gateway and is running (installed by default).
- The Bluemix package is installed on the IoT Gateway.
- You can install this package by clicking on Packages and then Add Packages from the Intel® IoT Gateway Developer Hub.
For additional information about connecting your gateway, see Getting Started with Intel® IoT Gateways with Intel® IoT Developer Kit 3.5 Step 3: connecting to the cloud.
Testing the Bluemix* script
Note: At the time of this publication, this example has only been tested with direct internet connections. Ensure your IoT gateway is connected directly to the internet, with no proxy support.
- Open a terminal session to the IoT Gateway either by a directly connected monitor or by establishing a SSH session to the IP address of the IoT gateway.
- Change to the /home/gwuser/bluemix-solution folder.
- Run the ibm-iot-quickstart app. This python app reports the CPU utilization as a MQTT topic to the MQTT broker.
- You should see output like this:
No config file found, connecting to the Quickstart service MAC address: 000bab8b0a86 0.0 message published 87.7922077922 message published 88.3376849434 message published
- Press Ctrl+C to terminate the app.
Run Node-RED* example flow
The Node-RED browser interface can be reached via http://ipaddressofthegateway:1880. When it first comes up it will look something like this:
- The sample Bluemix package you installed from the Intel® IoT Gateway Developer Hub includes a sample Node-RED flow for communicating to Bluemix. To import this flow, click on the 3 horizontal lines to the right of the Deploy button, and select Import, Library, and Bluemix.
- Position the imported flow on your active sheet and click to finish the import process.
- Click on the Deploy button, top right, and Confirm deploy if needed.
- Ensure the debug node is turned on. The box extending to the right of the node should be solid/filled in green.
- Switch the column on the right from the Info tab to the debug tab.
- Click on the blue box to the left of the Run once injector node to start the Bluemix flow.
If the default import script doesn’t work, replace the line below:
With the following:
Note: If there are no errors in the debug tab, this indicates that the flow is running. There will be no other output in Node-RED.
Here's how you can see the data that is being sent from the IoT Gateway to the Bluemix cloud:
- Go to https://quickstart.internetofthings.ibmcloud.com with a web browser.
- Enter the MAC address of your IoT Gateway's internet connection.
- Click Go.
- The page will display the chart of the IoT Gateway’s CPU utilization over time.
Congratulations! You are now successfully transmitting sensor data to/from the Bluemix cloud.