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.  :)
<p>yo yo baby!</p>
<p>I am having a problem in the given code bluetooth_chat_lcd.pde.</p><p>in this line, in void loop() part</p><p> lcd.print(nss.read(), BYTE); </p><p>My Arduino compiler shows an error that BYTE can not be accessed from here!!</p><p>After removing BYTE from that line &amp; placing code in my arduino, the project is now working. Nothing shown on LCD.</p><p>Please help.</p><p>Thanks, in advance. :) </p>
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.<br><br>731<br>7<br>31<br><br><br>Any idea what could be causing this? I set the baud rate of the modem to 57600..thanks again
Hi ervman1,<br>I've noticed the same thing and don't know what causes that. I'll try to check it out soon.<br>Thanks,<br>Mark
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.<br><br>Thanks again,<br>Ervin
Hi Ervin,<br>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, <br>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. <br> <br>I am now sending fixed number of bytes from Arudino (even though sometimes the actual data is less.). <br> <br>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. <br> <br>case MESSAGE_READ: <br> byte[] readBuf = (byte[]) msg.obj; <br> // construct a string from the valid bytes in the buffer <br> String readMessage = new String(readBuf, 0, msg.arg1); <br> <br> //messageString is declared as an empty global variable String <br> messageString = messageString + readMessage; <br> <br> //the length of my message is 60 <br> if (messageString.length()&lt;60){ <br> break; <br> } <br> <br> //Get time <br> String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime()); <br> <br> mConversationArrayAdapter.add(mydate +&quot; : \n&quot;+ messageString); <br> messageString = &quot; &quot;; <br> break; <br> <br>
<p>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.</p>
<p>Thank u boss!!</p>
saya suka projectnya.. terima kasih ya
<p>v.Gud.. ! Impressive </p>
<p>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 &quot;start with bluetooth &quot; so i need to open this bluetoothchat app with that button can someone plz help me out in this tooo....</p>
<p>thanks a bunch boss, i think the uuid change caused the connection. however still to recieve text from my device, looks hopeful</p>
<p>If allowed possible code transmitter via Bluetooth</p>
Hello!!:D <br> <br>I found this tutorial intriguing <br> <br>However I have a question Can I apply this instead of the bluetooth module smif gold rather use BT shield or arduino!???
Hello, <br> <br> I followed your instructions for controlling LCD with arduino and android. I received a junk message from arduino.I did not get message &quot;Hello from Arduino&quot;.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.
Could you send text based commands to the arduino this way?
As an alternative, I suggest my own Andriod to Arduino control using pfod (<a href="http://www.pfod.com.au" rel="nofollow">www.pfod.com.au</a>)<br> <br> No android programming is required and the Arduino code is simple.<br> <br> 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. &nbsp;<br> <br> 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.
Yes, you can modify the Android code to send any text message you want to the Arduino.
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....???? <br> <br> <br> <br> <br>byte data; <br>String message; <br> <br>void setup () <br> { <br>// Sets the serial communication: <br>Serial.begin (57600); <br> <br>// Sets the pins of the LEDs as output: <br>pinMode (6, OUTPUT); <br>pinMode (7, OUTPUT); <br>pinMode (8, OUTPUT); <br>pinMode (9, OUTPUT); <br>pinMode (10, OUTPUT); <br> } <br> <br>void loop () { <br> int i=0; <br>// See if something has been received from the serial port: <br>if (Serial.available()) <br> { <br> // Read the last byte received (value between 0 and 255) <br> data= Serial.read(); <br> <br> Serial.println (data); <br> <br>if (data=='q') //q <br>{ <br>digitalWrite(6, HIGH); // turn on LED 1 at pin6 <br>message = &quot;LED 1 On&quot;; <br>Serial.println (message); <br> <br>} <br>if (data=='a') // a <br>{ <br>digitalWrite(6, LOW); // off LED 1 at pin6 <br>message = &quot;LED 1 Off&quot;; <br>Serial.println (message); <br>} <br> <br>if (data=='c') //c <br>{ <br>digitalWrite(7, HIGH); //on LED 2 <br>message = &quot;LED 2 On&quot;; <br>Serial.println (message); <br>} <br> <br>if (data=='d') //d <br>{ <br>digitalWrite(7, LOW); // off LED 2 <br>message = &quot;LED 2 Off&quot;; <br>Serial.println (message); <br>} <br> <br>if (data=='e') //e <br>{ <br>digitalWrite(8, HIGH); //on LED 3 <br>message = &quot;LED 3 On&quot;; <br>Serial.println (message); <br>} <br> <br>if (data=='f')// f <br>{ <br>digitalWrite(8, LOW); //sets the LED 3 <br>message = &quot;LED 3 Off&quot;; <br>Serial.println (message); <br>} <br> <br>if (data=='g') //g <br>{ <br>digitalWrite(9, HIGH); //turn on LED 4 <br>message = &quot;LED 4 On&quot;; <br>Serial.println (message); <br>} <br> <br>if (data=='h')//h <br>{ <br>digitalWrite(9, LOW); //sets the LED 4 <br>message = &quot;LED 4 Off&quot;; <br>Serial.println (message); <br>} <br> <br> <br>if (data=='i') //i <br>{ <br>digitalWrite(10, HIGH); //sets the LED 5 <br>message = &quot;L5 high&quot;; <br>Serial.println (message); <br>} <br> <br>if (data=='j') //j <br>{ <br>digitalWrite(10, LOW); //sets the LED 5 <br>message = &quot;LED 5 Off&quot;; <br>Serial.println (message); <br>} <br> <br>if (data=='y') //y <br>{ <br>digitalWrite(6, HIGH); // turn on ALL LEDs <br>digitalWrite(7, HIGH); <br>digitalWrite(8, HIGH); <br>digitalWrite(9, HIGH); <br>digitalWrite(10, HIGH); <br>message = &quot;ALL LEDs ON&quot;; <br>Serial.println (message); <br>} <br> <br> <br>if (data=='z')//z <br>{ <br>digitalWrite(6, LOW); //Turn off all LEDs <br>digitalWrite(7, LOW); <br>digitalWrite(8, LOW); <br>digitalWrite(9, LOW); <br>digitalWrite(10, LOW); <br>Serial.println (&quot;ALL LEDs OFF&quot;); <br>} <br> <br>else <br>{ <br>digitalWrite(13, HIGH); //sets the LED 5 <br>delay(3000); //3sec <br>digitalWrite(13, LOW); <br>delay(3000); <br>Serial.println (&quot; else case executed &quot;); <br> <br>} ////end of else <br> <br>// Send response <br>Serial.println (&quot; end of loop &quot;+message); <br> <br>} <br>} <br> <br> <br> <br> <br> <br> <br>
To use the Arduino sketch just open with notepad then copy and paste to a blank Arduino sketch
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.
Thanks fella! it worked perfectly!
Question: Could you still do all of these with a BlueSMiRF Silver? the only difference with the Gold one is the range?<br>Thanks in advanced :D
I'm guessing it will work with the Silver but I don't know for certain. Thanks
hello can i use any kind of bluetooth....with this project......:)
I have only tested with the bluesmirf gold but the concept should be the same for any serial modem.
rename the tmp to dot pde
Hi, thanks for the info on this little system you created. <br><br>the file &quot;bluetooth_chat_LCD.pde&quot; is downloaded as a tmp file. I think this needs to be fixed?<br><br>thanks<br>frank
Very Good !
Muito bom, criei algo parecido!

About This Instructable




More by circuit_breaker:Android talks to Arduino Change BAUD rate on BlueSMiRF Gold 
Add instructable to: