Skip to content

IBM-Cloud/sphero-bluemix-android

Repository files navigation

sphero-bluemix-android

This project is a simple Android app that demonstrates how to steer a Sphero ball via URL commands using IBM Bluemix, the MQTT protocol and the IBM Internet of Things service. Watch the video and read the slides to learn more.

<iframe src="//www.slideshare.net/slideshow/embed_code/key/GojsUXfMPU2Aty" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;" allowfullscreen> </iframe>

For the communication between the Android app and IBM Bluemix the MQTT client Paho from Eclipse is used that comes with the project. For the communication between the Android app and the ball over bluetooth the Sphero Android SDK is used. Since the SDK is not available under an open source license three files need to be downloaded and copied into the Android project.

Author: Niklas Heidloff @nheidloff

Import of the Android Project

Download these files from the Sphero SDK.

In the easiest case copy the files to the directories as documented in the screenshots before importing the project in Android Studio.

After this open Android Studio and import the project. This should result in the following project structure - Project, Android.

Setup of the Bluemix Application and the Node-RED Flow

In order to send commands to the Android app a Node-RED flow in IBM Bluemix is used in combination with the IBM Internet of Things Foundation.

Log in to Bluemix and create a new application, e.g. MySphero, based on the Internet of Things Foundation Starter. Additionally add the Internet of Things service to it.

In the next step you have to register your own device. Open the dashboard of the Internet of Things service and navigate to 'Add Device'. As device type choose 'and' (for Android) and an unique device id - screenshot. As result you'll get an org id and password - screenshot.

In order to import the flow open your newly created Bluemix application and open the Node-RED editor, e.g. http://mysphero.mybluemix.net/red, and choose [import from clipboard]((https://raw.githubusercontent.com/IBM-Bluemix/sphero-bluemix-android/master/images/nodered4.png). You find the flow in the sub-directory 'noderedflow'. In the outgoing IoT node select your unique device id and deploy the application.

Run the Android App and invoke URLs

Before running the app you need to enter the Internet of Things configuration from the previous step in the Java class net.bluemix.sphero.MainActivity: org, device id and password.

The app can not be run via the emulator but only actual Android devices. Make sure that both Wifi and Bluetooth are enabled.

Launch the app 'Sphero Bluemix' on your Android device and select your Sphero ball. Once the ball is connect, press the 'Connect' button to also connect to Bluemix. After this you can see the connected device in the IoT dashboard. You can now invoke the following URL commands to steer the Sphero ball.

alt text

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages