3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Android talks to Arduino

Android talks to 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.

Here's the full video instruction that we'll break out into steps:

 
Remove these adsRemove these ads by Signing Up
 

Step 1Hardware list

Hardware list
Hardware
- Arduino Uno (328, 16MHz, 5V).
- Bluetooth Modem: BlueSMiRF Gold, aka FireFly (Sparkfun sku: WRL-00582).
- Parallel LCD (Sparkfun sku: LCD-09051 but you can use pretty much any parallel LCD).
- 10k Potentiometer.
- Wires to connect electronic components.
- Computer and FTDI chip (to change BAUD rate).
- Android Phone (I used a Motorola Droid - operating system v2.2.2 - but Google has sample code for all versions).

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.  :)
« Previous StepDownload PDFView All StepsNext Step »
19 comments
Mar 26, 2012. 11:35 AMervman1 says:
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.

731
7
31


Any idea what could be causing this? I set the baud rate of the modem to 57600..thanks again
Apr 4, 2012. 2:19 PMervman1 says:
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.

Thanks again,
Ervin
Apr 23, 2012. 6:38 AMmerciyas says:
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.

case MESSAGE_READ:
byte[] readBuf = (byte[]) msg.obj;
// construct a string from the valid bytes in the buffer
String readMessage = new String(readBuf, 0, msg.arg1);

//messageString is declared as an empty global variable String
messageString = messageString + readMessage;

//the length of my message is 60
if (messageString.length()<60){
break;
}

//Get time
String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());

mConversationArrayAdapter.add(mydate +" : \n"+ messageString);
messageString = " ";
break;

Mar 17, 2012. 3:43 PMAcousticAchilles says:
To use the Arduino sketch just open with notepad then copy and paste to a blank Arduino sketch
Feb 8, 2012. 8:27 PMVorsorken says:
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.
Dec 19, 2011. 8:47 AMMechapinata says:
Thanks fella! it worked perfectly!
Dec 12, 2011. 11:41 AMYewfort says:
Could you send text based commands to the arduino this way?
Nov 26, 2011. 12:07 AMMaki_mx says:
Question: Could you still do all of these with a BlueSMiRF Silver? the only difference with the Gold one is the range?
Thanks in advanced :D
Nov 16, 2011. 11:34 AMshaadmahmud says:
hello can i use any kind of bluetooth....with this project......:)
Nov 17, 2011. 7:21 AMatif khair says:
Appreciate your work that you can use your android phones with Arduino devices.
Jaycon
Nov 11, 2011. 11:15 AMcoder512 says:
rename the tmp to dot pde
Oct 26, 2011. 4:08 AMfdelatorre says:
Hi, thanks for the info on this little system you created.

the file "bluetooth_chat_LCD.pde" is downloaded as a tmp file. I think this needs to be fixed?

thanks
frank
Jul 7, 2011. 10:56 PMrmashhadi says:
Very Good !
Apr 23, 2011. 1:59 PMbsoares says:
Muito bom, criei algo parecido!

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
7
Followers
2
Author:circuit_breaker