HC-05 : Any AT command outputs "ERROR"

Hi guys,

I have multiple HC-05 (ZS-040). My arduino mega has an almost empty project except in the setup where I set the pin 9 at high.

The HC-05 is connected directly to the RX0-TX0 pins. Pin 9 is connected to the KEY pin. When I send an AT command through the terminal, the HC-05 always return ERROR without any code.

Like I wrote, I have 25 HC-05 to configure and I tried 5-6 they all return the same result.

Does someone know what is wrong?

There is more than one right way to do this, I suspect you are using none of them - and I don't see any code either.

You cannot write to Bluetooth from the serial monitor when it is on pins 0,1.

Try moving it to pins 18,19 and change the serial commands to serial1. It will be something like
Serial1.print (serial read);

Also check the wiring is Tx to Rx, and Rx to Tx.

If you are mass producing something, you can configure Blueteeth with pre-set commands in Setup, no keyboard commands involved. This is also legitimate in "single use" configuration.

If you connect the BT module directly to the RX0-TX0 pin, you don't need code on the Arduino. You communicate directly with the module.

I have tried using pins 10-11 with SoftSerial without success. I will try tomorrow your method tomorrow using RX1-TX1.

This sounds a pretty silly thing to do on a Mega, but really should work nonetheless. About the only thing that can go wrong is that you wired Bluetooth the wrong way round.

I think the ZS-040 board has a button on it to prompt AT mode.

Follow these steps to issue AT Command to HC-05 Bluetooth:
1. Connect HC-05 and MEGA as per Fig-1.
hc5Mega
Figure-1:

2. Upload the following sketch in MEGA.

void setup()
{
  Serial.begin(9600);
  Serial1.begin(38400);//AT Command data transmission rate;
}

void loop()
{
  if (Serial1.available())
  {
    char x = Serial1.read();
    Serial.print(x);
  }

  if (Serial.available())
  {
    char c = Serial.read();
    Serial1.print(c);
  }
}

3. Carry out the following steps:

(a) Do not pair the BT with any device.
(b) Disconnect power +5V line of BT from UNO.
(c) Connect EN-pin of BT with 3.3V point of UNO.
(d) Open SM at Bd = 9600. Select NL & CR option in the Line ending tab.
(e) Hold down the micro switch of BT.
(f) Connect +5V line of BT.
(g) 2/3 Second later, release the micro switch of BT.
(h) Check that Red LED of BT blink once in about 2-sec.
(i) Focus the cursor in the InputBox of Serial Monitor.
(j) Type AT and then click on the Send Button.
(k) In my case, I see OK message on the OutputBox of Serial Monitor.

I managed to get into the partial AT by using a FTDI programmer.

So typing AT returns OK.

But I only get partial commands. Here are the command I can get to work :

  • AT+NAME --> Eg result : +NAME=BT05
  • AT+NAMENEWNAME --> Notice no "=" signs. Otherwise it's taken into account.
  • AT+VERSION --> Result +VERSION=v5.3
  • AT+ROLE --> +ROLE=0

I can't change the password. The command AT+PSWD returns ERROR.

Is there something particular with this FW version?

My setup of post #5 with MEGA works well for any the common AT Commands including the password change. Why is not working your setup?

Insted of using the little push button to put the HC05 into AT mode you may want to try using the EN pin. Remove power from the HC05 and connect the EN pin to 3.3V (NOT 5V). Then re-power the HC05. It should enter AT mode.

Your prescribed method does not work for me. The following steps have been followed to put the HC-05 into AT Mode.

1. Disconnect 5V from HC-05.
2. Connect EN-pin with 3.3V.
3. Press and hold the micro switch of HC-05.
4. Connect 5V with BT.
5. After 2/3 seconds, release the micro switch.
6. Check that the Red-LED of HC-05 blinks at 2-sec interval indicating AT Mode.

I have 6 of the ZS-040 module and I can assure you that the method that I posted works for every one. Maybe it does not work for yours, but it does work for some so I think that it may be worth a try if the modules will not enter full AT mode with the button (which is a known problem).

Another thing that you can try, that I have had success with, is to hold the button down with an alligator clip so that it stays down after powering the module. That may allow the full AT mode.

A Martyn Currie page that helped me. >> Arduino with HC-05 (ZS-040) Bluetooth module – AT MODE | Martyn Currey

1 Like

So I went down the rabbit hole and manage to find the valid AT commands.

The chip on board is the CC2541 and the commands are a bit different from what is seen on many websites.

https://w.electrodragon.com/w/CC2541#AT_commands

Type AT+HELP and the device will show all, I think, the commands.

HTH

What Groundfungus proposed is correct for HC-05 but, at times like this, it really helps if you know what the hell you are holding in your hand. It isn't an HC-05 it's a BLE device, probably an HM-10. This means it is in AT mode by default so, if you just send AT commands as soon as you power on, it should work. No extra wires, no button.

I bought the BT module as HC-05 from Amazon with ZS-040 marked on the PCB. They have the same form factor and the same pin out. That's the reason why I thought they were HC-05.

Now I need to know what is the casual name of this device.

A few sharp words with Amazon might be timely, but you can be pretty sure it is an HM-10, which is a sort of bottom of the range BLE. You may find that it is quite OK for your needs and, since it is in your hand, you might as well persevere with it.

The ZS-040 is merely the breakout board and can have HC-05, HC-06 or HM-10 installed. Yours may have the little button everybody is talking about, missing, but I have always seen an HM-10 with six pins, while only four are warranted.

Be aware that HM-10 is not a reliable drop-in replacement for HC-05, and you do need BLE libraries to run it.

I think the Martyn Currey website is up-to-date on these devices.

Thanks!

After a quick search, I have clones without the oscillator. If I want to connect to it via Windows or Android, I think need to upload a firmware. I'm I correct? I so, is there some kind of adapter to clip a programmer to the side connectors of the module?

No.
There is a long-running thread around here about upgrading the firmware to bring the HM-10 more in line with a full-bottle BT4. I have no idea what that is about but, if your original intention was to use HC-05, I'm sure you don't need to do it. The cheapo HM-10 is severely crippled so that its capabilities is more or less the same as an HC-05, i.e. its list of AT commands is more or less the same, and so is the range. But note, as I said, it is not a drop-in replacement. There is a BTSerial library. I have never used it as it was simpler to stick with HC-05.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.