So, recently I follow these series of tutorial How to - Arduino android bluetooth real time graph - YouTube To connect Arduino with Android using Bluetooth module HC-05
I did exactly on his scheme, the bluetooth module detected as HC-05 on my android, but won't get paired.
The red LED keep blinking as Using the HC-06 Bluetooth Module | MCU on Eclipse
said that the red LED on the module indicates the status:
blinking: ready to pair
steady on: paired
here is the code that I should get output "(Paired)" beside my device name
receiver = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)){
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
devices.add(device);
String s = "";
for(int a=0;a<pairedDevices.size();a++){
if (device.getName().equals(pairedDevices.get(a))){
//append
s = "(Paired)";
break;
}
}
listAdapter.add(device.getName()+" "+s+" "+"\n"+device.getAddress());
}else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)){
}else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)){
}else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)){
if (btAdapter.getState() == btAdapter.STATE_OFF){
turnOnBT();
}
}
}
};
instead i got a toast saying that the device is not paired
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
if (btAdapter.isDiscovering()){
btAdapter.cancelDiscovery();
}
if (listAdapter.getItem(arg2).contains("(Paired)")){
BluetoothDevice selectedDevice = devices.get(arg2);
ConnectThread connect = new ConnectThread(selectedDevice);
connect.start();
}else {
Toast.makeText(getApplicationContext(), "device is not paired", 0).show();
}
}
here is code arduino side
#define sensor A0
void setup (){
Serial.begin(115200);
}
void loop(){
if (Serial.available()>0){
char re = Serial.read();
switch (re){
case 'E':
start();
break;
}
}
}
void start(){
while(1){
Serial.print('
what did I miss? note: I am using, external power supply Module HC-05 with two chip (on video there is only one chip) Arduino UNO (on videos used Android Pro Mini));
Serial.print(floatMap(analogRead(sensor),0,1023,0,5),2);
delay(10);
if(Serial.available()>0){
if (Serial.read() == 'Q') return;
}
}
}
float floatMap(float x, float inMin, float inMax, float outMin, float outMax){
return (x-inMin)*(outMax-outMin)/(inMax-inMin)+outMin;
}
what did I miss? note: I am using, external power supply Module HC-05 with two chip (on video there is only one chip) Arduino UNO (on videos used Android Pro Mini)