Android Talks to Arduino




Introduction: 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

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

Step 2: Software List

- Arduino Source code from this project (bluetooth_chat_LCD.pde attached below)
- NewSoftSerial library from Mikal Hart:
- Eclipse
- Android Development Kit (explicitly follow all of Google's installation instructions)
- "Bluetooth Chat" Android sample code from Google:
- Hyperterminal or TeraTerm to change BAUD rate

Android Beginners (like me):
Make sure you do at least a couple tests before you execute the rest of this instructable:
- Create a "hello, world" app (lots of examples out there) to make sure you have Android/Eclipse setup correctly to run an app on a virtual device.
- Plug in your Android phone and ensure that you can copy the "hello, world" app to your phone.  Make sure your phone has debugging turned on. Settings --> Applications --> Development --> USB debugging (turn it on)

After you successfully copy an Android app to your actual phone, you can proceed with this instructable.  Keep in mind that you are not going to be able to run this instructable on a virtual device; you have to have a real phone to deploy the "Bluetooth Chat" code.

Step 3: Change BAUD Rate on BlueSMiRF Gold

Change the BAUD rate from the default 115.2k to 57.6k.  If you leave the BAUD at 115.2k, the parallel LCD will display gibberish when you send a message from Android to Arduino.  If you set the BAUD below 57.6k, the Android phone will "cut up" the message that the Arduino sketch sends every 30 seconds.  So 57.6k BAUD is just right.

*Commands to set BAUD:

*Video instructions on how to change BAUD:

FTDI Basic chip:

Step 4: Change Android "Bluetooth Chat" Sample App

Modify the Android app.  Make sure you watch the instructional video at the beginning of this instructable because I have recorded video of how to create a project from an existing sample app and where to change the code.

1. Open the "Bluetooth Chat" project.

2. Open the BluetoothChatService class, find the following declaration for MY_UUID, and replace with the code below:

    //Actual Unique UUID for this application generated by Android: fa87c0d0-afac-11de-8a39-0800200c9a66
    //common machine UUID that we need to communicate with FireFly Bluetooth module: 00001101-0000-1000-8000-00805F9B34FB
    private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

3. Attach your Android phone to your computer and, again, make sure your phone has debugging turned on.  Settings --> Applications --> Development --> USB debugging (turn it on)

4. Run your project within Eclipse and the program will deploy to your Android phone.

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

1. If you just ran the app within Eclipse then you don't need to click on the app icon on your Android phone; the app will launch automatically if your Android phone is plugged in to your computer's USB port and your phone's debugging is turned on.  If the app doesn't run automatically, find the "Bluetooth Chat" app icon on your phone and touch it.

2. Turn on your Arduino circuit.  Your BlueSMiRF Gold bluetooth modem LED will slowly blink red.

3. Pair your Android phone to your Bluetooth modem if you haven't done that already.  Do this using the Android's normal Bluetooth pairing process under "settings" --> "wireless and networks" --> "bluetooth settings" --> "Scan for devices" --> select the Firefly.  You may need to type "1234" password if your FireFly requires a password.  

4. After you pair the phone with the FireFly bluetooth modem, you need to connect the Android phone to the Firefly.  Confusing?  Maybe, but those are two separate steps: Pair the phone with the Firefly (one time) and then connect the Android "Bluetooth Chat" app to the Firefly (every time you use the app).  You can do both steps at once in the "Bluetooth Chat" app if you didn't pair the device in the step above.  After opening the "Bluetooth Chat" app, click on the Android menu button, click "Connect a device" --> "scan for devices" --> find the "FireFly" device, then the app will pair the phone with the Firefly. You may need to type "1234" password if your FireFly requires a password.  Now you have both paired and connected and your bluetooth modem LED should turn a solid green.  

Future use of  the "Bluetooth Chat" app will not require you to pair the phone with the Firefly but you will always need to connect the phone with the Firefly before you can send messages from Android to Arduino and back.  

5. Type a message in the "Bluetooth Chat" Android app and press "send".  In the instructional video at the beginning of this instructable, I typed "hi".

6. Wait for the "Hello from Arduino" message that will display on your Android phone.  This message is sent twice from the Arduino sketch code, 30 seconds after you start the Arduino sketch and then again 30 seconds later.  I tried to keep this proof-of-concept as simple as possible so please customize/change this as you wish.

Have fun!

Be the First to Share


    • Tinkercad to Fusion 360 Challenge

      Tinkercad to Fusion 360 Challenge
    • Stick It Challenge

      Stick It Challenge
    • Make It Modular: Student Design Challenge

      Make It Modular: Student Design Challenge



    10 years ago on Introduction

    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


    Reply 10 years ago on Introduction

    Hi ervman1,
    I've noticed the same thing and don't know what causes that. I'll try to check it out soon.


    Reply 10 years ago on Introduction

    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,


    Reply 10 years ago on Introduction

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


    Reply 10 years ago on Introduction

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

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

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

    Tze YeenY
    Tze YeenY

    Reply 4 years ago

    HI there, by any chance do you still have the code for this project? I have hard time following the steps and i couldnt make it work. Thanks! Would really appreciate your help.

    Wei-Hsiung Huang
    Wei-Hsiung Huang

    Reply 7 years ago on Introduction

    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.


    7 years ago on Introduction

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

    in this line, in void loop() part

    lcd.print(, 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. :)


    7 years ago

    saya suka projectnya.. terima kasih ya


    7 years ago on Step 4

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


    7 years ago on Step 4

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


    8 years ago on Step 4

    If allowed possible code transmitter via Bluetooth


    8 years ago on Introduction


    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!???


    9 years ago on Introduction


    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.


    10 years ago on Introduction

    Could you send text based commands to the arduino this way?


    Reply 9 years ago on Introduction

    As an alternative, I suggest my own Andriod to Arduino control using pfod (

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