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.)
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.
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 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.