bluetooth android application for interfacing with arduino

14
BLUETOOTH ANDROID APPLICATION Presented By: Sumit Chakraborty Pratik Shetty

Upload: sumit-chakraborty

Post on 25-May-2015

804 views

Category:

Technology


3 download

DESCRIPTION

This presentation describes the basic Bluetooth application that can be used to interface with Arduino and MSP 430 controllers

TRANSCRIPT

Page 1: Bluetooth android application For interfacing with arduino

BLUETOOTH ANDROID APPLICATION

Presented By:

Sumit Chakraborty

Pratik Shetty

Page 2: Bluetooth android application For interfacing with arduino

Contents

1. Introduction.

2. Bluetooth Basics.

3. Bluetooth Permission.

4. Setting Up Your mobile Bluetooth.

5. Connecting Android phone to Arduino(using Rn42).

Page 3: Bluetooth android application For interfacing with arduino

IntroductionIntroduction

Using the Bluetooth APIs, an Android application can perform the following:

•Scan for other Bluetooth devices.

•Query the local Bluetooth adapter for paired Bluetooth

devices.

•Establish RFCOMM channels.

•Connect to other devices through discovery.

•Transfer data to and from other devices.

Page 4: Bluetooth android application For interfacing with arduino

Bluetooth Basics All Bluetooth API’s are present in android.bluetooth package.

1.Bluetooth Adapter: It’s the entry-point for all Bluetooth interaction.

2.Bluetooth Device: It is used to  request a connection with a remote device through a BluetoothSocket or query information about the device such as its name, address, class, and bonding state.

3.Bluetooth Socket: This is the connection point that allows an application to exchange data with another Bluetooth device via InputStream and OutputStream.

Page 5: Bluetooth android application For interfacing with arduino

Cont..

4. Bluetooth Server socket: Represents an open server socket that listens for incoming requests.

5. Bluetooth Class: Describes the general characteristics and capabilities of a Bluetooth device.

Page 6: Bluetooth android application For interfacing with arduino

Bluetooth Permission

We need this permission to perform any Bluetooth communication e.g. requesting a connection, accepting a connection and transferring data.

If you want your app to initiate device discovery or manipulate Bluetooth settings, you must also declare the BLUETOOTH_ADMIN permission.

Page 7: Bluetooth android application For interfacing with arduino

Cont..

Page 8: Bluetooth android application For interfacing with arduino

Setting up the Bluetooth

Before your app can communicate over Bluetooth verify that Bluetooth is supported on your mobile.

BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();

  if(btAdapter==null) {

errorExit("Fatal Error", "Bluetooth not support");

} else {

if (btAdapter.isEnabled()) {

//promt user that the Bluetooth is already On

} else {

//Prompt user to turn on Bluetooth

Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);

startActivityForResult(enableBtIntent, 1);

}

}

Page 9: Bluetooth android application For interfacing with arduino

Managing a connection

The ConnectThread is a inner class, it passes a message to the Handler which then carries out the required action

Page 10: Bluetooth android application For interfacing with arduino

Cont..

Page 11: Bluetooth android application For interfacing with arduino

HandlerAllows you to send and process message and runnable object associated with a thread’s Message queue.

The main uses of Handler are:-

1.To schedule messages that can be executed as some point in the future.

2.To Enqueue an action to be performed on a different thread.

Page 12: Bluetooth android application For interfacing with arduino

Cont..

Page 13: Bluetooth android application For interfacing with arduino

Circuit Diagram

Bluetooth Module

FlexiForceSensor

Page 14: Bluetooth android application For interfacing with arduino