Using HC-05 and Mega 2560

Hi there! First time post here, sorry if I am missing any main details.

I am trying to use a HC-05 module with a Mega 2560. I have followed a few guides, but haven’t gotten 100% working so far. I have ended up trying to use this Instructable adapted to a Mega 2560.

I have the TX on the HC-05 connected to pin 19 (RX1) and the RX from HC-05 connected to pin 18 (TX1), as well as power connected. I have an LED connected to pin 8, but no code working it.

The code I am using is as follows:

#include <SoftwareSerial.h>

SoftwareSerial EEBlue(19, 18); // RX | TX

void setup()

{

Serial.begin(9600);

EEBlue.begin(9600); //Default Baud for comm, it may be different for your Module. 
Serial.println("The bluetooth gates are open.\n Connect to HC-05 from any other bluetooth device with 1234 as pairing key!.");

}

void loop()

{

// Feed any data from bluetooth to Terminal. 
if (EEBlue.available()) 
  Serial.write(EEBlue.read());

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

}

I am using the Bluetooth Serial app by Qwerty to try to communicate with the module through Arduinos Serial Monitor. Currently, anything I type into the Serial Monitor displays on the tablet I am connected to, but nothing from the tablet will display on the Serial Monitor. Everything seems to be set up correctly, apart from me skipping the voltage division. Is that what is causing my issue? I was under the impression it would work without it.

EDIT: I just tried adding the voltage division onto the RX lead, using a 1k resistor and 2.2k resistor, and it would not send signal at all.

Do not use software serial on these pins, use Serial1.
Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).

There should be no need to use Software Serial on a Mega with its four hardware serial ports.

Bit of honesty here, this is my first time ever working with Arduino, and barely a coder.

So I should be able to remove the SoftwareSerial entirely, swapping out to Serial1? And if I can only use those pins for RX, why do 15, 17 & 19 have RX1, RX2, RX3 printed on the board? and what can I use for TX?

https://www.arduino.cc/reference/en/language/functions/communication/serial/

Thank you, that has fixed the problem, I now have 2 way communication.

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