bluetooth problem

in the past two weeks i posted twice about problems with fingerprint scanner , both problems was solved thanks to help i get here
so now i have a problem with HC05 bluetooth module
i can't get any response from it
1 - i eired id lile this
B grnd to Arduino Grnd
B VCC to arduino 5 v
B Tx to arduino Tx
B Rx to arduino Rx
and uploaded a blank sketch

i put the blue tooth once in data mode by just connecting it (it flashed rapidly)
and once in AT command mode by pressing the button while connecting it (it flashed one second on , one second off)
i tried to get any response to the AT commands i failed in both cases
so i changed the wiring
B Tx to arduino 2
B Rx to arduino 3
and used this code

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
Serial.begin(9600);
pinMode(9,OUTPUT); digitalWrite(9,HIGH);
Serial.println("Enter AT commands:");
mySerial.begin(38400);
}
void loop()
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
//Serial.write(Serial.read());
}

also i failed to get any response
i swaped the pins of the softwareserial (3,2) instead of (2,3)
i also failed
thankful for your help

pinMode(9,OUTPUT); digitalWrite(9,HIGH);

Maybe not important but You can code it digitalWrite(9,HIGH); pinMode(9,OUTPUT); and awoid short spikes at initiation.

Then, I add my comments to Your code:

if (mySerial.available())
Serial.write(mySerial.read()); //One character is pulled out of the receiver buffer.
if (Serial.available())
mySerial.write(Serial.read()); //Second character is pulled out of the receiver buffer.

What do You think?

Railroader:
if (mySerial.available())
Serial.write(mySerial.read()); //One character is pulled out of the receiver buffer.
if (Serial.available())
mySerial.write(Serial.read()); //Second character is pulled out of the receiver buffer.

What do You think?

sorry i can't figure what do you mean ??

Every time You perform a Serial.read() You "consume", eat, one character from the input stream. Are You aware of that?

Well
What is the right code to use

The serial input basics tutorial shows simple and reliable ways to receive serial data.

To send AT commands to the HC05 it must be put into "AT mode" and the baud rate is 38400. See this page for more information.

RX goes to TX and vice versa - I know you said you swapped TX and RX pins in your sketch, but still.

Curious, what are you trying to do with pin 9?

Lastly, are you pressing the AT Command Mode button and holding it down as the HC-05 turns on?

What AT commands are you sending it? Can you give us exact examples? (Maybe they aren't formatted correctly)

Pin 9 was intended to light a led in the original sketch and i just forgot to remove it
Yes i pressed the button and held it while the hc05 turns on and the led indicates at command mode by blinking one second on and one second off
Th at commands are the standard at commands i got from internet

Are you sure your wires connect to the Arduino pins 2 and 3? Maybe post some (clear and decent resolution) pictures of your setup showing all of your connections?

I made sure of the connection by using the same board for operating a fingerprint sensor after loadin the suitable sketch on arduino
Note the board is prepared so as to make it easy to test this or that by just plugging it in four pin connection
Vcc,ground,tx,rx

Mr groundfungus thanks for the links i hope they may be useful when i study them well tomorrow

fidamon:
I made sure of the connection by using the same board for operating a fingerprint sensor after loadin the suitable sketch on arduino
Note the board is prepared so as to make it easy to test this or that by just plugging it in four pin connection
Vcc,ground,tx,rx

What? Are you saying you just plugged the HC-05 directly into some of the female header pins on your Arduino?

sorry i didn't mean that
i prepared the testing board in the attached images for testing my work
thank you very much for helping me

EDIT i didn't use a voltage divider
does that mean i damaged my BT and buing another one is the solution ?

EDIT i didn't use a voltage divider
does that mean i damaged my BT and buying another one is the solution ?

Having a voltage divider on the bluetooth Rx to prevent it from seeing the 5v Arduino TX signals is a good idea, but I have never heard on this forum of an HC05 being harmed by an undivided connection.

Have you tried to work through the martyn currey tutorial referred by @GroundFungus?

Ok, I see the problem.

You are trying to hardware the HC-05 to the UART pins of the Arduino. These pins are NOT to be used for device communication (i.e. with an HC-05) because these pins mirror what is happening on the USB port. Also, Arduino TX0 and RX0 pins are actually pins 0 and 1, not 2 and 3. Lastly, you have the TX and RX wires swapped.

Your circuit board is the problem

Power_Broker i can't see how you concluded "You are trying to hardware the HC-05 to the UART pins of the Arduino. "
the image shows there are two ways to plug the BT module and the other image shows i plugged it in the one connected to arduino D2 , D3
the other set of Pins which is connected to UART pins of the Arduino. is not used in this trial
it was used when i tried a blank sketch

Since the pic with the actual "wiring" isn't labelled :angry: , I got mixed up between the two headers and which one the HC-05 is being plugged into.

Can you post a (labelled) pic of the underside of the board? Can you try with a breadboard?

BTW, it looks like there is a jumper from GND to D2. Sounds improbable, but is this the case?

Power_Broker thank you for trying to help me ,don't get angry
i mentioned that i tested the board with fingerprint sensor and it worked fine , so the board has no faults
i doubt that not using voltage divider with the BT Rx fried it
thanks again

fidamon:
Power_Broker thank you for trying to help me ,don't get angry

Sorry, I wasn't actually angry, just a little tilted and sometimes I overuse emojis. My apologies

Idk man, you might just have a bad bluetooth module? Might try using one of these to connect the HC-05 to your computer (without an Arduino) and test the AT commands with PuTTY:

Thanks i am looking for one
Or serial ttl converter but it is hard to find here in upper egypt where i live
Thank you for your help
Till we meet again in the next problem