Arduino HC-05 Not Working

Hi,

I've been trying to get my HC-05 Bluetooth modules to work all day. I have followed several online guides but no matter what method I try, I do not get a response in the Serial Monitor. I understand that I must get an 'OK' response after typing in AT, yet this is not the case. I have rewired the circuit several times and attempted to use several different scripts but alas, no response. The issue may be the modules themselves, however, but they exhibit the standard blinking LED response to AT command mode and have high reviews online.

Have I got faulty HC-05's or is there something I might be missing?

Below are pictures of the circuit (sorry if it is at all unclear, I will attach an image that I copied to create the circuits as well.)




The code used is:

#include <SoftwareSerial.h>
#define tx 2
#define rx 3
SoftwareSerial configBt(rx, tx);
void setup() {
  // put your setup code here, to run once:
  Serial.begin(38400);
  configBt.begin(38400);
  pinMode(tx, OUTPUT);    
  pinMode(rx, INPUT);
}

void loop() 
{
  if(configBt.available()) // if the HC05 is sending something… 
  {
    Serial.print(configBt.readString()); // print in serial monitor
  }
  if(Serial.available()) // if serial monitor is outputting something… 
  {
    configBt.write(Serial.read()); // write to Arduino’s Tx pin
  }
}

UPDATE:
I've tried several more supposed solutions and am now receiving this about a minute or so later after typing 'AT':

I wired a HC05 to my Uno and tried your code. No success. Then I uploaded the code that I usually use to put my HC05 modules to AT mode and talk to them. Works fine.

My AT mode code. Not sure where I got it but it works fine. Mind the baud rates.

#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;
      }
   }
}

It is not unusual for the HC05 to return "error" the first time that you send "AT", just try again and you should get "OK".

To configure 2 HC05 as master and slave, consult this page. It helped me a lot.

On setting HC05 to AT mode, this page.

The wiring between the Uno and HC05 should be Uno RX to HC05 TX and Uno TX to HC05 RX.
The voltage dividers should be between Uno TX and HC05 RX.

Hi,

Firstly, thanks for the help, I'm going to give it a try in the morning.

Secondly, you mention the Uno Tx and Rx but the code references the 2nd and 3rd digital outputs, are these functionally the same thing?

Thirdly, if that is the case, how would I then translate that to the arduino nano (every)?

Thank you again for the help, it is very much appreciated.

Sorry, I meant the Uno software serial RX and TX. So Uno pin 2 (ss RX) to HC05 TX and Uno pin 3 (ss TX) to HC05 RX through the voltage divider. Note the resistor values. Are those the values that you use?

What Nano Every? Sorry, I know nothing of the Nano Every. Maybe someone else can help with that.

I am using a 1.2k Ω resistor and a 2.2k Ω resistor.

The outcome is much more positive, every time I enter AT I now get a response on the serial monitor. However, this response is not ideal.


What do you think may be causing this? I've done (what has felt like) so much troubleshooting now, I think the Bluetooth module itself may just be busted. Do you recognise this error?

EDIT: Upon further research I think the problem may be due to an outdated SoftwareSerial library file.

EDIT2: I changed the serial monitor baudrate to 38400 and I no longer get a reply, but the text produced from the code is no longer encoded like before.

This is with pin 2 hooked up to TX on the HC-05 and pin 3 hooked up to RX respectively.

I've managed to fix the problem. The output voltage of the 1.2k and 2.2k ohm voltage divider resulted in a value lower than 3.3V. I added a 1.2k resistor in series to create a 1.2k and 3.4k voltage divider and now it all works fine.

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