Picture of 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:

Step 1: Hardware list

Picture of Hardware list
- 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.  :)
ParamP14 months ago

I am having a problem in the given code bluetooth_chat_lcd.pde.

in this line, in void loop() part

lcd.print(nss.read(), BYTE);

My Arduino compiler shows an error that BYTE can not be accessed from here!!

After removing BYTE from that line & placing code in my arduino, the project is now working. Nothing shown on LCD.

Please help.

Thanks, in advance. :)

ervman13 years ago
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.


Any idea what could be causing this? I set the baud rate of the modem to 57600..thanks again
circuit_breaker (author)  ervman13 years ago
Hi ervman1,
I've noticed the same thing and don't know what causes that. I'll try to check it out soon.
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,
circuit_breaker (author)  ervman13 years ago
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. :)
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.

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){

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

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

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.

alx.camron5 months ago


vipul.swamy5 months ago

Thank u boss!!

Sasando_Rote8 months ago
saya suka projectnya.. terima kasih ya
jaydippatel9 months ago

v.Gud.. ! Impressive

ash12412 months ago

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....

jleighton21 year ago

thanks a bunch boss, i think the uuid change caused the connection. however still to recieve text from my device, looks hopeful

ehmedat1 year ago

If allowed possible code transmitter via Bluetooth

mkattouri1 year ago

I found this tutorial intriguing

However I have a question Can I apply this instead of the bluetooth module smif gold rather use BT shield or arduino!???
msoftgp2 years ago

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.
0151n3 years ago
Could you send text based commands to the arduino this way?
drmpf 0151n2 years ago
As an alternative, I suggest my own Andriod to Arduino control using pfod (www.pfod.com.au)

No android programming is required and the Arduino code is simple.

Very flexiable control of Arduino projects via menus, multi-selection lists, text input, numeric input, navigation screens all controlled by the Arduino code (think micro pages max 255 chars). Arduino can send updates back to Andriod.  

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.
0151n drmpf2 years ago
circuit_breaker (author)  0151n3 years ago
Yes, you can modify the Android code to send any text message you want to the Arduino.
rajusaleem2 years ago
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....????

byte data;
String message;

void setup ()
// Sets the serial communication:
Serial.begin (57600);

// Sets the pins of the LEDs as output:
pinMode (6, OUTPUT);
pinMode (7, OUTPUT);
pinMode (8, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);

void loop () {
int i=0;
// See if something has been received from the serial port:
if (Serial.available())
// Read the last byte received (value between 0 and 255)
data= Serial.read();

Serial.println (data);

if (data=='q') //q
digitalWrite(6, HIGH); // turn on LED 1 at pin6
message = "LED 1 On";
Serial.println (message);

if (data=='a') // a
digitalWrite(6, LOW); // off LED 1 at pin6
message = "LED 1 Off";
Serial.println (message);

if (data=='c') //c
digitalWrite(7, HIGH); //on LED 2
message = "LED 2 On";
Serial.println (message);

if (data=='d') //d
digitalWrite(7, LOW); // off LED 2
message = "LED 2 Off";
Serial.println (message);

if (data=='e') //e
digitalWrite(8, HIGH); //on LED 3
message = "LED 3 On";
Serial.println (message);

if (data=='f')// f
digitalWrite(8, LOW); //sets the LED 3
message = "LED 3 Off";
Serial.println (message);

if (data=='g') //g
digitalWrite(9, HIGH); //turn on LED 4
message = "LED 4 On";
Serial.println (message);

if (data=='h')//h
digitalWrite(9, LOW); //sets the LED 4
message = "LED 4 Off";
Serial.println (message);

if (data=='i') //i
digitalWrite(10, HIGH); //sets the LED 5
message = "L5 high";
Serial.println (message);

if (data=='j') //j
digitalWrite(10, LOW); //sets the LED 5
message = "LED 5 Off";
Serial.println (message);

if (data=='y') //y
digitalWrite(6, HIGH); // turn on ALL LEDs
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
message = "ALL LEDs ON";
Serial.println (message);

if (data=='z')//z
digitalWrite(6, LOW); //Turn off all LEDs
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
Serial.println ("ALL LEDs OFF");

digitalWrite(13, HIGH); //sets the LED 5
delay(3000); //3sec
digitalWrite(13, LOW);
Serial.println (" else case executed ");

} ////end of else

// Send response
Serial.println (" end of loop "+message);


To use the Arduino sketch just open with notepad then copy and paste to a blank Arduino sketch
Vorsorken3 years ago
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.
Mechapinata3 years ago
Thanks fella! it worked perfectly!
Maki_mx3 years ago
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
circuit_breaker (author)  Maki_mx3 years ago
I'm guessing it will work with the Silver but I don't know for certain. Thanks
shaadmahmud3 years ago
hello can i use any kind of bluetooth....with this project......:)
circuit_breaker (author)  shaadmahmud3 years ago
I have only tested with the bluesmirf gold but the concept should be the same for any serial modem.
coder5123 years ago
rename the tmp to dot pde
fdelatorre3 years ago
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?

rmashhadi4 years ago
Very Good !
bsoares4 years ago
Muito bom, criei algo parecido!