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:
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]);
}
}
}