Connection on HC-06 Bluetooth module:
VCC - connect to 3.3V
GND - connect to GND
RXD connect to TXD, to make it in loop-back mode.
In Android side, we will use the Android code sample of BluetoothChat. To make it work with HC-06, we have to modify the UUID. Refer to Android document http://developer.android.com/reference/android/bluetooth/BluetoothDevice.html, If you are connecting to a Bluetooth serial board then try using the well-known SPP UUID 00001101-0000-1000-8000-00805F9B34FB. Open file file com.example.android.bluetoothchat.BluetoothChatService.java in Android Studio, replace the code:
private static final UUID MY_UUID_SECURE =
UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");
to:
private static final UUID MY_UUID_SECURE =
UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
Then re-build, install and test it.
Test HC-06 Bluetooth Module with Android BluetoothChat
- Power on HC-06 (*caution 3.3V), the HC-06 LED will blink, to show it is not connected.
- Turn on Bluetooth on Android, pair with HC-06 with default password "1234". After paired, the LED on HC-06 still blink.
- Run the BluetoothChat example on Android, connect to HC-06. After connected, the LED stop blinking.
- Now you can enter text to test the bluetooth connection.
- Anything HC-06 received will echo back to Android. But in my test, sometimes the first character will be incorrect.
Next:
- Android example to communicate with Bluetooth device, HC-06 Bluetooth Module
5 comments:
Thank you this is very helpful
how to use the android app?
I tried this and immediately after selecting my device to connect to my phone gives me an update that it connected to a trusted device, but the bluetooth app tells me I am unable to connect is says it is unconnected at the exact same time, what is happening?
hello Brent Grimm,
I no no exact idea, sorry.
But I re-tried the BluetoothChat example recently and found it's problem on new Android Studio/Android version. Please refer to http://android-er.blogspot.com/2016/04/problem-of-bluetoothchat-example.html
Can you try to set target sdk version to Android 4.4, to see if any improvement? What device you test on?
I want to know reason also, thx for your comment.
Oh man I'm so thankful!!
I've been developing an app using code from the BluetoothChat and testing with phones. Now I'm in the final stage, testing with an actual HC06 module and I thought nothing worked. Thanks to your change line everything worked!!!
Post a Comment