HC06 ATMega 2560

Hi,
I seem to have an issue where I am able to receive data from arduino->hc06->phone but not the other way around. So I am never able to get messages from the HC06.

Is there any know limitation of this for atmegas? I am connected to pin 14 and 15 and I am able to send data, so the TX RX should be fine.

There is no such limitation.

Do you connected the GND pins of your Mega and HC06 module?

Please show the minimal code which demonstrates how you send and receive data to/from HC06 on arduino.

You should have a read here first:
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966

This suggests you are able to send from Arduino, which confirms your wiring and procedures are kosher, but not able to receive from the phone, which suggests your code isn't, but it is, apparently, a secret.

See posts #2 and #4

Here is the code I was using

#include <SoftwareSerial.h>
SoftwareSerial BTserial(15, 14); // RX | TX


void setup() 
{
    Serial.begin(9600);
    Serial.println("Enter AT commands:");
    

  // HC-06 default serial speed is 9600
    BTserial.begin(9600);  
}

void loop()
{
  
    if (BTserial.available())
    {  
        Serial.write(BTserial.read());
    }
    if (Serial.available())
    {
        BTserial.write(Serial.read());
    }

}

Probably won't make a difference because it's just the logic voltage level, but you should connect the ground on the breadboard to the ground on the Mega to pull the voltage down to prevent damage to HC06.
I don't own a HC06 but if it's anything like the HC-05 then you may need to change the relevant modes using AT commands. master /slave? baud rate? etc

1 Like

Why on earth are you using SoftwareSerial on a board that has several extra hardware serial ports?

The irony is, you are already attached to one of them. :slight_smile:

I can't get it to reply to the AT commands as well :slightly_frowning_face:

Using software serial on hardware serial pins is a sure recipe for disaster and completely unnecessary.
There is nothing to suggest you need AT commands. You can use it as is.

As others have pointed out you may not need to, your problem is to do with you accidently assigning new serial lines on pins that are hardwired as such to begin with, so you're confusing the arduino I think. I would try setting up the serial lines on different pins.

Thanks guys, I feel dumb :stuck_out_tongue: I took your feedback and it's working. :metal:

Can you be more specific, for people that read this thread later?

That suggestion was for troubleshooting.

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