Skip to content

A lightweight .aar library to create easily a stable bluetooth connection between Android and Arduino.

License

Notifications You must be signed in to change notification settings

giuseppebrb/Ardutooth

Repository files navigation

Ardutooth

Ardutooth Version Download

Ardutooth Banner

Ardutooth is a lightweight Android Archive Library (.aar) that allows you to create easily a stable bluetooth connection with an Arduino board. Once a connection has been established, you can fetch information about it or send data to the board (reading has not been implemented yet).

How to use it

The first thing you need is to get an instance of Arduooth, preferably insde the onCreate() callback, by the getInstance(activity) method: Ardutooth mArdutooth = Ardutooth.getInstance(activity); where the parameter represents the current activity.

After that you can allows user to established a bluetooth connection with mArdutooth.setConnection();. This simply method will check if bluetooth is supported on the current device, if is it turned on and if it's already connected with another bluetooth device. If bluetooth is supported but not turned on or disconnected a series of dialogs will guide user through the process. Bluetooth off Bluetooth not connected

You can check if connection has successfully established using mArdutooth.isConnected();

Once a stable connection has been established, you can send data to your Arduino throgh the Serial Monitor with these methods:

  • mArdutooh.sendInt(value)
  • mArdutooh.sendLong(value)
  • mArdutooh.sendShort(value)
  • mArdutooh.sendFloat(value)
  • mArdutooh.sendDouble(value)
  • mArdutooh.sendBoolean(value)
  • mArdutooh.sendChar(value)
  • mArdutooh.sendString(value)

The library offers also methods to retrieve information about Bluetooth module, output stream and socket.

To close communication, simply use mArdutooh.disconnect();

Arduino Side

You can find a very basic sketch for arduino to the path /Arduino_Basic_Sketch/Basic_Sketch.ino. Obviously this is a basic demo but it shows you how arduino could read data through the Serial Monitor and could be a starting point for your own sketch.

Final Note

You can download the latest ardutooth .aar file in here

If you don't know how add an .aar file to your Android Project take a look here: Add your library as a dependency - Android Developer

If you want add/edit features, any improvements is really appreciated. Just fork and pull request.

About

A lightweight .aar library to create easily a stable bluetooth connection between Android and Arduino.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published