I have trouble with Problem with hc-05 bluetooth connection(Not sending message out through phone app)

Guys I currently working on a project. Please help me out
In order to keep a safe distance from each other and there is now a limited number of people that can be in a room together.
I had produced a code to program( Using Arduino Mega 2560)
2 infrared sensors

    • One to count up
    • One to count down
      Temperature sensor
  • Measure the temperature of each person that enters the room
    RGB LED Matrix to display a message
    • Number of people in the room
    • Temperature of the last person detected
      With the values being displayed on the RGB LED Matrix
      I using an app called

Currently, I am stuck with sending messages from Phone to Arduino, however, I can send out text(Arduino to Phone)instead. I want to add an additional function of sending real-time messages to my 64x32 RGB LED Matrix matrix

#include <RGBmatrixPanel.h>
#include <SoftwareSerial.h>

#define in 4
#define out 5
#define led 6

#include <Wire.h>
#include <Adafruit_MLX90614.h>

SoftwareSerial BT(2, 3); // RX | TX

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

//#define CLK 8 // USE THIS ON ADAFRUIT METRO M0, etc.
//#define CLK A4 // USE THIS ON METRO M4 (not M0)
#define CLK 11 // USE THIS ON ARDUINO MEGA
#define OE 9
#define LAT 10
#define A A0
#define B A1
#define C A2
#define D A3

RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false, 64);
String Arduino_data;
String BT_input;

void setup()
{

Serial.begin(9600);
Serial.println("Arduino is ready");
BT.begin(9600);
matrix.begin();
// fill the screen with 'black'

}

void loop()
{
matrix.fillScreen(matrix.Color333(0, 0, 0));
matrix.setTextColor(matrix.Color333(7, 0, 0));
if(BT.available())//keep reading from HC-05 and send to Arduino Serial Monitor
{
BT_input=BT.readString();
Serial.print(BT_input);
}
if(Serial.available())//keep reading from Arduino Serial Monitor and sent to HC-05
{
Arduino_data=Serial.readString();
matrix.setCursor(8, 17);
matrix.print(Arduino_data);
BT.print(Arduino_data);
delay(1000);
}

}

Hi, @omgspade1212
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

Can you also post a copy of your circuit please.
A hand drawn image with component and pin labels will be fine.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

image

sorry about that, Tom. I am new to the forum / Arduino. I try all kinds of solutions on the internet. I don't think the problem is the baud rate of HC05 as I can receive messages. Nonetheless, I tried to go into AT setting interface however I can't seem to go in either, I can't seem to send AT command. there are codes out there for testing hc05 send/receive messages I tried all of them. but I only can receive instead.

Hi,
Thanks for the circuit, but its resolution is too low to read.
Your CAD should have an EXPORT facility that should give bigger image.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:


how about this tom . i tried my best because i don't have a higher resolution copy . I am continuing another student project.

Hi,
So you didn't begin the project.
Okay
Google

hc-05 arduino

It will give you some simple code to check your BT unit.
In particular;

You need to back track and make sure each of your devices works on its own, you problem may be the mix of hardware and code.

Try the Arduino Project Hub example to prove you have BT connectivity and data transfer.

Tom... :smiley: :+1: :coffee: :australia:
PS, Avoid using Strings in your code, it eats memory space and can cause code corruption in the UNO, Nano and Mega environments.

Using Arduino Mega 2560
SoftwareSerial BT(2, 3); // RX | TX

You should not be using software serial on a Mega. Use one of the additional hardware serial ports like Serial1.
https://www.arduino.cc/en/Tutorial/BuiltInExamples/MultiSerialMega

HC05 RX goes to Arduino TX and Arduino RX goes to HC05 TX.

#include <SoftwareSerial.h>
SoftwareSerial MyBlue(2, 3); // RX | TX
int flag = 0;
int LED = 8;
void setup()
{
Serial.begin(9600);
MyBlue.begin(9600);
pinMode(LED, OUTPUT);
Serial.println("Ready to connect\nDefualt password is 1234 or 000");
}
void loop()
{
if (MyBlue.available())
flag = MyBlue.read();
if (flag == 1)
{
digitalWrite(LED, HIGH);
Serial.println("LED On");
}
else if (flag == 0)
{
digitalWrite(LED, HIGH);
Serial.println("LED Off");
}
}
Tom, I tried to test out the BT connectivity and data transfer. somehow it is not working, I tried their connection. this is what I get from my serial port. and my led is not lighting up.

void setup() {

// initialize both serial ports:

Serial.begin(9600);

Serial1.begin(9600);
}

