Skip to content
Bluetooth helper Java class
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

BasicAirData BluetoothHelper
Releases GitHub license

Bluetooth Java Class for Android

This Java Class implements an easy message-based Bluetooth wireless communication layer between an Android device (the client) and a Microcontroller (the server).
Using this class you can Connect, Disconnect, Send String messages, Receive String messages via Listener (best way) or by explicit polling, automatically reconnect and check the status of your Bluetooth connection in a simple and thread-safe way.

The library is compatible with android 4.0 (API 14) and newer.

Here in this repo (in the Arduino/BluetoothHelperExample folder) you can also find a very simple example (around 100 lines of code, including comments) that shows how to use it.
You can find a complete implementation of this library in BasicAirData Air Data Bridge.

For further information about this library and its usage you can read this article.


Use Gradle

dependencies {
    implementation 'eu.basicairdata:bluetoothhelper:1.0.5'

Or Maven


Getting started


  • Add Bluetooth permissions to your AndroidManifest.xml:
<uses-permission android:name = "android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name = "android.permission.BLUETOOTH"/>
  • Declare a new BluetoothHelper instance into your activity:
BluetoothHelper mBluetoothHelper = new BluetoothHelper();
  • Setup a BluetoothHelperListener to receive the messages and the changes of the connection status:
mBluetoothHelper.setBluetoothHelperListener(new BluetoothHelper.BluetoothHelperListener() {
    public void onBluetoothHelperMessageReceived(BluetoothHelper bluetoothhelper, final String message) {
        // Do something with the message received
        // runOnUiThread(new Runnable() {
        //     @Override
        //     public void run() {
        //         // Update your UI
        //     }
        // });

    public void onBluetoothHelperConnectionStateChanged(BluetoothHelper bluetoothhelper, boolean isConnected) {
        // Do something, depending on the new connection status

Common Usage

  • As alternative, connect to a BluetoothDevice directly using its Device Name:
  • Send a message:
mBluetoothHelper.SendMessage("Hello World");
  • Check the connection status:
  • Disconnect:

For further information you can read the full BluetoothHelper API Documentation.

This repository contains

  • Android/BluetoothHelper.class = The Helper Class for Android;

The repo includes also a very simple but fully functional example, that shows how to use the helper class:

  • Android/BluetoothHelperExample/ = Example app for Android - around 100 lines of code, including comments - that controls 2 leds (one ON/OFF using a button and one in PWM using a slider);
  • Arduino/BluetoothHelperExample/ = The sketch for Arduino; this example (ready to be uploaded on Arduino 2009) is made to communicate with the example app;
  • doc/ = The related documentation. The folder includes the API documentation of the Class and the electrical scheme of the microcontroller circuit, showing one of the possible hardware configurations (Arduino 2009 + BlueSMIRF Gold);

General Information

BasicAirData Open and free DIY air data instrumentation and telemetry.

What is BasicAirData?

Reference documents

Code of conduct

Contributing Information

Repository License

You can’t perform that action at this time.