HC-05 Bluetooth Master-Slave is not working probably

Hi. i wonder if someone can help me. im having problem with my arduino. basically i tried to do a Master-Slave connection but when it comes to AT Mode at Serial Monitor i am having this kind of non-stop characters spamming in my Serial Monitor and i cant perform the AT commands(see image below).

i also noticed that my Bluetooth HC-05 doesnt have "STATE" Pin and i only have Pins for RX,DX,VCC,GND. i wonder what should i do? this is my code:

Master:
#include <SoftwareSerial.h>
#define ledPin 9 //port9
#define Button 8
int state = 0;
SoftwareSerial configBt(0,1);
void setup() {
pinMode(1,OUTPUT);
pinMode(0,INPUT);
// put your setup code here, to run once:
pinMode(Button, INPUT);
digitalWrite(ledPin, LOW);
Serial.begin(38400);
configBt.begin(38400);
}
void loop() {
if (Serial.available()>0){
state = Serial.read();
}
if (digitalRead(8)== LOW){
Serial.write(HIGH);
}else{
Serial.write(LOW);
}
}

SLAVE:

#include <SoftwareSerial.h>
#define ledPin 9 //port9
#define Button 8
int state = 0;
SoftwareSerial configBt(0,1);
void setup() {
pinMode(1,OUTPUT);
pinMode(0,INPUT);
pinMode(Button, INPUT);
digitalWrite(ledPin, LOW);
Serial.begin(38400);
configBt.begin(38400);
}
void loop() {
if(Serial.available()>0){
state = Serial.read();
}
digitalWrite(8,state);
}

1. Check that the BTs are connected as per following diagram (Fig-1). It is not recommended to use DPin-0 and 1 as these pins are engaged with Serial Monitor/IDE.


Figure-1:

2. Check that BTs are paired. Let them run at default settings.
3. Upload the following sketches to UNO and NAN0 for functionality check of BTs.
UNO Sketch:

#include<SoftwareSerial.h>
SoftwareSerial SUART(7, 8);  //SRX = DPin-7, STX = DPin-8

void setup()
{
  Serial.begin(9600);
  SUART.begin(9600);  //activate Software Serial Port (SUART)
}

void loop()
{
  SUART.print('A');
  delay(1000);
}

NANO Sketch:

#include<SoftwareSerial.h>
SoftwareSerial SUART(7, 8);  //SRX = DPin-7, STX = DPin-8

void setup()
{
  Serial.begin(9600);
  SUART.begin(9600);  //activate Software Serial Port (SUART)
}

void loop()
{
  byte y = SUART.available();//check if a charcater has come from UNO via SUART Port
  if (y != 0) //a charcater has arrived
  {
    char x = SUART.read(); //read the charcater
    Serial.println(x); //
  }
}

4. Press RESET buttons on both Arduinos.
5. Chaeck that the charcater A appers on Serial Monitor of NANO at 1-sec interval.

Hi GolamMostafa, tried to copy paste your codes. i also try to connect the TX to 7pin, RX - 8th pin and GND, GND to GND, and VCC(in my Bluetooth) to 5v. i believe i am doing it correctly. i tried to use both UNO though. anyway, i then try to mount the code respectively and upload it. i then press both RESET buttons on UNOs but none work. my screen are blank for both. i also try to press RESET on Bluetooth HC but nothing appear as well, try to change the Serial Monitor to 38400 but still nothing works...i wonder why none work.

Now, the process of trouble shooting begins:

1. Remove USB connector of NANO from PC.
2. Leave only the UNO and BT as are shown in Post#1. Do not forget to connect the voltage divider circuit with the BT,
3. Power on UNO and check that the RED-LED of BT is blinking at about 1 Hz rate.
4. Bring in the BT Terminal of your Android Phone.
5. Check that BT of Mobile and BT of UNO are paired. This can be known by looking at the RED-LED of BT which now blinks once a while. If not paired, change the BT of UNO with the BT of NANO. If there is still not pairing, then the BTs are probably in Master Mode which must be chnaged using AT command along with corrrect Bd=9600.

6. Upload the followinh sketch in UNO.

#include<SoftwareSerial.h>
SoftwareSerial SUART(7, 8);  //SRX = DPin-7, STX = DPin-8

void setup()
{
  Serial.begin(9600);
  SUART.begin(9600);  //activate Software Serial Port (SUART)
}

void loop()
{
  byte y = SUART.available();//check if a charcater has come from Mobile via SUART Port
  if (y != 0) //a charcater has arrived
  {
    char x = SUART.read(); //read the charcater
    Serial.println(x); //
  }
}

7. Press RESET button of UNO.
8. Set BT Terminal of Mobile in ASCII Mode with CR and LF un-checked.
9. Send A from Mobile.
10. Check that A has appeared on Serial Monitor of UNO.
11. In the same way, check the functionality of UNO-BT and Mobile-BT.

If the above setup does not work, please tell in which step you are failing.

keanu-type0:
Bluetooth HC-05 doesnt have "STATE" Pin and i only have Pins for RX,DX,VCC,GND. i wonder what should i do?

Easy. Just come to terms with the fact that you haven't got an HC-05, it's an HC06.

You might find the following background notes useful.

Whatever you are trying to do is far from clear, even your intention is murky. If you have two Blueteeth the same and you want them to communicate with each other, you have to replace ONE with an HC-05. HC-06 is slave only, and may warrant no configuration.

No comment on the serial monitor other than it is probably not running at the correct rate, i.e. not matching what your Arduino programme declares, and you probably haven't done any damage.

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