HC-05 module works with Arduino Uno but not with Mega

Hello all. Me and my Bluetooth module (HC-05 6Pin) are not getting friends. In short: The module works on my Arduino Uno R3 without problems. Unfortunately I can't get the module to work on my Arduino Mega where i need it. I pluged the cables in both Arduinos in the same slots. I tried additionally TX1 and RX1, but it didn't work.

Behavior on the Arduino Mega:
Cell phone connects to module and LED on HC-05 flashes slowly evenly as it should. Transmitted data are not printed in the Serial Console. There is simply no output. Are there any differences between the two boards? Does someone have any ideas? Thanks to all who read this. Ask if you need more informations.

Both Arduinos were tested by 12V battery and USB 3.0 and only USB 3.0
Arduino Uno Pinout:
HC-05/Arduino Uno
RXD => 2 (Digital Pin)
TXD => 3 ~ (Digital Pin)
GND => GND
VCC => 5V

Arduino Mega Pinout:
HC-05/Arduino Mega
RXD => 2 (Digital Pin)
TXD => 3 (Digital Pin)
GND => GND
VCC => 5V

Code:

#include "Arduino.h"
#include <SoftwareSerial.h>

const byte rxPin = 3;
const byte txPin = 2;
SoftwareSerial BTSerial(rxPin, txPin);

void setup(){
 pinMode(rxPin, INPUT);
 pinMode(txPin, OUTPUT);
  BTSerial.begin(9600);
  Serial.begin(9600);
}

void loop() {
  if (BTSerial.available()) {
    Serial.write(BTSerial.read());
  }
  if (Serial.available()) {
    char ch=Serial.read();
    BTSerial.write(ch);
  }
}

SoftwareSerial will not work will every pin on a Mega

See https://docs.arduino.cc/learn/built-in-libraries/software-serial

But as the Mega has 4 hardware serial interfaces why would you need to use it anyway ?

1 Like

Use one of the three other hardware serial ports on the Mega (Serial1, Serial2 or Serial3), using the appropriate pins, and the problem will go away.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.