hello people,
we are working with 2 Arduino boards each connected with Wireless Bluetooth Transceiver HC-05 RS232 / TTL Base Board. We generate 6 digit codes on one board and want to receive them on other. The codes transmitted by one HC05 are detected via android application "SENA BTERM", but the other HC-05 is receiving nothing
the code for the transmitting end is:
#include <SoftwareSerial.h>
#define RxD 10
#define TxD 11
#define Reset 5
#define PIO11 8
#define Led 13
#define RTS 4
SoftwareSerial blueToothSerial(RxD,TxD);
void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
pinMode(Led, OUTPUT);
pinMode(PIO11, OUTPUT);
digitalWrite(PIO11, HIGH);
pinMode(Reset, OUTPUT);
digitalWrite(Reset, LOW);
pinMode(RTS, INPUT);
setupBlueToothConnection();
}
void setupBlueToothConnection()
{
enterATMode();
sendATCommand();
sentATCommand("UART=9600,0,0");
sentATCommand("ROLE=1");
enterComMode();
}
void enterATMode()
{
blueToothSerial.flush();
delay(500);
digitalWrite(PIO11, HIGH);
resetBT();
delay(500);
blueToothSerial.begin(9600);
}
void resetBT()
{
digitalWrite(Reset, LOW);
delay(2000);
digitalWrite(Reset, HIGH);
}
void sendATCommand()
{
blueToothSerial.print("AT\r\n");
delay(100);
}
void sentATCommand(char *command)
{
blueToothSerial.print("AT");
if(strlen(command) > 1){
blueToothSerial.print("+");
blueToothSerial.print(command);
delay(100);
}
blueToothSerial.print("\r\n");
}
void enterComMode()
{
blueToothSerial.flush();
delay(500);
digitalWrite(PIO11, LOW);
resetBT();
delay(500);
blueToothSerial.begin(9600);
}
void loop()
{
Serial.println(blueToothSerial.print("12345"));
delay(1000);
}
and the code for the receiving end is:
#include <SoftwareSerial.h>
#define RxD 50
#define TxD 51
#define Reset 5
#define PIO11 8
#define Led 13
#define RTS 4
SoftwareSerial blueToothSerial(RxD,TxD);
void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
pinMode(Led, OUTPUT);
pinMode(PIO11, OUTPUT);
digitalWrite(PIO11, HIGH);
pinMode(Reset, OUTPUT);
digitalWrite(Reset, LOW);
pinMode(RTS, INPUT);
setupBlueToothConnection();
}
void setupBlueToothConnection()
{
enterATMode();
sendATCommand();
sentATCommand("UART=9600,0,0");
sentATCommand("ROLE=0");
enterComMode();
}
void enterATMode()
{
blueToothSerial.flush();
delay(500);
digitalWrite(PIO11, HIGH);
resetBT();
delay(500);
blueToothSerial.begin(9600);
}
void resetBT()
{
digitalWrite(Reset, LOW);
delay(2000);
digitalWrite(Reset, HIGH);
}
void sendATCommand()
{
blueToothSerial.print("AT\r\n");
delay(100);
}
void sentATCommand(char *command)
{
blueToothSerial.print("AT");
if(strlen(command) > 1){
blueToothSerial.print("+");
blueToothSerial.print(command);
delay(100);
}
blueToothSerial.print("\r\n");
}
void enterComMode()
{
blueToothSerial.flush();
delay(500);
digitalWrite(PIO11, LOW);
resetBT();
delay(500);
blueToothSerial.begin(9600);
}
void loop()
{
Serial.println(blueToothSerial.read());
delay(1000);
}
the problem is that app shows that data is correctly transmitted, but the receiving side shows 0 0 0 0 0 0 on the serial monitor window. As the HC05 is by default configured as a slave, so we checked the receiving end without programming the Bluetooth as well. works neither way.
Can anybody please help us in communication between these two boards. where are we going wrong?