Name: manage-control-device-node-red
Owner: International Business Machines
Description: Create, connect and simulate devices with Watson Data Platform and Node-Red
Created: 2017-10-10 02:08:38.0
Updated: 2018-04-27 17:52:30.0
Pushed: 2018-04-27 17:52:29.0
Homepage: https://developer.ibm.com/code/patterns/develop-an-iot-app-with-node-red-and-watson/
Size: 1218
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Skill Level: Any Skill Level
N.B: All services used in this repo are Lite plans.
Build an IoT project with a simualted device that sends events for data monitoring on Watson IoT Platform on IBM Cloud.
This guide steps you through the process of connecting devices to Watson IoT Platform, monitoring and acting on device data.
The outcome of this project will help you:
We set up a connected simulated motor and use it to send IoT data to Watson IoT Platform.
The app self-registers a device with Watson IoT Platform and automatically sends well-formatted data to the platform.
As part of this guide, you will:
To get started with Watson IoT Platform using a different IoT device, see the Getting started tutorial.
Click here to view the IBM Pattern for this project.
You will need the following accounts and tools:
If you want to deploy directly to IBM Cloud, click on Deploy to IBM Cloud
button below to create a IBM Cloud DevOps service toolchain and pipeline for deploying basic motor with an IoT device that sends monitoring data to Watson IoT Platform on IBM Cloud, else jump to Steps
After deploying the application, please continue with Step 4 - See raw data in Watson IoT Platform.
You can also create a Node-Red app manually from IBM Cloud Catalog.
Steps
1) Deploy Watson IoT Platform 2) Deploy the node-red simulate iot app (make sure you rename your app) 3) Store data in Cloudant database 4) See raw data in Watson IoT Platform 5) Visualize live data in Watson IoT Platform
Watson IoT Platform provides powerful application access to IoT devices and data to help you rapidly compose analytics applications, visualization dashboards, and mobile IoT apps. The steps that follow will deploy an instance of the Watson IoT Platform service with the name
simulate-iot
in your IBM Cloud environment. If you already have a service instance running, you can use that instance with the guide and skip this first step. Just make sure that you use the correct service name and IBM Cloud space when you proceed through the guides.
From the command line, set your API endpoint by running the bx api command.
Replace the API-ENDPOINT
value with the API endpoint for your region.
pi <API-ENDPOINT>
Example: bx api https://api.ng.bluemix.net
Region | API Endpoint |
---|---|
US South | https://api.ng.bluemix.net |
United Kingdom | https://api.eu-gb.bluemix.net |
Log into your IBM Cloud account.
ogin -u YOUR_BLUEMIX_USERNAME -o org_name -s space_name
If prompted, select the organization and space where you want to deploy Watson IoT Platform and the sample app. Note example a) org: john.doe@ibm.com b) space = dev
Deploy the Watson IoT Platform service to IBM Cloud.
reate-service iotf-service iotf-service-free YOUR_IOT_PLATFORM_NAME
For YOUR_IOT_PLATFORM_NAME, use simulate-iot.
Example: bx create-service iotf-service iotf-service-free simulate-iot
The sample app lets you simulate a IBM Cloud connected industrial devices.
You can start and stop the motor and adjust the speed of the motor. Every change to the motor is sent to IBM Cloud in the form of an MQTT message that is displayed in the app. You can monitor the motor behavior by using the default dashboard cards.
This sample is using a motor which is a simulated device and can be replaced with any device to perform the same behavior.
To deploy this setup from a terminal instead, you can use the following commands:
pi https://api.ng.bluemix.net
ogin -u YOUR_BLUEMIX_USERNAME -o org_name -s space_name
reate-service iotf-service iotf-service-free simulate-iot
pp push YOUR_APP_NAME
To troubleshoot errors, use
bx app logs YOUR_APP_NAME --recent
command (i.e.bx app logs simulate-iot --recent
).
https://YOUR_APP_NAME.mybluemix.net
https://simulate-iot.mybluemix.net/
. from flow folder the content of flow.txt into `https://simulate-iot.mybluemix.net/red` after you setup an username/password. Paste it under the Menu tab -> Import -> Clipboard and press Import. Now ready for `https://YOUR_APP_NAME.mybluemix.net/motor`
Step 3 - Cloudant database will be part of this step 2 setup
Verify that the device is registered with Watson IoT Platform.
https://*iot-org-id*.internetofthings.ibmcloud.com
.View raw data
Send sensor data to the platform.
The device sends data to Watson IoT Platform when sensor readings change. You can simulate this data sending by stopping, starting or changing the speed of the motor.
Verify that the updated device data points that correspond to the published message are displayed in the Device Properties card.
Message example A:
{
d":"motor1",
s":1507477920588,
y":1.424,
unning":true,
pm":1.5,
peed":"1",
imestamp":"Sun, 08 Oct 2017 15:52:00 GMT",
sgCount":1
To create a dashboard card to see live motor device data:
Motor data
and then click Submit.For more information about creating boards and cards, see Visualizing real-time data by using boards and cards.