Kubernetes with OpenShift World Tour: Get hands-on experience and build applications fast! Find a workshop!

Create an Internet of Things Platform Starter application

In this tutorial, learn how to create a Node-RED and Watson IoT Platform starter application that can be used to connect IoT devices and simulated IoT devices to the Watson IoT Platform. This combination of services will be assembled to work together, including a Node-RED Node.js web server, a Cloudant database to store the sensor data, and the IoT Platform service, so that you can easily connect IoT devices.

Learning objectives

In this tutorial, you will learn how to:

  • Create a Node-RED Starter Kit application running in the IBM Cloud
  • Create an Internet of Things Platform service instance
  • Connect the the Internet of Things Platform service instance to the Node-RED Cloud Foundry application
  • Restage the Node-RED Starter Cloud Foundry application
  • Open the Watson IoT Platform so that you can send data from IoT devices and device simulators
  • Configure the Node-RED visual programming editor

Prerequisites

To complete this tutorial, you need an IBM Cloud account (IBM Cloud Lite, trial, or paid account).

Estimated time

You can complete this tutorial in less than 20 minutes.

Steps

  1. Create a Node-RED Starter application
  2. Create an Internet of Things Platform service
  3. Connect the Internet of Things Platform service to the Node-RED Starter application
  4. Open the Node-RED visual programming editor
  5. Launch the Watson IoT platform

Step 1. Create a Node-RED Starter application

Follow these steps to create a Node-RED Starter application in the IBM Cloud.

  1. Log in to IBM Cloud.

  2. Click Catalog (1), and search for Node-RED Starter (2).

  3. Under Starter Kits (3), click the Node-RED Starter (4) tile.

    Catalog entry NodeRED Starter Kit

  4. Enter a unique name for your application (5). This name will be part of the application URL (6). Note: If the name is not unique, you will see an error message, and you must enter a different name before you can continue.

  5. The Domain (7), Organization (8), and Space (9) will be pre-populated with valid options for your IBM Cloud account. If you have a Lite account, then accept the defaults. If you have a trial or paid account, or belong to additional organizations, then you can choose to deploy to any region, organization, and space that is available to you.

  6. In the Selected Plans, you can provision the Node-RED Starter application using the IBM Cloud Lite plan (10).

  7. Click the Create button (11).

    Create Node-RED Starter Kit

Step 2. Create an Internet of Things Platform service

The next step is to create an Internet of Things Platform service instance.

  1. Return to the IBM Cloud Catalog
  2. Search for Internet of Things
  3. Click the Internet of Things Platform tile (12).

    Catalog IoTP Service

  4. Specify a unique service name, such as: “discover-iot-try-service”

    Create IoTP Service

  5. Click on the Create button.

Step 3. Connect the Internet of Things Platform service to the Node-RED Starter application

So far, you have provisioned the IoT Platform Service and Node-RED Starter application in the IBM Cloud region as specified. In this step, you bind the two together.

  1. Once your Internet of Things Platform service instance has been created, the Manage page describes the plans. The Lite tier is free, but it will be deleted after 30 days of inactivity.
  2. Click Connections (13) in the left navigation menu.
  3. Click the Create connection (14) button.

    Starting IoTP Starter Kit

  4. Connect to the Node-RED Cloud Foundry application created in Step 1 by clicking on the Connect button.

    Connect to Cloud Foundry App

  5. Restage the Node-RED Cloud Foundry application to bind it to the Internet of Things service by clicking on the Connect & restage app button.

    Restage Cloud Foundry App

  6. Click on the Restage button to confirm the restage of the Node-RED Starter application.

    Confirm Restage

  7. Click on the application name to open the Node-RED Starter application Overview page.

    Restaging

    Restaging Overview

  8. Wait for the Cloud Foundry application to restart, which is indicated by the status “This app is awake.” Then, click the Visit App URL link.

    Restarted CF app Overview

Step 4. Open the Node-RED visual programming editor

A new browser tab will open to the Node-RED start page. Node-RED is an open source Node.js application that provides a visual programming editor that makes it easy to wire together flows.

Several panels will help you set up Node-RED in your Watson IoT Platform application.

  1. When you see the welcome panel, click the Next button to proceed. (Step 1 of 4)

    Node-RED Welcome

  2. Secure your Node-RED editor by setting a username and password. Remember your username and password. Click the Next button to proceed. (Step 2 of 4)

    Node-RED security

  3. If you forget, you can reset the username and password in the Cloudant DB or by setting IBM Cloud environment variables. Click the Finish button to proceed. (Step 3 of 4)

    Node-RED setup

  4. Click the Go to your Node-RED flow editor button to launch the Node-RED flow editor. (Step 4 of 4)

    Node-RED Launch

  5. Sign in with your new username and password credentials.

    Node-RED login

The Node-RED Visual Programming Editor opens with a default flow. On the left side is a palette of nodes that you can drag onto the flow. You can wire nodes together to create a program.

IoTP Node-RED Default Flow

Step 5. Launch the Watson IoT platform

Now that you’ve bound the two apps together, and configured the Node-RED Visual Programming Editor, you can launch the Watson IoT Platform.

  1. Return to the IBM Cloud Application Details page.

  2. Click the Overview item (15) in the left navigation menu.

  3. In the Connections tile, click your iotf-service (16).

    App Overview page

  4. Click the Alias of … link.

    Alias link

  5. The Internet of Things service landing page opens. From the Manage page, click the Launch (17) button.

    IoT Platform Landing Page

The Watson IoT Platform service opens in a new browser tab. You can now create an IoT device.

IoT Platform Device Page

Summary

Congratulations. You have now created a Node-RED and Watson Internet of Things Platform Starter application in the IBM Cloud.

John Walicki