Bluetooth HC05 communication with Hardware Serial port 1-3 on Arduino Mega

Hello,

I have been trying arduino mega 2560 to communicate with the HC-05 bluetooth module. It works fine when connected to Hardware Serial Port 0 (Rx0 and Tx0). But, when I connect it to Rx1-Tx1 or Rx2-Tx2 or Rx3-Tx3, it is able to receive data correctly from Arduino but does not transmit correctly.

My code is as follows: void setup() { Serial.begin(9600); Serial3.begin(9600); while(!Serial); while(!Serial3); }

void loop() { while (Serial3.available()) { Serial.print("Getting from Serial3: "); char inByte = Serial3.read(); Serial.print(inByte); delay(1000); }

if (Serial.available()) { int inByte = Serial.read(); Serial3.write(inByte); } }

For most of the characters / numbers sent from bluetooth, I only get 0 in the serial monitor. For some I get 4 and some 60. Would appreciate if someone can help me out with this. Since it works perfectly with Rx0 and Tx0, unable to understand the problem with alternate Serial ports.

Also, to confirm that the serial ports are working fine, I disconnected the bluetooth module and connected Tx3 to Rx3. With this I was able to receive the output correctly.

My connections with HC05 module are as follows: Vcc - Arduino 5V Gnd - Arduino Gnd Tx - Arduino Rx3 Rx - Arduino Tx3 via voltage divider circuit

Would appreciate if someone can help me with this.

Thanks, John