I've connected the HC-05 Bluetooth module to my Arduino, but I just can't get it to work. I'm about to lose my mind—I've tried everything. I tested with 4 different Arduinos and 3 different modules, but the problem remains the same. When I type AT+PSWD?
, the serial monitor returns pswd fail
. When I type AT+PSWD=1234
, it still fails. However, commands like AT+NAME?
work fine.
Also, when entering AT mode, I press the button before powering it on, and it seems to enter AT mode. But as soon as I release the button, it exits. If I connect the EN pin to 3.3V, it stays in AT mode, but some sources say it should enter AT mode using the button alone.
I've been struggling with this for two days, and I'm on the verge of going crazy. Please help me! (ZS-040 model)
MY CODE : `// 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;
}
}
}` >