# \[Solved\] HC05 Two Way Trouble

**URL:** <https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762>\
**Category:** Programming\
**Created:** [October 16, 2024, 3:19am UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762 "2024-10-16T03:19:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![decentro](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/decentro/32/1066007_2.png) [@decentro](https://forum.arduino.cc/u/decentro)\
**Post date:** [October 16, 2024, 3:19am UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/1 "2024-10-16T03:19:50Z")

</div>

I am using two Arduino Megas to try and interface with each other for a project. I have used many tutorials, and nothing has seemed to work. I have configured the modules in AT Command mode, paired them, and I have no idea why this isn't working. Can someone please help me out? Thank you in advance!

This is the code I have so far:

Master:

```arduino
#include <Arduino.h>
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3); // RX | TX

void setup() {
  Serial.begin(9600);
  BTSerial.begin(9600);
}

void loop() {
  BTSerial.println("hello"); 
  delay(1000); 
}

```

Slave:

```arduino
#include <Arduino.h>
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3); // RX | TX

void setup() {
  Serial.begin(9600);
  BTSerial.begin(9600);
}

void loop() {
    Serial.println(BTSerial.readString());
}

```

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [October 16, 2024, 3:25am UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/2 "2024-10-16T03:25:07Z")

</div>

You haven't provided enough information for forum members to guess the problem.

This seems by far the best collection of HC-05 tutorials, so go through them carefully:: [https://www.martyncurrey.com/arduino-with-hc-05-bluetooth-module-at-mode/](https://www.martyncurrey.com/arduino-with-hc-05-bluetooth-module-at-mode/)

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [October 16, 2024, 3:53am UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/3 "2024-10-16T03:53:30Z")

</div>

I can't help you but I'm curious why you're using SoftwareSerial on a board that has 3 spare UARTs?

---

<div class="post-metadata">

**Author:** ![decentro](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/decentro/32/1066007_2.png) [@decentro](https://forum.arduino.cc/u/decentro)\
**Post date:** [October 16, 2024, 10:56am UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/4 "2024-10-16T10:56:12Z")

</div>

What does that mean?

---

<div class="post-metadata">

**Author:** ![decentro](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/decentro/32/1066007_2.png) [@decentro](https://forum.arduino.cc/u/decentro)\
**Post date:** [October 16, 2024, 10:56am UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/5 "2024-10-16T10:56:32Z")

</div>

Do I need to share my wiring too?

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [October 16, 2024, 12:36pm UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/6 "2024-10-16T12:36:42Z")

</div>

It means that in general one does not need to use SoftwareSerial for Bluetooth but can use Serial1/2/3 and the respective pins on the Mega.

---

<div class="post-metadata">

**Author:** ![superbwoodpecker791](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/superbwoodpecker791/32/1108294_2.png) [@superbwoodpecker791](https://forum.arduino.cc/u/superbwoodpecker791)\
**Post date:** [October 16, 2024, 2:15pm UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/7 "2024-10-16T14:15:06Z")

</div>

```arduino
#include <Arduino.h>
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3); // RX | TX

void setup() {
  Serial.begin(9600);
  BTSerial.begin(9600);
}

void loop() {
  BTSerial.println("hello"); 
  delay(1000); 
}

```

If i'm correct this line.  
`BTSerial.println("hello"); `  
should be.  
`BTSerial.write("hello");`

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [October 16, 2024, 2:19pm UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/8 "2024-10-16T14:19:05Z")

</div>

No, _write_ will behave the same as _print_; _println_ will add a \<CR\>\<LF\>.

You can test those differences by simply using Serial instead of BTSerial and check what shows in serial monitor.

---

<div class="post-metadata">

**Author:** ![superbwoodpecker791](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/superbwoodpecker791/32/1108294_2.png) [@superbwoodpecker791](https://forum.arduino.cc/u/superbwoodpecker791)\
**Post date:** [October 16, 2024, 2:23pm UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/9 "2024-10-16T14:23:21Z")

</div>

My bad, Your correct.

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [October 16, 2024, 2:36pm UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/10 "2024-10-16T14:36:57Z")

</div>

> [@decentro](#):
>
> Do I need to share my wiring too?

There is a good chance that it is wrong, especially if you forgot to use logic level converters, or a resistive divider as the Martyn Currey tutorial recommends.

---

<div class="post-metadata">

**Author:** ![cattledog](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cattledog/32/217816_2.png) [@cattledog](https://forum.arduino.cc/u/cattledog)\
**Post date:** [October 16, 2024, 4:40pm UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/11 "2024-10-16T16:40:32Z")

</div>

> [@decentro](#):
>
> `SoftwareSerial BTSerial(2, 3); // RX | TX`

From  
[https://docs.arduino.cc/learn/built-in-libraries/software-serial/](https://docs.arduino.cc/learn/built-in-libraries/software-serial/)

> Not all pins on the Mega and Mega 2560 boards 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).

That explains why software serial instance was not working on the Mega.

As others have said, using software serial on a device with three additional hardware serial ports is the wrong way to go.

---

<div class="post-metadata">

**Author:** ![decentro](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/decentro/32/1066007_2.png) [@decentro](https://forum.arduino.cc/u/decentro)\
**Post date:** [October 16, 2024, 10:49pm UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/12 "2024-10-16T22:49:06Z")

</div>

I tried using UARTs and same issue.

---

<div class="post-metadata">

**Author:** ![decentro](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/decentro/32/1066007_2.png) [@decentro](https://forum.arduino.cc/u/decentro)\
**Post date:** [October 16, 2024, 10:59pm UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/13 "2024-10-16T22:59:18Z")

</div>

I don't think so because even after I changed the code to the UARTs I tried to make the arduinos communicate over wires.

This is how I connected it.  
TX -\> RX  
RX -\> TX

---

<div class="post-metadata">

**Author:** ![cattledog](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cattledog/32/217816_2.png) [@cattledog](https://forum.arduino.cc/u/cattledog)\
**Post date:** [October 16, 2024, 10:59pm UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/14 "2024-10-16T22:59:24Z")

</div>

> [@decentro](#):
>
> I tried using UARTs

Please post your code.

Can you read the line "hello" sent by the HC05 when you use a phone app like Kai Morich's Serial Bluetooth Terminal.

> <https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal&hl=en_US>
>
> Terminal for serial devices connected with Bluetooth Classic / L...

> I tried to make the arduinos communicate over wires.

If the two Mega's can't communicate over wires between two hardware serial ports then there is a different issue.

---

<div class="post-metadata">

**Author:** ![decentro](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/decentro/32/1066007_2.png) [@decentro](https://forum.arduino.cc/u/decentro)\
**Post date:** [October 16, 2024, 11:00pm UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/16 "2024-10-16T23:00:29Z")

</div>

Here is my new code:

```arduino
#include <Arduino.h>
#include <SoftwareSerial.h>

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() {
  Serial1.println("Hello World"); 
  delay(1000); 
}

```

Slave:

```arduino
#include <Arduino.h>
#include <SoftwareSerial.h>

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() {
    Serial.println(Serial1.readString());
}

```

---

<div class="post-metadata">

**Author:** ![decentro](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/decentro/32/1066007_2.png) [@decentro](https://forum.arduino.cc/u/decentro)\
**Post date:** [October 17, 2024, 2:01am UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/17 "2024-10-17T02:01:18Z")

</div>

That outputted Hello World but still no two-way communication on the arduinos yet. How can I change the code to make it work?

---

<div class="post-metadata">

**Author:** ![cattledog](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cattledog/32/217816_2.png) [@cattledog](https://forum.arduino.cc/u/cattledog)\
**Post date:** [October 17, 2024, 2:24am UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/18 "2024-10-17T02:24:16Z")

</div>

> [@decentro](#):
>
> How can I change the code to make it work?

It's not clear how you configured the two devices, but a good tutorial on how to configure and connect two HC05's is here  
[https://www.martyncurrey.com/connecting-2-arduinos-by-bluetooth-using-a-hc-05-and-a-hc-06-easy-method-using-cmode/](https://www.martyncurrey.com/connecting-2-arduinos-by-bluetooth-using-a-hc-05-and-a-hc-06-easy-method-using-cmode/)

If you are now using the Hardware Serial1 on pins 19 (RX) and 18 (TX), you do not need to include the software serial library.

If you remove the HC05 modules, can you get the Megas to communicate with each other over wires and Serial1?

Using the voltage divider on the module RX so that it doesn't see 5v is a good idea. It's not clear to me why you haven't done this.

---

<div class="post-metadata">

**Author:** ![decentro](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/decentro/32/1066007_2.png) [@decentro](https://forum.arduino.cc/u/decentro)\
**Post date:** [October 17, 2024, 3:04am UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/19 "2024-10-17T03:04:53Z")

</div>

I have done it because I was following that tutorial a while back, but the programming stumped me. Should the baud rate be 38400 instead of 9600?

---

<div class="post-metadata">

**Author:** ![decentro](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/decentro/32/1066007_2.png) [@decentro](https://forum.arduino.cc/u/decentro)\
**Post date:** [October 17, 2024, 3:33am UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/20 "2024-10-17T03:33:14Z")

</div>

Whenever I take out the wire of the TX and RX pins on the slave it prints a bunch of hello worlds. It never does this when it is plugged in. Is there any reason for this?

---

<div class="post-metadata">

**Author:** ![cattledog](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cattledog/32/217816_2.png) [@cattledog](https://forum.arduino.cc/u/cattledog)\
**Post date:** [October 17, 2024, 4:34am UTC](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762/21 "2024-10-17T04:34:06Z")

</div>

> [@decentro](#):
>
> Should the baud rate be 38400 instead of 9600?

The default baud rate for communication mode is 9600. The default baud rate for AT mode is 38400.

> Whenever I take out the wire of the TX and RX pins on the slave it prints a bunch of hello worlds.

I thought that the modules were wired to TX1 and RX1 of the Megas. I don't understand what you have connected to TX and RX.

> Do I need to share my wiring too?

Yes, please.

[Next page](https://forum.arduino.cc/t/solved-hc05-two-way-trouble/1311762.md?page=2)
