HC-05 (Bluetooth card) and UNO - HC-05 "not available

Command mode on NC-05 --- all commands return "-1". More to the point, the HC-05 does not respond as "available" when sent test to send the basic "AT" test command.

Sketch code:
Preformatted text#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX
char test_AT_command[3] = {'A', 'T', '\r\n'};

int pin9 = 9;
int pin6 = 6;

void setup() {
pinMode(6, OUTPUT); // pin 6 is for the LED (useless pilot light)
pinMode(9, OUTPUT); // Pin 9 will pull the HC-05 pin 34 ("key" pin)
// switch module to AT mode
digitalWrite(9, HIGH);
Serial.begin(9600);

digitalWrite(6, LOW);
BTSerial.begin(38400); // HC-05 default speed in AT command more
//
// HC-05 put into Command mode by holding the smalll button above the KEY pin while
// applying power to the circuit board. HC-05 LED blink at slow mode.
}

void loop() {
digitalWrite(6,HIGH);
if (BTSerial.available()) {
BTSerial.write(test_AT_command);
Serial.print("AT test command is ");
Serial.print(test_AT_command);
Serial.print("\tresult from basic AT Test command is ");
Serial.println(BTSerial.read());
} else {Serial.print("\nBTSerial not available. ");}
Serial.print("Wait a few seconds.");
delay(10000);
}Preformatted text
attach by link --- drawing of the simle circuit.
image

That's on, or above, the capacity of Software serial.

Also... Please read this topic and focus on posting code: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

The EN (or any of the HC05 input pins) is not 5V compatible. Hopefully you did not damage the HC05 by connecting it to 5V.

Your improperly posted code is incomplete. Please read the forum guidelines* to see how to properly post code and some information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Please go back and fix your original post.

Here is the method that I use to put my HC05 modules (labeled ZS-040) into AT mode and make changes to their setup. On some HC05 modules, pressing the button at start up will put the HC05 into a very limited ATmode. Connecting the EN pin to 3.3V and then powering the module puts it into full AT mode. These instructions have worked on all 6 HC05 modules that I have and at least 3 members modules that tried it.

This instruction is for the HC05 module marked ZS-040 connected to an Arduino Uno, Nano or any mega328 based board. Connect the HC05 as shown in the Martyn Currey page on AT mode for the HC05 (ZS-040). HC05 TX to Arduino pin 2 and HC05 RX to Arduino pin 3 (through voltage divider).

To change the baud rate you must first put the HC05 into AT mode. Do that by connecting the EN pin to 3.3V, NOT 5V. Then power up the Arduino board and HC05 module. The LED on the module should alternate lit for about 3 seconds and off about 3 second if it enters AT mode.

Upload the following code to the Arduino board.

// To enable AT mode connect the EN pin of the HC05
// to 3.3V.  Caution, do not connect EN to 5V.

#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX

const long baudRate = 38400;
char c = ' ';
boolean NL = true;

void setup()
{
   Serial.begin(38400);
   Serial.print("Sketch:   ");   Serial.println(__FILE__);
   Serial.print("Uploaded: ");   Serial.println(__DATE__);
   Serial.println(" ");

   BTserial.begin(baudRate);
   Serial.print("BTserial started at "); 
   Serial.println(baudRate);
   //BTserial.print("BTserial started at "); 
   //BTserial.println(baudRate);
   Serial.println(" ");
}

void loop()
{
   // Read from the Bluetooth module and send to the Arduino Serial Monitor
   if (BTserial.available())
   {
      c = BTserial.read();
      Serial.write(c);
   }

   // Read from the Serial Monitor and send to the Bluetooth module
   if (Serial.available())
   {
      c = Serial.read();
      BTserial.write(c);

      // Echo the user input to the main window. The ">" character indicates the user entered text.
      if (NL)
      {
         Serial.print(">");
         NL = false;
      }
      Serial.write(c);
      if (c == 10)
      {
         NL = true;
      }
   }
}

In serial monitor (baud rate set to 38400) you should see something like (the file directory and date will, of course, be a different):

    Sketch: D:\bt_test_AT\bt_test_AT.ino
    Uploaded: May 19 2022

BTserial started at 38400

Type "AT" (no quotes) and enter. You may see:

    AT
    ERROR:(0)

That is normal.

Type "AT" (no quotes) and enter again. Now you should see:

    AT
    OK

If that is what you see, the HC05 is in AT mode and ready to accept AT commands.

To set to baud 115200, enter "AT+UART=115200,0,0" (no quotes).

HC05 AT command list with examples.

More HC05 information by Martyn Currie.

I understand that you are trying configure HC-05 in AT mode. Therefore you can safely ignore the nonsense in post#2. You don't have a choice, 38400 is the required baud rate for configuration, and it is standard practice to do that in software serial. Further, it is quite OK to have the serial monitor @ 9600.
Just make sure your wiring is Tx to Rx and Rx to Tx. The flashing LED is not a confirmation of kosher wiring.