Hello ![]()
So I've had this HC-05 Bluetooth since like a year, but never done something with it because I used HC-07 modules for my projects and didn't need the features of the HC-05.
Today I wanted to try it's capabilities, so the first thing I did is simply connect it to my Arduino Mega 2560's Serial1 port (with a 5V to 3.3V voltage divider from the Arduino's TX to the HC-05's RX). I didn't change any of it's settings, so it's default to Slave mode, 38400 bauds.
Theorically, it should work just like the HC-07, with which I didn't have any problems..
Practically, it doesn't work right. I can send data from it with Serial1.print (for example), this worked, but when trying to send data to it, it doesn't matter what I send: Serial1.available() will most of the time equal to 1, and sometimes 2, and Serial1.read() will most of the time read a 0, and sometimes a 0 followed by a random character...
This problem is happening with HardwareSerial ports Serial1, Serial2, Serial3. If I use HardwareSerial port Serial or SoftwareSerial, then it works as planned.
This is not a problem in my code, because if I just replace the HC-05 by a HC-07, it works. Also, I am able to enter AT mode and change settings without any problem. I also tried powering the Arduino from an external PSU, no changes.
To recap, the problem is only when trying to receive with additional HardwareSerial ports of my Arduino Mega 2560.
Not working:
void setup()
{
 Serial1.begin( 38400 );
}
void loop()
{
 if ( Serial1.available() > 0 )
 {
  Serial1.println( (char)Serial1.read() );
 }
}
Working:
void setup()
{
 Serial.begin( 38400 );
}
void loop()
{
 if ( Serial.available() > 0 )
 {
  Serial.println( (char)Serial.read() );
 }
}
Any idea what could be wrong ? ![]()