No response on AT commands from HC-05

Hi, I have browsed through some other forums and it seemed that they are either not suitable for what I wanted to ask or the forum has been closed.
I connected my Arduino Uno to a HC-05 module.
I ran the following code :

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX

void setup() {
pinMode(9, OUTPUT);
digitalWrite(9, HIGH);

Serial.begin(38400);
Serial.println("Enter AT Commands:");
BTSerial.begin(38400);
}

void loop() {

if (Serial.available()) //Read from Arduino Serial Monitor
 BTSerial.write(Serial.read()); // and send to HC-05

if (BTSerial.available()) //Reading from HC-05 and send to Arduino
 Serial.write(BTSerial.read()); //Serial Monitor   

}

My has no errors when I verified and uploaded.

My circuit is as shown above with the red light on the bluetooth module blinking.

I went to the Serial monitor and changed the baud rate to 38400.


No matter what AT commands I keyed in and sent, there was no response.

So I went back to the HC-05 module (with the circuit and power still connected) and pressed the button on the module.

My module came with the button as shown below.


What is missing or could possibly have gone wrong ?

Are you certain the 38400 is the default serial baud rate for your module?
Have you connected the required voltage divider from Arduino TX to Bluetooth RX?

Follow this excellent tutorial:
https://www.martyncurrey.com/arduino-with-hc-05-bluetooth-module-at-mode/

Hello

are you sure it's 38400 and not 9600?
You also might want to change the line terminator from
image
to both CR + LF


Please read How to get the best out of this forum and fix your first post accordingly (having indented code with code tags would be a minimum). I won't answer this thread anymore until the first post looks correct.

You wiring is unreadable. Make sure the serial connections are Rx to Tx and Tx to Rx. 38400 is not the default but is correct for your purpose. If you have the button, pin 9 stuff is redundant.

Did you see the voltage range on the back of the module. 3.6 to 6volt.
So why did you power it from the 3.3volt pin of the Uno.

Did you use a level shifter (voltage divider), to protect the RX pin of the HC-05?
Leo..

Thanks for your advice. I tried out combinations of commands (3 sets), code baud rates (9600 and 38400), serial monitor baud rates (3 sets), and options on the serial monitor (e.g. No line ending, New line, Carriage return, and Both NL & CR). Code baud rates are matched with serial monitor baud rates.

This screenshot is only a sample of all combinations.

I discovered that there were only 3 combinations which I could get "OK"s from the commands.
(a) code baud rate = 38400, serial monitor baud rate = 38400, and use of new line option.
(b) code baud rate = 38400, serial monitor baud rate = 38400, and use of carriage return option.
(c) code baud rate = 38400, serial monitor baud rate = 38400, and use of Both NL + CR (your option).

For these 3 combinations, when I tried to use commands AT+NAME and AT+VERSION (meaning I could not even ascertain the firmware status), there were no responses. How can this be possible ?

I digress to answer your concerns. I came from other forums and the codes were handled differently. They either allowed the :
(a) physical file format/(s) to be uploaded (i.e. by suitable file extensions) or
(b) actual code format in my first post
When I first copied and pasted the code here, I was prompted in this forum with backtick (for multiple code lines "java" style ?), and ("semi html" style ?) formats which I did not encounter and use elsewhere.
The examples in the prompt left ambiguities I had to figure out on syntax. e.g., back tick every line of my start and end of code ? use <> the same way as html but should come in pairs ? I had other forums where such pre-formatting comes with online previews down to WYSIWYG outputs before I posted. This forum, I got an option at the bottom right hand of the window "post anyway". At the risk of second guessing and ending up with something unintended, I chose "post anyway".
So if you would like to help further, I thank you in advance unreservedly.
But if the code pre-format isn't acceptable to you and you want to keep quiet, I am fully aware that not everyone is open to understand matters contextually.

Ok, what I did was to draw out the wiring diagram as shown.


You may consider me to be very new to electronics or Arduino.
This was my original diagram and in it, I had a wiring going to the 5V pin of Arduino (I will explain why this is the original diagram when I answer another query here).

Thanks and yes I saw it. Basically it read "Level 3.3V" and "Power 3.6V-6V", and because of this, I deliberately asked the seller beforehand. The reply given to me was I could connect it to the 3.3V terminal of Arduino Uno. Is this reply correct ?
So although my original circuit diagram posted showed the connection to the 5V terminal, I connected the actual circuit to the 3.3V terminal instead.
Do I still need a voltage divider when connecting to the 3.3V terminal ? If yes, how should the voltage divider be implemented in terms of wiring, or is there a link which I can refer to ?

