Join us for Code @ Think 2019 | San Francisco | February 12 – 15 Register now Limited availability
By Daniel Beguelin | Published November 10, 2015 - Updated December 18, 2017
This tutorial shows how you can send sensor data that is generated by your smartphone to the IBM Watson IoT Platform cloud-hosted service, and then create Cloud Foundry apps on the IBM Cloud that process, visualize, and store the data. Lastly, it shows you how to create an Android application for a smartphone.
Here is an overview of the architecture:
Try IBM Cloud for free
Build your next app quickly and easily with IBM Cloud Lite. Your free account never expires, and you get 256 MB of Cloud Foundry runtime memory, plus 2 GB with Kubernetes Clusters. Get all the details and find out how to get started. And if you’re new to IBM Cloud, check out the IBM Cloud Essentials course.
The Internet of Things Platform Starter boilerplate contains a Node-RED engine that you will use later to process IoT messages. For now, you will create an Internet of Things service to send and receive MQTT messages to and from the IBM Watson IoT Platform.
Now you are ready to send MQTT messages from a device to the IBM Watson IoT Platform.
If you have an iPhone or iPad, you can use the IoT Starter for iOS. Installation on the iPhone is not covered in this article, but if you do it on your own, you can use the iOS app for the rest of this tutorial.
You will use the IoT Starter for Android app to read and send sensor data on your smartphone. The source code and documentation of the app are in the iot-starter-for-android GitHub project.
If you are experienced in Android development, you can download the code from GitHub, import it into your Android development environment, and then build the apk file. Otherwise, to get the app installed and running quickly, follow these steps.
Note: The .apk file is compiled for Android version 5.0.1, but it also has been tested and works on Android 6. If you have installed an older version of this app, you need to uninstall it before installing the this one.
Get the code
Next, you need to configure your Android app.
Now you are ready to work with the message data on IBM Cloud.
Node-RED is a visual tool that makes it easy to wire and process Internet of Things messages. You can learn more about Node-RED in this Hands-on IoT video, An introduction to Node-RED.
In this section, you will enhance your IBM Cloud IoT app by using a Node-RED flow to process messages from your smartphone, and then send messages back to your smartphone. The phone will react on these messages by changing the background color in the app.
Run the app
You now have two-way communication between your smartphone and the first IBM Cloud IoT app.
Note: This app is documented on the IBM Cloud Docs for the Internet of Things Platform service.
In this step, you create an additional app in the IBM Cloud, which receives the messages from your smartphone (now an IoT device) and visualizes the data.
cf api https://api.ng.bluemix.net
cf login -u _<your_bluemix_login_id>_
cf login -a https://api.eu-gb.bluemix.net // United Kingdom
cf login -a https://api.eu-de.bluemix.net // Germany
cf login -a https://api.au-syd.bluemix.net // Sydney
cf push <your_application_name>
App <your app name> was started using this
command 'node app.js'
In this tutorial you learned how to easily turn your smartphone into a sensor device, connect it to the IBM Watson IoT Platform, and send and receive data. You also learned how to process and visualize device data on the IBM Cloud. With these two apps, you can recognize the value of IBM Cloud for the Internet of Things, and all you need is your own smartphone.
Back to top