This post was published at 17 Sep 2017

Node Red

Node-RED is a programming tool to connect hardware devices, APIs and online services in a simple mode.
It’s provide through a browser server.
You can install write in bash:

sudo apt-get install -g node-red

And start a project writing:

sudo node-red dendrobytes.json

Components

Packages that can help you to develop faster and easier.

Dashboard

Allow you to create a dashboard (with charts, tabs, menus, etc).

sudo npm install -g node-red-dashboard

Sample

Create a simple dashboard with different data and charts.

Here shows node-red example:

localhost

And here, the respective dashboard:

dashboard

https

Allow you to create HTTPS services.

sudo npm -g install node-red-contrib-https

To set up https

include ca, key and crt files using fs on file settings.js and create a tls-ssl/ folder and put the files there.

Implementing with IBM-Bluemix IoT platform

Firts, you must register on bluemix-console.

register

Once created your account, you should create an organization, I prefer fmorenovr in US South.

organization

Then, choose an apropiate name-space:

space

And confirm.

summary

Then, go to catalog and choose in Boilerplates tab.

catalog

Next, choose “Internet of Things Platform Starter”. You’ll see this view.

iot-platform

Then, create a Cloud Foundry App:

foundryApp

Wait for connect and run …

foundryApp-run

You can verify your information in “dashboard” tab.

dashboard-tap

Press on “Internet of Thing Platform”, this shows info of Iot Instance:

iot-service

Click on launch and redirects to Watson IoT Platform:

watson-paltform

Once here, we must create a device type, go to Device tab:

watson-device-type-1

Click on +Add Device:

watson-device-type-2

Select Manufacturer and model, and then finish.

watson-device-type-2

Next, create a Device with a device type created.

watson-device-device-1

Add a token and finish.

watson-device-device-2

Then, you will have a summary of your new Device:

watson-device-device-3

You can verify in Devices:

watson-device-device-4

Second, generate API Key in APP tab, just press on Generate API Key:

watson-api-key-1

Verify then:

watson-api-key-2

Once created, go to our IoT platform, in this case is Jenazads-ibm.mybluemix.net.
Make a security settings (create an username and password) and go to node-red.

nodered-security

Go to the node-red page:

nodered-secure

Authentificate …

nodered-login

And have fun :D

nodered-tool

Example connection ibm-iot module

You need a basic information, an API key and API key token generate (if you don’t remember, you should generate a new API key).

node-bluemix-iot

Implementing Watson with NodeJS

Finally, we use Watson !!, First of all, download watson package to node-red:

sudo npm install -g node-red-contrib-ibm-watson-iot

Or, through node-red tool, in right-side menu -> Manage palette -> Pallette -> Install -> search package and install.

nodered-tool-install

Then, we try connection (your organization is your Watson IoT url):

nodered-tool-watsoniot