Bluetooth module HC-05 giving ERROR :(0)

I am working right now with Arduino UNO and HC-05 bluetooth module.I followed the instruction given on this link for wiring.

So there are 2 mode of working with this HC-05 module
i) Simple serial communication
ii) working in AT command mode so as to change the parameters of HC-05 module

As long as i work in simple serial communication mode, everything work fine but when i tried to change the parameters of module, it didn't worked out.FOr working in At command mode, PIN NO 34 of HC-05 module need to be high and i had taken care of.Lately i find that in mu module they had knowingly not connected the Berg strip to PIN 34 , so i connected the PIN directly, even thought i am not able to change the parameters of moduel and when i write any command on COM port of arduino IDE, i get this response

Enter AT commands:
ERROR:(0)
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿõÿýìa¢^
ERROR:(0)
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿõÿýìa¢^
ERROR:(0)
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿõÿýìa¢^
ERROR:(0)
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿõÿýìa¢^
ERROR:(0)
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿõÿýìa¢^
ERROR:(0)
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿõÿýìa¢^

I think that garbage is due to my code

and here is my code

#include <SoftwareSerial.h>

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

void setup()
{
  pinMode(9, OUTPUT);  
  digitalWrite(9, HIGH);
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  
}

void loop()
{uint8_t x;
 char CommandFromSerial[50]=" ";
 char ResponseFromBluetooth[50]= " ";
   
  if ((Serial.available())){
    if(Serial.available()>0){
  for(x=0;x<50;x++){
  CommandFromSerial[x]=Serial.read();}
BTSerial.println(CommandFromSerial);}
}
    

 
  if ((BTSerial.available())){
    if(BTSerial.available()>0){
  for(x=0;x<50;x++){
  ResponseFromBluetooth[x]=BTSerial.read();}}
Serial.println(ResponseFromBluetooth);}
    

}

I am not able to figure out what i am doing wrong. i used this command on COM port AT\r\n and many other commands but everytime i get the same response.

Did i had messed up with my bluetooth module unknowingly?

I dont think that i am messing up with the Bluetooth coding as i m getting ERROR :(0) which according to the Bluetooth AT command module datasheet ERROR : (0) is due to the bad AT command error , i get this from this link
http://www.elecfreaks.com/wiki/index.php?title=Bluetooth_Bee

  1. try to set the HC-05 via a terminal, set the terminal parameters as required
  2. as Nick indicates your code is not correct as the Serial.available() indicates just 1 byte is available, and you are trying to read a lot of them within the loop

Of course Serial.available indicate one byte is avaliable but i am reading and then storing each byte in response[x] and then displaying it.
Well i will try to set the parameters with Terminal instead

Try to be precise:

    if(Serial.available()>0){
      for(x=0;x<50;x++){
        CommandFromSerial[x]=Serial.read();}

You know one byte is available and you are reading 50. Do you see the problem here?

hi, if u having trouble in making into AT mode of HC-05 (ZS-040)(especiall if one having en/wakeup up pin instead of key pin) and trouble in transfering data between two hc05 module . Follow they bellow procedure
Power off HC-05 module.
Press and hold small button above EN pin.
Power on and keep pressing small button.
Small LED should start to blink slowly about once every 2 seconds.

for more info visit below site:

another good reference for making it into master mode is here:

aftermaking connection if you stuck in transmitting data from one module to another see below:
http://www.martyncurrey.com/connecting-2-arduinos-by-bluetooth-using-a-hc-05-and-a-hc-06-easy-method-using-cmode/

Try setting the AT commands in lower case

1 Like