Getting Started with Node-RED* and Bluemix*

Overview

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.

Notes

  • 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.

Required Hardware

  • IoT Gateway that uses Intel® IoT Gateway Technology

Assumptions

  • 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.

  1. 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.
  2. Change to the /home/gwuser/bluemix-solution folder.
    cd /home/gwuser/bluemix-solution
  3. Run the ibm-iot-quickstart app. This python app reports the CPU utilization as a MQTT topic to the MQTT broker.
    python ibm-iot-quickstart.py
  4. 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
  5. 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:

  1. 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.
  2. Position the imported flow on your active sheet and click to finish the import process.
  3. Click on the Deploy button, top right, and Confirm deploy if needed.
  4. Ensure the debug node is turned on. The box extending to the right of the node should be solid/filled in green.
  5. Switch the column on the right from the Info tab to the debug tab.
  6. 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:

$home/usr/ibm-iot-quickstart/samples/ibm-iot-quickstart.py

With the following:

/home/gwuser/bluemix-solution/ibm-iot-quickstart.py

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.

Data Visualization

Here's how you can see the data that is being sent from the IoT Gateway to the Bluemix cloud:

  1. Go to https://quickstart.internetofthings.ibmcloud.com with a web browser.
  2. Enter the MAC address of your IoT Gateway's internet connection.
  3. Click Go.
  4. 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.

For more complete information about compiler optimizations, see our Optimization Notice.