HC-05 is not connecting with bluetooth

Even though wiring is fine and bluetooth can pair with HC-05, the HC-05 cannot connect to my phone, laptop, or tablet. What could be wrong that would make this issue happen? Also I have already used two different HC-05 chips, so I'm pretty sure that that is not the problem.

You need to get a HM-10 BLE module if you want to connect with your smart device / phone

What about a laptop or tablet?

Hello electrogod

Welcome to the best Arduino forum ever :slight_smile:

Have you paired the BT devices?

I have gotten a HC-05 to pair with a Bluetooth dongle but not directly with the laptop itself. I think it was either a 5.0 or a 5.1 dongle that worked.

What are you using to make the connection, Putty?

Normally the HC05 is in slave mode, and the devices you mention connect to the HC05.
Do you have an andoid phone or iphone?
As said, and I phone will require BLE.
If Android, I suggest that you use the Kai Morich SerialBluetoothTerminal app.
https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal&hl=en_US

The app can certainly connect to an HC05. Connection of a PC with Bluetooth to an HC05 is a more complicated process, and requires setting up an outgoing serial port.

https://forum.arduino.cc/t/hc05-disconnecting-and-not-entering-at-mode/1344975/9

There is no evidence it is fine, and quite a bit to suggest it isn't. Your laptop/phone/tablet successful pairing means no more than

  1. Bluetooth has power.
  2. Devices are compatible - which means you can studiously ignore replies #2 and #5.

There may be other issues, but I suggest you first check the wiring between Bluetooth and Arduino Tx>Rx and Rx<Tx .... again. If your Arduino is a 5v device, it is also advisable to have a 1k/2k voltage divider on Arduino Tx.

Yes I can pair them but not connect

I checked both TX and RX as well as the other wiring. It looks good and the light is blinking.

Also here is my code if anyone thinks thats the problem.

`#include <AFMotor.h>
#include <SoftwareSerial.h>

SoftwareSerial bluetoothSerial(9, 10); // RX, TX

//initial motors pin
AF_DCMotor motor1(1, MOTOR12_1KHZ);
AF_DCMotor motor2(2, MOTOR12_1KHZ);
AF_DCMotor motor3(3, MOTOR34_1KHZ);
AF_DCMotor motor4(4, MOTOR34_1KHZ);

char command;

void setup()
{
bluetoothSerial.begin(9600); //Set the baud rate to your Bluetooth module.
}

void loop() {
if (bluetoothSerial.available() > 0) {
command = bluetoothSerial.read();

Stop(); //initialize with motors stoped

switch (command) {
  case 'F':
    forward();
    break;
  case 'B':
    back();
    break;
  case 'L':
    left();
    break;
  case 'R':
    right();
    break;
}

}
}

void forward()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}

void back()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(BACKWARD); //rotate the motor anti-clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(BACKWARD); //rotate the motor anti-clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(BACKWARD); //rotate the motor anti-clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(BACKWARD); //rotate the motor anti-clockwise
}

void left()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(BACKWARD); //rotate the motor anti-clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(BACKWARD); //rotate the motor anti-clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}

void right()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(BACKWARD); //rotate the motor anti-clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(BACKWARD); //rotate the motor anti-clockwise
}

void Stop()
{
motor1.setSpeed(0); //Define minimum velocity
motor1.run(RELEASE); //stop the motor when release the button
motor2.setSpeed(0); //Define minimum velocity
motor2.run(RELEASE); //rotate the motor clockwise
motor3.setSpeed(0); //Define minimum velocity
motor3.run(RELEASE); //stop the motor when release the button
motor4.setSpeed(0); //Define minimum velocity
motor4.run(RELEASE); //stop the motor when release the button
}`

This is not a code issue. Can your phone with the Serial Bluetooth Terminal app connect to the module?

This is a separate process from sending and reading any commands. The pattern of blinking light on the module should change when connected.

Do not use pin 1, as this pin is already used by the IDE for serial communication.

Not an answer. Did the blinking change when you attempted to connect?

99% of your code is irrelevant, and your problem may well have nothing to do with Bluetooth anyway. What evidence is there that Bluetooth is at fault?
Try sending just a simple series of Hello to a phone terminal.

The light would be solid if it was connected.

No.

The 3 flash patterns of HC05 (ZS-040) modules are:

  1. rapid on, off flash (2 Hz ish) = communication mode, not connected.
  2. rapid flashes (on, off, on, off, takes ≈ 1 second) then a pause (off) of ≈ 2 seconds >> communication mode, connected.
  3. slow flash, ≈2 seconds on, ≈2 seconds off = AT mode

Right, right, I am thinking of the HC-06 module.

When I try to connect, the light blinks twice about every 5 seconds. It says it connects, but when I do anything on the app, nothing happens. A few seconds after that, the HC-05 disconnects.

Also what is the correct baud?

By default the baud rate is 9600 but it can be changed with the AT commands.

When I try to connect, the light blinks twice about every 5 seconds. It says it connects, but when I do anything on the app, nothing happens. A few seconds after that, the HC-05 disconnects.