void loop() {

// read from port 1, send to port 0:

if (Serial1.available()) {

int inByte = Serial1.read();

Serial.write(inByte);

}

// read from port 0, send to port 1:

if (Serial.available()) {

int inByte = Serial.read();

Serial1.write(inByte);

}
}

I had tried it but I keep having issues with the upload. I have tried to connect HC05 RX goes to Arduino TX and Arduino RX goes to HC05 TX. I even try to switch it around.

This is meaningless nonsense and just adds to the confusion.. Arduino has nothing to do with making the connection other than, perhaps, providing the power to the Bluetooth module.

IF this is true, there can't be anything seriously wrong. At the risk of further muddying the water, you might try the test at

This uses Serial 0 , pins 0,1. Upload code before Bluetooth connected. It can be confirmed with the serial monitor first and then connect Bluetooth and check with the phone.

No damage was done, but don't bother with this futile exercise.

hi nick, thanks for your help. it only able to appear single letter instead of the whole word. But may I ask the setting for the serial monitor? I only able to put it on (no line ending), else if put other than that nothing will appear.

I have test it on hc05 bluetooth as well . sorry i tried it as figure there is no harm done . but i seem to only able to sent to serial monitor(arduino) only . serial monitor is not sending to phone via hc05.

Can you show the connections with the HC05 on Serial1 and what if anything is connected to pin 0/1 Serial. The code you presented should load to a Mega if you are connected correctly.

A single letter, sent from phone and returned to phone from Arduino is all you need to prove that everything is kosher. You don't need the serial monitor, but you can use it instead and indeed, if you have Bluetooth on pins 0,1 you can prove the code using the serial monitor. Needless to say, HC-05 and monitor should both be at default setting 9600. Getting it right with serial monitor does wonders for your self-confidence. You then connect Bluetooth. As mentioned above, it is a good idea to use serial1 etc - eventually - but it isn't a bad idea to use serial0 pins 0,1 to start with so tht you can check things with the serial monitor. Just in case you aren't aware of it, serial monitor shares with serial0, thereby allowing you to use either without changing any code.

I managed to solve the problem(timeout error). i plug out the Tx/Rx pin when uploading to arduino mega . after upload , i just plug it back in, and it worked normally.


This one I connect HC05 to 3.3V / RX to TX / TX to RX
After I sent a message through the Phone, and nothing appears on the serial monitor.
So it is the same as I sent a message out using Arduino to phone. no message


This one I connect HC05 to 3.3V / Rx to Rx / Tx to Tx
After I sent a message through the app, and nothing appears on the serial monitor.
But when I sent a message through the Arduino, the phone received the message

Nick, I want to send real-time messages using a phone and display them on an RGB matrix display. (using Arduino Mega), therefore I am using serial monitor to check the functionality/connectivity of the Bluetooth.
I tried it again today.
I managed to get a string of words displayed on my phone*( Arduino to Phone )*
I don't get any words displayed on my Arduino*(Phone to Arduino)*
Below is my connection.

I tried to connect HC05 to 3.3V / RX to TX / TX to RX instead and this is what I got. both side is acting weird.


Thanks, Nick. Appreciate your help. I just want to clarify my project. I using serial monitor to check since my phone will bypass the Arduino and be sent to the display.

The HC05 should be powered from 5v not 3.3. This is important.
The cross connections of RX/TX and TX/RX is correct.

Really? That is another game altogether.

Do not use the Arduino's 3.3v to supply HC-05. The back of the board clearly states 3.6v minimum, and Mega may be light on for mA anyway.

I can't explain the reversed question marks. Do you see the text on the phone when Bluetooth is connected to pins 0,1?
Since it initiates the transmission, you might need to hit the reset button on the Mega.

It is the same . nothing happens. even after I connect the 5 V
After I sent a message through the Phone, and nothing appears on the serial monitor.
So it is the same as I sent a message out using Arduino to phone. no message

After I sent a message through the Phone, and nothing appears on the serial monitor. the weird thing is I have line spacing on the Bluetooth serial terminal, I'm not sure why.
So it is the same as I sent a message out using Arduino to Phone, no message appears on the Phone
This is Rx/Tx , Tx/Rx connection , 5V

I tried , nick. But it works as only 1 way communication when I connect Rx/Rx , Tx/Tx, connect 5V.. However there is text appear on the phone when I type through the Arduino. But when I want text appear on Arduino . So I not sure why I can't seem to establish a communication back to Arduino . (I using serial monitor to verify the communication)