Bluetooth serial monitor recieving but not sending to Arduino, help!

Hi everyone, i built a very basic circuit with the HC05 and i am trying to send data between the Arduino IDE Serial Monitor and my smartphone through a BT-serial monitor. When i type stuff in my arduino serial monitor i recieve everything as normal. But when i try and send something from the monitor on my smartphone, it won't display anything on the monitor from Arduino. I tried it as well with turning a led on and off, but nothing happened, i'm just not able to send anything to my Arduino. I am using pin 0 and 1 on my Arduino Leonardo, i have tried different cables and a different breadboard. Hope somebody knows what the problem might be and hope you can help me out! Thanks in advance :slight_smile:

#include <SoftwareSerial.h>

SoftwareSerial bluetoothSerial(0, 1);  // RX, TX

void setup() {
  Serial.begin(9600);         // Serial Monitor
  bluetoothSerial.begin(9600); // Bluetooth module

  // Set the HC-05 to master or slave mode (AT commands may vary based on your HC-05 version)
  bluetoothSerial.print("AT+ROLE=0\r\n");  // 0: Slave mode, 1: Master mode

  // Set a recognizable name for your module
  bluetoothSerial.print("AT+NAME=MyBluetooth\r\n");

  // Set the PIN code for pairing (you can change this)
  bluetoothSerial.print("AT+PIN=1234\r\n");
}

void loop() {
  if (bluetoothSerial.available()) {
    char data = bluetoothSerial.read();
    Serial.write(data);  // Display data received from Bluetooth module on Serial Monitor
  }

  if (Serial.available()) {
    char data = Serial.read();
    bluetoothSerial.write(data);  // Send data from Serial Monitor to Bluetooth module
  }
}

Those pins are best used with Serial1 not software serial.

Why do you have the AT code in your sketch. The HC05 should be set in slave mode before using it in the sketch.

What app are you using on your phone? Kai Morich's Serial Bluetooth Terminal is one of the best.

The AT code was just a try and can be dismissed, we have not changed anything on our settings.

The HC05 is standard in slave mode i think and we have not changed this, but is there a way to check to make sure?

What should i change in my code to make sure i use Serial1 correctly and not software serial?

I'm already using that app as well! So don't think the problem is to do with the app.
we deleted the AT code and this is the code we use now.

#include <SoftwareSerial.h>

SoftwareSerial bluetoothSerial(0, 1);
void setup() {
  Serial.begin(9600);         // Serial Monitor
  bluetoothSerial.begin(9600); // Bluetooth module
}
void loop() {
  if (bluetoothSerial.available()) {
    char data = bluetoothSerial.read();
    Serial.write(data);  // Display data received from Bluetooth module on Serial Monitor
  }

  if (Serial.available()) {
    char data = Serial.read();
    bluetoothSerial.write(data);  // Send data from Serial Monitor to Bluetooth module
  }
}

We tried it with Serial1 and it worked! Thanks a lot

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