I'm working on a project where I'll need to establish a connection between two HC-05 modules, each connected to an Arduino, but for now I'm just trying to get one to work and connect to my phone, but I'm not sure if I'm doing anything right...
I'm not able to give AT-Commands, and as a result the device is not able to pair with my phone. My setup looks something like this:
With minor differences being that I'm using an Uno board instead of a Mega, the RX and TX pins are connected to...well, I tried a lot of different pins, from the default RX/TX pins to specifying other pins like the ones in the code, as well as reversing the connections (RX to TX, TX to RX), also this schematic neglected to mention the 'ENABLE' pin, which I connected to my Arduino's 3,3V pin.
I tried a lot of different code samples, the latest one I tried is the following:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(38400);
Serial.println("Enter AT commands:"); // a prompt in Serial Monitor
// Deleted while loop, unnecessary
mySerial.begin(38400);
}
void loop() { // run over and over
//if (Serial3.available()) { // we don't use Serial3 any more
if (mySerial.available()) {
//Serial.write(Serial3.read());
Serial.write(mySerial.read());
}
if (Serial.available()) {
//Serial3.write(Serial.read());
mySerial.write(Serial.read());
}
}
Which I blatantly ripped-off from this answer, with minor changes.
So, I connect my Arduino to my PC, upload the code, connect my module, set the serial monitor's baud rate to 38400 and...a bunch of gibberish appear on screen, just an alternating sequence of the characters 'x' and '?', to my understanding that's actually the message "Enter AT commands:" written in my code...
Now, with this exact setup, I'm now actually receiving a response to my commands, except the response is also gibberish, this is as far as I've gotten.
EDIT: By following some of the comments and setting the Serial baud rate to 38400, I managed to get other Reponses to my commands, but it's just a new type of gibberish and it's still not actually responding to my commands.
The thing is, all of the tutorials I've seen online are contradicting each other, some connect the RX and TX pins in reverse to the Arduino, some don't, some specify other pins on the board, some don't bother with the ENABLE pin entirely, some don't use a voltage divider, some connect VCC pin to the 3,3V instead of the 5V, some even skip the AT-Command setup entirely!
One last detail I feel like I should mention, there's a red light that blinks on and off every two seconds, I believe that means the module is read to receive commands but I've seen contradicting information about this as well so I'm not sure.
I want to know what I'm doing wrong, and what's the right way to do this?