I would if you fix the post.
Three backticks at the start of the code alone on one line
Three backticks at the end of the code alone on one line

If you click on the <code> button in the toolbar above the text entry you’ll get the right formatting, just replace the default text type or paste code here and paste your indented code there.

type or paste code here

Do yourself a favour and please read How to get the best out of this forum and post accordingly .

3v3 terminal from arduino is definately not meant as a power supply. Certainly not for demanding things like radio modules...
Please make a drawing as is. Not as it is not with a lot of explanation how it is different.

No. Minimum supply voltage of the HC-05 is 3.6volt.
The HC-05's built-in 3.3volt regulator needs some overhead to do it's job.

Don't confuse power with logic. The Uno uses 5volt-logic, the HC-05 uses 3.3volt logic.
The RX pin needs protection from the higher logic voltage of the Uno.
Commonly a 1k:2k2 resistor divider is used for that. Many diagrams on Google.
The TX pin of the HC-05 is an output, so doesn't need that divider.

All of this might have nothing to do with your problem.
Leo.

The prompt message says use either back ticks or


SoftwareSerial BTSerial(10, 11); // RX | TX

void setup() {
   pinMode(9, OUTPUT); /* pin will pull HC-05 pin 34 (key pin) HIGH to switch module to AT mode */
   digitalWrite(9, HIGH);   

   Serial.begin(9600);
   Serial.println("Enter AT Commands:");
   BTSerial.begin(9600); // HC-05 default speed in AT command mode
}

void loop() {

  // Code below allows for commands and messages to be sent from COMPUTER (serial monitor) -> HC-05
  if (Serial.available()) //Keep reading from Arduino Serial Monitor
     BTSerial.write(Serial.read()); // and send to HC-05

  //Code allows for commands and messages to be sent from HC-05 --> COMPUTER (serial monitor)
  if (BTSerial.available()) // Keep reading from HC-05 and send to Arduino
     Serial.write(BTSerial.read()); //Serial Monitor   
}```

Like this from what you mentioned ? I have looked at your link before I replied and I have stated where the issues came from. I have no idea if you were trying to understand what happened given that you  selectively quoted only my thank you portion instead of the full context. I don't have an axe to grind and will not be dirtying the thread anymore with unproductive replies.

Point taken on drawing.
So instead of connecting the HC-05 Vcc to 3.3V in actual circuit, I should have connected it to 5V ? If yes, how would that explain that I got some AT responses but not all ?

Double check how your first post and post 13 look.

adding code tags is not rocket science... it's just three backticks around the code portion.

The reason I insist is not to pick on you, it's because there is value in maintaining a readable forum. Remember that helpers here contribute not only for you but also for dozens of other people who will face the same issue you have and will find this thread.

Making it look good for "generations to come" is a little ask for being provided with help, don't you think?

It is good practice to use a voltage divider on Arduino Tx.
divider
Note this shows pin1 as Tx, in your case it is pin 11.
Driving HC-05 off 3.3v is definitely not a good idea.

Sure I can agree to having readable code, but your original post did not come across as such. You said read the "How to get the best out of this forum" (giving the impression to read the whole thing ??) when the initial issue was on code readability. Just be aware that there are 2 types of people out there, one those who start off without reading too much, work on something till they hit road blocks. Two, those who read on the kind of articles before starting anything. As long one understands that there are 2 groups of people out there and not engage in bigotry to the point of being opinionated, it's easier to know where issues/ disagreements can lie.
Of course code readability is not rocket science and I have nothing against it, please do yourself a favour by reading my messages very carefully instead of pouncing with your views. One more time, do not selectively quote what I said leaving the rest out.

Ok Thanks, let me try this out.

Of course it’s expected you read the whole thing…there are two types of people indeed. Those who care for the community and want their discussion to be useful in the long run also for others and those who don’t care.

Post 1 and 13 still don’t look right. (Have the 3 backticks without anything else at the start of a new line.) you seem reasonable, I don’t see how hard it is to just click on this little pencil next to your posts and fix them… thx

I am trying to understand the rationale behind the voltage divider while assuming that you recommend connecting HC-05 to a 5V Vcc. What exactly is the difference between using 3.3V directly vs using 5V with a voltage divider if the currents drawn are not expected to change too much (since there is no inductive load) ?