Step 4: Change Android "Bluetooth Chat" sample App

Step 5: Run the "Bluetooth Chat" Android app

Showtime : Run the Android app, then type messages to send from Android to Arduino (and Arduino to Android will happen automatically from the Arduino ...

This project slightly modifies the Google Android sample app called "Bluetooth Chat" so you can type a message in the Android app and that same message will appear on an LCD attached to an Arduino Uno.

Functionality: Android talks to Arduino
1. Run the Android "Bluetooth Chat" sample app (after we modify the app in this instructable). Type a message in the app's text box and press the "send" button. The message you typed echoes on the app display.
2. Message travels through the air from the built-in Android Bluetooth modem to the Bluetooth modem connected to the Arduino Uno.
3. Arduino Uno receives the typed message.
4. The Arduino Uno prints the typed message on the LCD.

Functionality: Arduino talks to Android
1. Every 30 seconds, the Arduino sends a message ("hello from Arduino") to the Android phone via Bluetooth.
2. The Arduino message appears on the Android "Bluetooth Chat" sample app display.
Why? Just an easy way to test the Arduino's ability to not only receive messages from, but send messages to the Android phone. You can take the example sketch and change it however you want.

Assemble your circuit as shown in the diagram. You don't have to assemble anything between circle #1 and circle #2: that is the message going through the air from Android to the Bluetooth modem. Hey, I'm an Arduino beginner so I'm not assuming anything. :)

Thank you very much for the tutorial. I got it working but I'm having one problem. The output on my android phone is split up sometimes. For example, I am transmitting the value of a potentiometer. Sometimes the phone will display the proper value such as 731 and other time it will display a 7, next line will hold 31. And other combinations.

731731

Any idea what could be causing this? I set the baud rate of the modem to 57600..thanks again

Any updates? I don't mean to rush but I've got a deadline for a project I'm doing at school and I can't figure out how to fix this. This is a small part of the project but without being able to display the right data I'm pretty much stuck. Is it possible to change baud rate at the java side? I've tried looking but it seems like this is not necessary and not doable.

Hi Ervin,I verified what you saw and, unfortunately, I could not remedy it. For me, I get the problem about 10% of the time. I haven't had the time to test some workarounds but you could implement something similar to a checksum concept where you put an extra fixed message in your Arduino data and then check if that message comes through on the Android side. If on the receiving end (Android) you don't get the extra message that you append to your data on the Arduino side then you don't display the reading on Android. It is not complicated in concept but would take time to implement and test considering that you have a deadline. This was just a quick little proof-of-concept for me; hope it did more good than harm for you. :)

Hi, I was having the same problem. I somehow compensated for it. I am a newbie in these, so its not a very scientific solution, but works for me.

I am now sending fixed number of bytes from Arudino (even though sometimes the actual data is less.).

In the HandleMessage() funciton of BluetoothChat.java, under the case MESSAGE_READ, I check how many bytes there are to print. If it is less than expected, I wait for more bytes to arrive before printing and append the received incomplete String to the String that I will print.

I've done some checking and I am pretty sure that this is a problem on the Android side, not on the Arduino side. You could verify it by running Bluetooth Terminal on your Android device and use it to receive the message from Arduino. All of the incoming message from Arduino to Android are O.K. on Bluetooth Terminal.

will anybody please tell me how should i do this step by step, i am not understanding like 1st we have to create a project under the name bluetoothchat then in this we have to create two other activities bluetoothchat service and device list activity?? i am confused in this please someone help me out in this ... in my app i have an icon for "start with bluetooth " so i need to open this bluetoothchat app with that button can someone plz help me out in this tooo....

I followed your instructions for controlling LCD with arduino and android. I received a junk message from arduino.I did not get message "Hello from Arduino".But I got this message in serial monitor.Also the typed message from Bluetooth chat application not displayed on LCD Monitor.Please give me your suggestions.

See www.pfod.com.au for numerous example projects, including showing text on an LCD. One user has coded the Arduino to run his KnightRider Lights from his Andriod using pfod with multiple menus, multiple screens and control options.

nice idea .... i am using this source code on android side. but when i send the chat message, i am trying to interpret it to control LEDs on arduino side. but every time only else case executes.i.e. Pin 13 gets on for few seconds..... below is my arduino code can any one please tell me where do i am making mistake....????

Could you comment on the range? Is the connectivity limited by the phone (something like 30 ft) or does it have a larger range since the BlueSmirf gold apparently offers up to 100 m? I'm designing an Android-controlled robot and would like to use a Bluesmirf. I need range up to maybe 100 ft though and I know my phone can't stay connected to my computer for more than about 30 ft.