Help Me with HC-05 and Arduino Mega

Hello, I need help with HC-05 bluetooth Module.

I want to use the HC-05 with Arduino Mega and I have following many instructions online but no one works on me.

Hope there is user in here that have a recommended suggestion or instruction regarding my problem.

Thank you.

Hello everyone, I have trouble connecting a HC-05 bluetooth module with Arduino Mega. I'm using this code from internet:

#include <SoftwareSerial.h>
SoftwareSerial EEBlue(0, 1); // RX | TX

void setup()
{
Serial.begin(9600);
EEBlue.begin(9600); //Baud Rate for command Mode.
Serial.println("Enter AT commands!");
}

void loop()
{

// Feed any data from bluetooth to Terminal.
if (EEBlue.available())

Serial.print(EEBlue.read());

// Feed all data from termial to bluetooth
if (Serial.available())
EEBlue.print(Serial.read());
}

I'm trying to send a simple character from my android phone, and I already tried using the bluetooth terminal app from PlayStore but it doesn't works.

I hope someone can tell me about this problem or give me a suggestion to make it works.

Thank you.

Duplicate topics moved and erged

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a timeout from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Hi.

Two immediate thoughts.

First, I'm not familiar with Mega, but using pins 0 & 1 for software serial might be wrong. Are those pins used as a hardware serial port as in the UNO and Nano? Try another pair of pins.

Second, I didn't think 9600 is the baud rate for the HC-05 command mode. Isn't it a higher value? The default operational mode (as opposed to the command mode) is 9600.

Do you know how to put the HC-05 into command mode? You keep the button pressed while connecting power.

It will work for you once you've got everything right. The serial terminal app will work to both send & receive text and send AT commands, when the HC-05 is in command mode. Then you can build your own apps.

Good luck.

John.

Have a look at the SoftwareSerialExample in the Examples in the IDE. It is written for a Mega.

When you have four (4) hardware serial ports, using software serial on a Mega is a seriously dumb idea. I cannot believe an example for that stated purpose would actually be included in the IDE, but there you go... About the only thing dumber would be to use software serial on the hardware serial pins 0,1, or any of the other hardware serial pins for that matter. Depressing results are guaranteed, and it just goes to show what dangerous junk you can get off the Internet although, on reflection, I can't help feeling that you have made some illicit changes.... Further, if you simply wish to connect with the phone, you don't need to send any AT commands.

You might find the following background notes useful.