Proximity-based Bluetooth triggers with Arduino + Android

This tutorial shows you how to get started with Temboo's support for Arduino + Bluetooth when you're using an Android device to interact with the Bluetooth shield. We assume that you've read our Bluetooth getting started tutorial, and are looking for specific help with setting up your Android app.

NOTE: we've chosen Android Studio as our development environment, but the instructions should still be helpful regardless of which Android IDE you're using.

Get Set Up

1First, make sure you've read our Bluetooth getting started tutorial. If you haven't already you should go and do that now.

2Next, download the Android app from the Choreo page that you're interested in. Make sure that you've entered some inputs and successfully tested out the Choreo first.

3If you don't already have it, download and install Android Studio.

4Finally, make sure that you've downloaded the Temboo Android SDK.

Set up the app

5Create a new Android Studio project called "BLE". It should have the following properties:

6Move to the next screen. Select "Phone and Tablet" with the minimum SDK "API 18: Android 4.3 (Jelly Bean)". This is the minimum SDK that supports Bluetooth LE.

7Move to the next screen, select "Blank Activity" and move on again.

8Call your new blank Activity "TembooBLE". Change the layout name to "main".

9First, add the relevant files (temboo-android-sdk-x.xx-core.jar and the .jar files for the Choreos relevant to the your project) from the Temboo Android SDK to your project. You can find detailed instructions on how to do this in our Android SDK getting started tutorial.

10Navigate to main/java/com/temboo/ble/ in the Android app you downloaded from Temboo, copy those files, and paste them into the corresponding location in the Android Studio app that you just created i.e., TembooBLE/app/src/main/java/com/temboo/ble.

11You'll also need to add the RedBearLab Android BLE files to the same location as above. You can find those files over on the RedBearLab Github. An easy way to get these files is by hitting the "Download ZIP" button on their top-level Android repository page. Once you've downloaded them, copy them and then paste them into Android Studio.

12Next, copy + paste the following files/folders from the downloaded Android app into your new Android Studio app, replacing the default files:

13Before running the application, let's take a look at where the signal strength is checked so that you can easily adjust the proximity threshold that triggers the Choreo. Locate the class called TembooBLE.java. In the displayData method, you'll see where signal strength is checked.

Run the App

14With all the setup out of the way, you're ready to run your app. Make sure that your Android device is connected to your machine, that it has Bluetooth enabled and is connected to the internet, and that your Arduino board + BLE shield are running your Temboo BLE sketch.

15Run the app on your Android device and move it close to your Arduino board + BLE shield. The proximity reading should cross the threshold and your Choreo will be triggered on the Temboo platform!

16The result object of the Choreo is returned to the onPostExecute method in TembooTask.java. You can do whatever you want with these results. For example, you could print the outputs to the screen:


17That's it! You can run any Choreo in our library by replacing TembooTask.java with the Android Choreo Code generated on our site, and adding that Choreo's library files to "Supporting Files".

What Next?

Now that you know how use Bluetooth and Android to interact with Temboo, you're ready to create a project that uses auto-generated code from any of our 2000+ Choreos. We'd love to hear about what you make - hey@temboo.com.

Once you've got your code up and running, you're ready to move on and do more. From monitoring your running applications, to moving your generated Temboo code to your preferred development environment and sharing it with colleagues, collaborators and friends - we've got you covered.

Get Live Updates About Your Application

Integrate Temboo with Slack to get up-to-the-second notifications and alerts about your deployed Temboo code.

Commit Code to GitHub

Commit Temboo-generated code directly to GitHub and share with the world. Learn more.

Need Help?

If you ever need help with IoT Mode, now or in the future, please don't hesitate to get in touch.

Email us at support@temboo.com and we'll answer your questions.