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 ads by
Signing UpStep 1Hardware 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. :)
| « Previous Step | Download PDFView All Steps | Next Step » |











































731
7
31
Any idea what could be causing this? I set the baud rate of the modem to 57600..thanks again
I've noticed the same thing and don't know what causes that. I'll try to check it out soon.
Thanks,
Mark
Thanks again,
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.
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;
Thanks in advanced :D
Jaycon
the file "bluetooth_chat_LCD.pde" is downloaded as a tmp file. I think this needs to be fixed?
thanks
frank