HC-05(ZS-040) Arduino

I connected my Bluetooth module to Arduino MEGA 2560 using vcc,gnd,rx,tx.
Then I connected it to android device to bluetooth terminal and tried to send messages and Arduino doesn't show them. When I tried to send from Arduino serial port bluetooth terminal show them. AT command doesn't respond( yes I started with AT mode indicator. is showing AT mode but when I'm sending "AT" I don't receive any answer).

How? Rx to Tx and Tx to Rx would be the usual way to communicate from an Arduino (the Mega) to the HC-05.

If you connect Rx to Rx and Tx to Tx and keep the Mega in reset, it acts as a serial-to-usb converter. What you type in serial monitor will go to the HC-05 (and your phone) and what you type on your phone will go to serial monitor.

The Rx and Tx pins on the Mega are also used for communication with the PC and using it for two things is usually not working.

You can use one of the other serial pairs on the Mega (e.g. Rx1 and Tx1) for communication with the HC-05 and keep Rx and Tx for the communication with the PC.

Start by using Serial1 on the Mega (pins 19 Rx and 18 Tx) instead of Serial as that is used by the Serial monitor and to upload sketches

Post your test sketch using code tags when you do

(post deleted by author)

// code by Martyn Currie.
// To enable AT mode, connect the EN pin of the HC05
// to 3.3V before powering the HC05.
// Caution, do not connect EN to 5V.

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

const long baudRate = 9600;
char c = ' ';
boolean NL = true;

void setup() {
  Serial.begin(9600);
  Serial.print("Sketch:   ");
  Serial.println(__FILE__);
  Serial.print("Uploaded: ");
  Serial.println(__DATE__);
  Serial.println(" ");

  BTserial.begin(baudRate);
  Serial.print("BTserial started at ");
  Serial.println(baudRate);
  BTserial.print("BTserial started at ");
  BTserial.println(baudRate);
  Serial.println(" ");
}

void loop() {
  // Read from the Bluetooth module and send to the Arduino Serial Monitor
  if (BTserial.available()) {
    c = BTserial.read();
    Serial.write(c);
  }

  // Read from the Serial Monitor and send to the Bluetooth module
  if (Serial.available()) {
    c = Serial.read();
    BTserial.write(c);

    // Echo the user input to the main window. The ">" character indicates the user entered text.
    if (NL) {
      Serial.print(">");
      NL = false;
    }
    Serial.write(c);
    if (c == 10) {
      NL = true;
    }
  }
}

Tried both way, at the moment I’m using 14,15 pins (TX3, RX3) and same android device received all messages, but serial monitor on PC doesn’t receive nothing when I try to send something from Android

Why are you using SoftwareSerial on the Serial3 hardware UART pins ? Just use Serial3 as you would Serial

Just Serial3.begin(9600)?

Yes, or whatever speed you need. Then you can use Serial3.available(), Serial3.read() etc

Nice.Thanks.All works now🫡

That's good