send data using android Bluetooth to Arduino - android

Good day.
I want to send Accelerometer readings from the Android to Arduino using Bluetooth communication. I don't want to write the code to discover devices around and connect or connect to them through program interface . I can connect to the other device manually by the android setting.all I want to do is to send the string through output buffer or anything while i connect manually to the Arduino bluetooth but the tutorials out there shows how to connect and discover device.
I have been struggling to know how to send data (string or int) and i really don't care about discover and connect because i can do this manually from my android settings
thank you in advance

Sensors, Arduino devices and other hardware systems typically work on SERIAL PORT PROFILE (SIP). You may wanna double check this with the specific hardware you are dealing with. But I am quite sure it is SIP. If that is the case, you can literally copy and paste android chat sample code and change UUID to default UUID of Serial Port.
Just replace UUID of the sample with this: 00001101-0000-1000-8000-00805F9B34FB
The UUID is the chat example is defined in BluetoothChatService.java. You can change both secure and insecure UUIDs.
This is the sample: https://android.googlesource.com/platform/development/+/eclair-passion-release/samples/BluetoothChat

Related

Can multiple phones be connected to same Arduino via Bluetooth using MIT App Inventor?

I am currently working on a project in MIT App Inventor, where I am connecting an Android device to an Arduino via Bluetooth.
Is it possible to connect multiple Android phones to this Arduino, and is there a procedure by which an Arduino could distinguish between them?
I assume, that you are using a serial bluetooth device, such as HC-06 or HC-05. As I know, even the master module HC-05 can only connect to one client at a time (which makes sense, since the serial connection on the other side is the same)(despite the fact, that bluetooth in principle allows handling multiple clients at a time, though it's a rather complex task). This means, that you would have to use one serial bluetooth module for each phone, you want to connect at the same time.
When using more than one bluetooth module, you have to connect them to the Arduino over serial, but only one device can use the serial connection at a time. Depending on the number of phones, you want to connect, you can use either the SoftwareSerial library to emulate more than one serial connection (so every connection can be identified by its own SoftwareSerial object), or you have to multiplex your data lines between the different serial bluetooth devices (so that you control the serial connection to the devices with for example setting digital pins). For the last mentioned possibilities, I'm not sure about the property limits in the serial connection. Maybe you can multiplex just only with a few transistors.
If you want not only distinguish between the different connections but directly between different phones (for example to remember special settings for only your phone, not the others) you would have to send an identification over bluetooth to the Arduino (for example the MAC adress of the phone).
For more help, you should state you question in a better way and telling more details

Sending serial data from android to a PICAXE microcontroller with usb cable

I am working on a project that including an android phone that sends simple serial messages to a picaxe microcontroller(14m2) like '1','2','a' etc.
I searched alot on the web, and I only found a way that the android smartphone first "connecting" to the device and "discover" it, the problem is that PICAXE microcontroller is NOT a 'USB' device, and it can't be discoverd by the android, that means the android will not be able to send serial messages to the PICAXE.
if theres any way to send simple pulses from android to PICAXE, please let me know about it.
EDIT: There's any way to do that by connecting the AXE027 download cable with OTG?
I do some project with communicating over serial port. You can use chineese bluetooth adapters (see on ebay arduino bluetooth), those communicate with controllers via Usart and connect to phone by bluetooth. There is sample project Bluetooth chat from google about how to use bluetooth on android. On hardware iside, you can use arduino for receiving data by bluetooth and converting it in format of your controller. You wont have to use any wires

Bluetooth communication between an Android phone and a hardware device supporting bluetooth

I'am trying to make an app that receives some binary data from a other device which is not running android. The Android phone should not transfer any data to this device. So over to my questions:
Should the phone act as the server which establishes the RCOMM channel?
Is it possible to connect the phone and this device without paring, as long as I know the MAC-address of the device? If so, how?
And yes, I have read http://developer.android.com/guide/topics/connectivity/bluetooth.html so no need to only answer with that link. :)
Thanks in advance!
1)
Phone should act as a receiver.
I found that the tricky part is to use correct UUID.
If you connect two phones you should be generating those and everything work fine, but on your hardware you can't change UUID that easily.
Take a look at these reserved UUIDs.
For a Serial Port Profile's (SPP) communication use UUID 00001101-0000-1000-8000-00805F9B34FB.
2)
You can connect to a device without pairing if you already know the MAC address, you don't even need to use BlueTooth discovery.
To get device using MAC address call getRemoteDevice(String)
and then createRfcommSocketToServiceRecord(UUID) to get BlueToothSocket.
Also take a look at checkBluetoothAddress(String) to validate MAC address.

How to connect application and Arduino Via Bluetooth in Android?

I have Ardunio board.I want to connect this Board through my application Via Bluetooth,and want to send my Tweets in this Ardunio board. Is this possible?
Please reply,
Thank you
I'm assuming that you already have a bluetooth shield for your Arduino, if not, then you must get one. Sparkfun carries a variety of different ones, I like to use the following: http://iteadstudio.com/store/index.php?main_page=product_info&cPath=18%E2%88%8Fucts_id=307
These will allow serial communication with your Arduino. The example bluetooth code: http://developer.android.com/resources/samples/BluetoothChat/index.html can be used "as is" to send messages to the Arduino for testing. You can also easily modify this example to meet your needs.
You will use the device acitity list code to detect your device and get the MAC address which is used to initiate the connection to your bluetooth shield. The service code allows you to connect, send and receive messages from the bluetooth device.
On the Arduino side you simply need to read and write via serial to send and receive the data.

How to find out which Bluetooth profile is used for communication

I need to use Bluetooth for communication with another application which sends data via bluetooth SPP profile. I use the Bluetooth Chat app from Android developer site. I am using real phone (HTC Desire) as there is no Bluetooth API in Android emulator. I use a BlueSoleil bluetooth dongle.
When the other application tries to connect to my phone via Bluetooth and send data via SPP, it is not possible to connect the phone to the application. So I tried Windows Hyperterminal to send data and connect the phone through the dongle. In this situation, I can receive the data and display on the phone.
I would like to know how to find out which bluetooth profile was used when communicating with Hyperterminal.
I have read that bluetooth stack has a buggy implementation in HTC Desire and the SPP profile doesn't work consistently always.
Appreciate any suggestion and time spent on this.
Cheers,
Madhu Nandan
In the case of your Hyperterminal communication - SPP profile that was most likely used.
SPP profile is a generic profile that just establishes the RFCOMM data channel and sets up a virual COM port for applications to open and connect to and send data.
SPP does not specify any data formats or application level communication protocol to be used by application.
So applications at both end should establish the required format/protocol for communication.
Applications sets it selfs up on a virtual COM (over SPP) and advertises itself (on SDP) via a unique UUID (And Service Names)
So I would suggest that you use the chat application as a starting point, and start with connection / reading data etc, then modify it and complete the application that talks to your application on the device.
(The chat example is meant to work with a remote chat of the same type and is not a generic usage for SPP profile application)
Hope this helps you.

Categories

Resources