HC-05 Bluetooth Module, AT Command is not working

Hi everyone,

I get no results when running AT commands on the serial port. Whatever I type, it writes to the screen.

Serial Monitor;

Circuit:

Arduino: VCC Bluetooth Module: VCC
Arduino: GND Bluetooth Module: GND
Arduino: 10 Bluetooth Module: TXD
Arduino: 11 Bluetooth Module: RXD

I didn't use any resistor.

// #define PIN_RX 11
// #define PIN_TX 10

#include <SoftwareSerial.h>

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

void setup() {
  
  Serial.begin(9600);                          
  Serial.println("Configuration Mode On!");  
  BTSerial.begin(38400);                       

}

void loop() {

  if (BTSerial.available())       
    Serial.write(BTSerial.read());  

  if (Serial.available())         
    Serial.write(Serial.read());  
    
}

Maybe

It depends on which Arduino you use. If it's a 5V one (e.g. Uno, Nano, Mega), you're living on the edge and risk damaging the bluetooth module (it might be a slow process).

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project :wink: See About the IDE 1.x category.

I tried but it isn't still working :frowning: before when I write AT, it show AT on screen but now it isn't showing any.

What process did you follow to place the module in AT mode, and what are the blinking lights showing?

I built the circuit first. Then I connected it to the computer. ON and L lights are on on the arduino. On the module, the light turns on every 2 seconds. I saved and uploaded the code in Arduino IDE. When I type a command on the Serial Monitor, it does not output.

You probably have destroyed the module.

Before I tried by using resistor, it doesn't work again.

Start over with a new HC-05 and follow the instructions very, very carefully. BE SURE to ignore any tutorials that suggest it is OK to omit the logic level shifter (resistive divider).

If you run into trouble, post again.

I can see bluetooth module's name on my phone and I can connect. Don't mean it works?

Some part of it works. It is possible that you merely burned out the RX pin.

If you buy those things from cheap suppliers like Alibaba or eBay, you have no guarantee that anything will work as advertised. So buy a couple and hope that one will. That way you can afford to make mistakes, too.

Also be sure to fix the code error noted in post #2.

Thanks.

No, I don't buy from there. I bought it from the local store.

I fixed it and tried it, still didn't work.

How can I tell if the rx pin is broken without buying another module? I will buy a new one accordingly.

If you work in data mode with a phone connected to the HC05, can you enter something from the monitor and have it transmitted to the phone? Can you send something from the phone and see it on the monitor?

One way to tell a dead module from a good one is to test a known good HC-05 module in the same circuit. If that works, and the old one does not, the question is answered.

Triple check all your wiring, and use your multimeter to test continuity of all connections, and proper voltages at all pins.

I will try.

Quite likely. Why don't you try to use it? A simple " hello world" with the phone doesn't require any AT commands.

Once you pair the HC05 module to your phone you will need to connect the HC05 to an app on your phone that you can use to communicate with the HC05. I really like the serial Bluetooth terminal app.

I have used the following instruction to put HC05 (ZS-040) modules into AT mode to make changes to your setup. Also at least 3 other members have used this instruction with success.

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) in my prior post. 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.

// code by Martyn Currie.
// To enable AT mode, connect the EN pin of the HC05 
// to 3.3V before powering the HC05.
// 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 will be a bit 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 tried but unfortunately it doesn't works.

It didn't again :(