Deploy IoT-Phone application to Bluemix
The IoT Recipe makes use of the Create Toolchain button to help deploy the necessary services on to Bluemix. You can take a look at the source code, made available under the Github Repository over here, to get to know on what is happening in the backend.
Click on the Create Toolchain button provided below, provide a Custom Name to your application and choose to click on Create button, to quickly deploy the Watson IoT Platform, Node-RED application and Cloudant NoSQL DB, as part of the Bluemix starter app.
Note: If you are a User using the United Kingdom Region in your Bluemix environment, then please make use of the steps mentioned in the IoT Recipe Deploy Internet of Things Platform Starter service on Bluemix to deploy the setup. Alternatively, you can also try using the Deploy to Bluemix button, to deploy the setup under your United Kingdom Region, provided your Jazzhub account is validated. Users of US South Region can ignore this step.
Post successful deployment, you shall have all three of the above mentioned services, up & running in your Bluemix environment.
Open the Bluemix Dashboard and click on the Application service that you have currently deployed. You should see the Watson IoT Platform listed under the Connections. Click on the WIoTP service and choose the click on Launch button to launch the WIoTP Dashboard.
Connect smartphone to Watson IoT Platform
- Open the Bluemix dashboard in a browser.
- Locate the IoT-Phone application under applications.
- Go to your smartphone and enter the URL shown on the Routes in the application. Start the location service in your smart phone. Ensure that the mobile device does not get locked or goes in a disconnected state. This completes the activity to be done on the mobile.
- In the smartphone you would be prompted to enter a device Id. Enter any unique 8 alphanumeric characters for the device Id. Select Connect on your smartphone and your phone is now an IoT Device.
- In case the smart phone asks for location to be shared, select yes.
- Open the Bluemix dashboard in your system browser and find the Internet of Things service (which could be named as iot-phone-iotf-service.
- On Watson IoT Platform Dashboard, select Devices to see the IoT devices connected. The connected device has an image of 3 rectangle bars of increasing height (similar to the signal strength seen in some mobile handsets) as shown below. You should see your smartphone connected and sending data.
- You can view the device events by hovering the mouse over the connected device and clicking on it.
To use Watsonâ„˘ IoT Platform features such as rules and actions, you must create a schema to map device properties to user-friendly properties names, set the data units for the properties, and specify a message type to use with the schema. Refer here for more information on creating device type schemas: https://console.ng.bluemix.net/docs/services/IoT/im_schemas.html
- Click on Manage Schemas tab and then click on Create a Schema as shown below.
- This will open up Add Schema page. Select Device Type and click Next as shown below.
- Click on Add Property. This opens up the add property page. Here selection is done from Connected tab and all properties are selected as shown below.
- Click OK and click Finish to complete creation of adding properties.
Create an Action
With Watsonâ„˘ IoT Platform cloud analytics, you can specify rule conditions that are based on real-time device data and that trigger alerts and optional actions when met. Rules are condition-based decision points that match real-time device data with predefined threshold values or other property data to trigger an alert if a condition is met.
In addition to the alert that is displayed in the Watsonâ„˘ IoT Platform dashboard, you can add one or more actions,Â such as sending emails and posting webhooks when a rule is triggered. Refer here for more information on creating the actions: https://console.ng.bluemix.net/docs/services/IoT/cloud_analytics.html#shared
One can create actions directly in the rule editor or create the actions in the Actions tab and then select the actions when you create your rules. In this step, we will show how to create an action that can be associated to the rule later.
- Click on the Rules and select Actions on the dashboard.
- Click on the Create An Action button on the right corner of the screen.
- This will open up the Create New Action page as shown below.
- Fill the actions page and Configure the action as per the requirement and click Finish.
- You will see new Action created under Rule Actions.
For creating various actions refer this recipe: https://developer.ibm.com/recipes/tutorials/perform-actions-in-ibm-watson-iot-platform-cloud-analytics/
In this step we will create a simple condition based rule and associate it the email action that we created earlier.
- Click on the Rules and select Browse on the dashboard.
- Click on the Create Cloud Rule on the right corner of the page.
- Fill the details for the Cloud Rule and Click Next.
- Define the rule.
- This rule is defined as :- if the ob is equal or more than 100, then send an e-mail to the supplied address.
- After adding the rule it needs to be activated. Click on the Activate button.
- Similarly created the rule for Alpha field, the example has the threshold value of 100.
- Above rules are created in such a way that alert will be triggered every time a condition is met.
Create Conditional rule triggers
Depending on the message frequency and the rule conditions, a rule might trigger a large number of times after a trigger condition is met. To control the number of alerts that are triggered for a rule over a time period, you can configure conditional trigger requirements for your rule. For more information on the conditional rule triggers: https://console.ng.bluemix.net/docs/services/IoT/cloud_analytics.html#conditional
- To configure conditional rule triggers, click on the rules dashboard and click on Trigger every time condition is met as shown below.
- Configure the set frequency requirement for the rule. In this case action will be triggered if the threshold reaches 5 times in every 30 mins.
Now, when the devices begin sending events, the rules will analyze the data in real time and take action when a threshold is broken.
- Dashboards for analytics can be viewed in Boards as shown below.
- Alerts for a particular device can be viewed under Rule Alerts For That Device in Device-Centric Analytics.