copyright | lastupdated | ||
---|---|---|---|
|
2017-04-19 |
{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen: .screen} {:codeblock: .codeblock} {:pre: .pre}
{: #gettingstartedtemplate}
Get started with {{site.data.keyword.iot_full}} by using the {{site.data.keyword.iot_short_notm}} Starter boilerplate. By using the Starter, you can quickly simulate a device, create cards, generate data, and begin analyzing and displaying data in the {{site.data.keyword.iot_short_notm}} dashboard. {:shortdesc}
The Starter automatically deploys and connects these services:
-
{{site.data.keyword.iot_short_notm}} - An IoT toolkit that includes gateway management, device management, and application access. By using {{site.data.keyword.iot_short_notm}}, you can collect connected device data and run analytics on real-time data from your organization.
-
{{site.data.keyword.sdk4nodefull}} - The runtime environment in which Node-RED runs.
-
{{site.data.keyword.cloudantfull}} - The database in which Node-RED stores metadata.
{: #about_iotplatform} {{site.data.keyword.iot_short_notm}} provides powerful application access to IoT devices and data to help you rapidly create analytics applications, visualization dashboards, and mobile IoT apps. You can use {{site.data.keyword.iot_short_notm}} to perform powerful device management operations, store and access device data, and connect a wide variety of devices and gateway devices. {{site.data.keyword.iot_short_notm}} provides secure communication to and from your devices by using MQTT and TLS.
{: #about_nodered} Node-RED is a tool for wiring together hardware devices, APIs, and online services in new and interesting ways. You can use Node-RED to create a simulated thermostat that sends simulated data to your {{site.data.keyword.iot_short_notm}} service. You can create cards to display real-time data in the {{site.data.keyword.iot_short_notm}} dashboard. For more information, see the Node-RED documentation.
Before you begin, you must deploy an instance of the {{site.data.keyword.iot_short_notm}} Starter in your {{site.data.keyword.Bluemix_notm}} organization. Deploying an instance automatically deploys the component applications and services of the starter.
You can find the {{site.data.keyword.iot_short_notm}} starter in the Boilerplates section of the {{site.data.keyword.Bluemix_notm}} catalog.
{: #deployStarter}
Perform the following steps to deploy the Starter:
- Create the boilerplate:
- Log in to or register for Bluemix at https://www.bluemix.net.
- Select the {{site.data.keyword.iot_short_notm}} Starter boilerplate. - Open the catalog by selecting Blue + or by selecting the catalog tab. - Select the Boilerplate category. - Select the Internet of Things Platform Starter boilerplate.
- On the Internet of Things Platform Starter page, verify the selections for Create an app. In this scenario, the following values are entered: - Space: dev - Name: myIoTApp - Host: myIoTApp
- Click Create to add Node-RED to your {{site.data.keyword.Bluemix_notm}} organization.
- Keep the default values for the rest of the options. After the application is deployed, the Getting Started with {{site.data.keyword.iot_short_notm}} Starter page is displayed. Note: The staging process might take a few minutes.
{: #gettingaround} To make moving between tasks easier, open the {{site.data.keyword.Bluemix_notm}} dashboard, the {{site.data.keyword.iot_short_notm}} dashboard, and the Node-RED application in three different tabs in your browser.
- {{site.data.keyword.Bluemix_notm}} dashboard - See the state of your deployment, read documentation, and launch the dashboards.
- {{site.data.keyword.iot_short_notm}} dashboard - Define device types, register devices, monitor incoming sensor data, create data visualization cards, and see live data visualizations.
- Node-RED - Configure and run the device simulator flow and work with other flows to process data from {{site.data.keyword.iot_short_notm}}.
{: #definingsimdev}
Complete the following steps to simulate a scenario that uses a thermostat to monitor temperature, humidity, and location of a living room.
- Launch the {{site.data.keyword.iot_short_notm}} dashboard.
- Scroll to the Services section and click the name of your {{site.data.keyword.iot_short_notm}} instance. The instance name usually ends with -iotf-service.
- Click Launch Dashboard to open the {{site.data.keyword.iot_short_notm}} dashboard in a new browser tab. The
All Boards
page is displayed by default. - Create a device type.
- From the main menu, select Devices, and then click Add Device.
- In the Add Device page, click Create device type.
- In the Create Device Type page, click Create device type.
- Enter a unique name and description for your device, and click Next.
- (optional) Defining a Template and Metadata on the next two pages is optional and can be safely skipped by clicking Next on each page.
- Click Create to add the device type.
- Add a device that uses the newly created device type.
- On the Add Device page, the device type that you just created is displayed in the list of device types. Click Next to add a device that uses that device type.
- Enter a unique device ID (for example, LivingRoomThermo1).
- (optional) Providing descriptive data on the Add Device page or entering device metadata on the next page is optional, and you can safely skip those pages by clicking Next on each page.
- On the Security page, click Next to generate an authentication token for your device.
- On the Summary page, verify that the information is correct and click Add to add the device. Click Back to return to a previous page.
- Make a note of the information that is displayed in the Your Device Credentials page. You need the following information to configure the simulator and display the data:
- Organization ID
- Device Type
- Device ID
- Authentication Method
- Authentication Token
{: #confignodered} Configure the Node-RED device simulator. Use the device simulator to send MQTT device messages to {{site.data.keyword.iot_short_notm}}. The device simulator sends temperature and humidity information to {{site.data.keyword.iot_short_notm}}.
- Launch the Node-RED flow editor.
- From your {{site.data.keyword.Bluemix_notm}} dashboard, open your Node-RED instance by clicking the Route link that is listed for your {{site.data.keyword.iot_short_notm}} Starter app.
- Click Go to your Node-RED flow editor to open the editor.
- Deploy your device.
- Double-click the blue Send to {{site.data.keyword.iot_short_notm}} node in the Device Simulator flow.
- Verify that Authentication is set to Bluemix Service.
- Enter the Device Type and Device ID of your device and click Done.
- Deploy the device by clicking Deploy.
- Configure the Node-RED Temperature Monitor flow.
- Double-click the blue IBM IoT App In node in the Device Simulator flow.
- In Authentication, select Bluemix Service.
- Select All for Device Type, Device ID, Event, and Format.
- Click Done.
- Deploy your monitor by clicking Deploy.
- Validate the device connection.
- Open the {{site.data.keyword.iot_short_notm}} dashboard.
**Tip:** If the {{site.data.keyword.iot_short_notm}} dashboard is not already open in another tab, return to your {{site.data.keyword.Bluemix_notm}} dashboard, click the name of your {{site.data.keyword.iot_short_notm}} instance, and then click **Launch Dashboard**.
- From the main menu, select Devices.
- Click the name of the device that you added. The device information displays the connection status of your device.
- In your Node-RED flow editor, double-click the gray Send Data node, set the Repeat value to Interval, and set the frequency to every 3 seconds.
- Click Done.
- Deploy your changes by clicking Deploy.
The payload contains data points, such as those shown in the following example:
{"d":{"temp":15,"humidity":50,"location":{"longitude":-98.49,"latitude":29.42}}}
- (optional) Open the Debug tab to verify that messages are being created. 1. From the menu that is located in the heading section, select View. 2. Select Show Sidebar. 3. Click the Debug tab to see messages.
- In the {{site.data.keyword.iot_short_notm}} Device Information page, verify that you see data points from the device in the Sensor Information section.
{: #createcards} Create a board and cards to display device data in the {{site.data.keyword.iot_short_notm}} dashboard. For more information about boards and cards, see Visualizing real-time data by using boards and cards.
{: #createboard}
- Open the {{site.data.keyword.iot_short_notm}} dashboard.
Tip: If the {{site.data.keyword.iot_short_notm}} dashboard is not already open in another tab, return to your {{site.data.keyword.Bluemix_notm}} dashboard, click the name of your {{site.data.keyword.iot_short_notm}} instance, and then click Launch Dashboard.
2. Create a board to contain the cards for your simulated devices.
1. If the All Boards, page is not already displayed, select Boards from the {{site.data.keyword.iot_short_notm}} dashboard main menu, and then click Create New Board.
2. Enter a name for the board (for example, Home Environment) and click Next.
3. On the next page, click Create.
3. Double-click the board that you just created to open it.
{: #cardtemp}
- Click Add New Card, and then select the Line Chart card type, which is located in the Devices section.
- Select your device from the list, then click Next.
- Click Connect new data set.
- In the Create Value Card page, select or enter the following values and click Next. - Event: update - Property: temp - Name: Temperature - Type: Float - Unit: °C - Precision: 2 - Min: 0 - Max: 50
- In the Card Preview page, select L for the line chart size, and click Next.
- In the Card Information page, change the name of the card to Temperature and click Submit. The temperature card appears on the dashboard and includes a line chart of the live temperature data.
{: #cardhumidity}
- Click Add New Card, and then select the Gauge card type, which is located in the Devices section.
- Select your device from the list, then click Next.
- Click Connect new data set.
- In the Create Value Card page, select or enter the following values and click Next.
Event: update
- Property: humidity
- Name: Humidity
- Type: Float
- Unit: %
- Precision: 1
- Min: 10
- Max: 95
- In the Card Preview page, select M for the gauge size, and click Next.
- In the Card Information page, change the name of the card to Humidity and click Submit. The humidity card appears on the dashboard and includes a gauge that shows the live humidity data.
{: #cardlocation}
- Click Add New Card, and then select the Value card type, which is located in the Devices section.
- Select your device from the list, then click Next.
- Click Connect new data set.
- In the Create Value Card page, select or enter the following values.
- Event: update
- Property: location.latitude
- Name: Latitude
- Type: Float
- Unit: "°N"
- Precision: 2
- Min: -180
- Max: 180
- Click Connect new data set.
- In the Create Value Card page, select or enter the following values and click Next.
- Event: update
- Property: location.longitude
- Name: Longitude
- Type: Float
- Unit: "°E"
- Precision: 2
- Min: -180
- Max: 180
- In the Card Preview page, select L as the text size, and click Next.
- In the Card Information page, change the name of the card to Location and click Submit. The location card appears on the dashboard and shows the live latitude and longitude of the device.
What's next? {: #whatsnext} Now that your simulated device is sending data to {{site.data.keyword.iot_short_notm}}, you can continue to iterate on your IoT project.
-
Watch your cards display the data that is generated by your node-RED flow. Node-Red continues to send data until you stop it. To stop the simulated data, perform the following steps:
- In your Node-RED flow editor, double-click the gray Send Data node, set the Repeat value to Interval, and set the frequency to every 3 seconds.
- Click Done.
- Deploy your changes by clicking Deploy.
-
Search the IoT Recipes to connect a physical device such as a Raspberry Pi and send data to {{site.data.keyword.iot_short_notm}}.
-
Deploy a sample node.js application to visualize device data.
-
Password protect the Node-RED flow editor. By default, the editor is open for anyone to access and modify flows. To password-protect the editor, perform the following tasks:
- In the {{site.data.keyword.Bluemix_notm}} dashboard, click the name of your Starter application to open the application pages.
- Click Runtime to display the Runtime page.
- Click Environment variable to display the Environment Variables page.
- In the User Defined section, click Add and then enter the following user-defined variables:
- NODE_RED_USERNAME - the user name to secure the editor
- NODE_RED_PASSWORD - the password to secure the editor
- Click Save.