0

For a project I need to connect a Bluetooth Remote control with an Arduino Nano.

The Problem

I am trying to setup a connection to said Bluetooth remote Control. This device is visible! (I have confirmed it with a smartphone)

Here are the steps that I am trying to do with the Arduino and HC05 module:

AT <-- confirms, that Command Mode is running successfully
OK

AT+ROLE? <-- 1 For Bluetooth Master Mode
+ROLE:1
OK 

AT+CMODE? <-- 1 allows connecting to any BT address
+CMOD:1
OK

AT+INQM? <-- Show Inquiry access values
+INQM:1,1,48
OK

AT+INQ <-- Inquiry Bluetooth Device

After ~60 seconds, it just says "OK", but according to this tutorial or according to this youtube video it should display all Bluetooth-devices, that are ready to connect. The BT device is definately visible. (I tried multiple BT devices like smartphones and peripheral devices).

Why is the inquiry not working? What is wrong here?

The circuit is exactly like in this picture:

circuit

For setting up the Bluetooth-connection I wire the EN-Pin to +3,3V, which successfully activates AT-Command-Mode According to this site, you can do it like that.

Here is my code, that I use, to communicate with the module. - It works good!

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX | TX
// Connect the HC-05 TX to Arduino pin 2 RX. 
// Connect the HC-05 RX to Arduino pin 3 TX through a voltage divider.
// 

char c = ' ';
int buf[64]; //buffer to store AT commands
int len = 0; //stores the length of the commands

void setup() 
{
    Serial.begin(9600);
    Serial.println("Arduino is ready");
    delay(500);
    mySerial.begin(9600);  
    Serial.println("BlueTooth is ready");
}

void loop()
{

  if(Serial.available())
  {
    len = Serial.available(); //store number of bytes to read
    for(int i = 0; i<len; i++) //store all bytes into the buffer
    {
      buf[i] = Serial.read();
    }
    for(int i = 0; i<len; i++)
    {
      mySerial.write(buf[i]);
      Serial.write(buf[i]);
    }
  }


  if(mySerial.available())
  {
    len = mySerial.available();
    for(int i = 0; i<len; i++)
    {
      buf[i] = mySerial.read();
    }
    for(int i = 0; i<len; i++)
    {
      Serial.write(buf[i]);
    }
  }

}

Here is a related question but the answer doesn't help.

2

I did a factory reset of the device. That resolved the issue

AT+ORGL
AT+RESET

Another thing that is very important: The KEY-Pin (EV-Pin on some boards) must be HIGH (3Volts), during the INQ-command. If this PIN is not High, the inq-command will not work.

If you put 3V to this PIN and release it, you indeed are in AT-Command mode. But not all AT-commands work (e.g. the said at+inq command). If you want to enable all AT-commands the PIN must remain high.

0

Try this example from the datasheet:

AT+INIT
AT+INQM=1,9,48  // max of 9 devices, timeout of 61 seconds
AT+INQ

And use this in your loop() instead:

void loop() {
  while (Serial.available())
    mySerial.write(Serial.read());
  while (mySerial.available())
    Serial.write(mySerial.read());
}
  • Tried it, but this does not work, either. This command only changes the maximum devices, that can be found by the module. but since not a single one is found it doesn't help. – Michael B Jan 13 '16 at 15:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.