1

I have an arduino mega 2560 and a recently purchased HC-08 module and the connection is as the following:

Arduino | HC-08

VCC - VCC

GND - GND

14TX3 - TXD

15TX3 - RXD

When I power up the arduino it shows that flashing light and I am able to see it on my android phone but would only reject the connection every time I tried to pair. Also I am not able to send or receive any data from it at all, here is my code:

#include <SoftwareSerial.h>
SoftwareSerial hc08(15,14) // RX pin, TX pin;
void setup(){
 //Initialize Serial Monitor
 Serial.begin(9600);
 Serial.println("ENTER AT Commands:");
 //Initialize Bluetooth Serial Port
 hc08.begin(9600);
}
void loop(){
 //Write data from HC08 to Serial Monitor
 if (hc08.available()){
 Serial.println("Reading from bluetooth");
 Serial.write(hc08.read());
 }
 
 //Write from Serial Monitor to HC08
 if (Serial.available()){
 Serial.println("Writing to bluetooth");
 hc08.write(Serial.read());
 } 
}

I'd really appreciate help on how to get it working.

asked Aug 25, 2020 at 9:19
5
  • 1
    Don't use SoftwareSerial when you're using the hardware serial pins. For TX3/RX3 use Serial3. In fact, on the 2560 don't use SoftwareSerial at all - there's only certain select pins it will work on. Commented Aug 25, 2020 at 9:45
  • Could you send a link to any documentation of this so I can see how to use Serial3 Commented Aug 25, 2020 at 10:02
  • I've now seen I can just use Serial1, 2 or 3 just like I would use Serial. Thanks Commented Aug 25, 2020 at 10:05
  • But there still is the problem with the pairing being rejected. Commented Aug 25, 2020 at 10:10
  • But now you should be able to see and control the HC-08 through the Arduino to configure the pairing - however that's done on that board (I've never used one). Commented Aug 25, 2020 at 10:26

2 Answers 2

1
void setup(){
 //Initialize Serial Monitor
 Serial.begin(9600);
 Serial.println("ENTER AT Commands:");
 //Initialize Bluetooth Serial Port
 Serial3.begin(9600);
}
void loop(){
 //Write data from HC08 to Serial Monitor
 if (Serial3.available()){
 Serial.println("Reading from bluetooth");
 Serial.write(Serial3.read());
 }
 
 //Write from Serial Monitor to HC08
 if (Serial.available()){
 Serial.println("Writing to bluetooth");
 Serial3.write(Serial.read());
 } 
}
answered Aug 25, 2020 at 10:07
1
  • ALSO: the HC-08 uses BLE, unlike the HC-05 and HC-06 and so won't exactly connect through the phone's system bluetooth settings. Commented Aug 25, 2020 at 20:01
1

I think this is the problem on the hardware setting. It should be: Arduino | HC-08

VCC - VCC

GND - GND

14RX3 - TXD

15TX3 - RXD

Variable declare: SoftwareSerial hc08(14,15) // RX pin, TX pin;

answered Jan 26, 2021 at 0:07

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.