Hello
I want to receive and send values to an Arduino board from a smartphone (Android) using bluetooth.
I use an Arduino Mega 2560 and a Grove Bluetooth shield v2.
My test code is at the end of the message.
From a terminal on the smartphone, I succeeded to receive values written in the serial monitor. But nothing is received in the serial monitor when I write from the smartphone terminal.
Have you some advice, please ?
Thanks in advance.
[code]
#include <SoftwareSerial.h> //Software Serial Port
#define RxD 6
#define TxD 7
SoftwareSerial blueToothSerial(RxD,TxD);
void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();
}
void loop()
{
blueToothSerial.flush();
if (blueToothSerial.available()) {
Serial.write(blueToothSerial.read());
}
if (Serial.available()) {
blueToothSerial.write(Serial.read());
}
}
void setupBlueToothConnection()
{
blueToothSerial.begin(9600); // Set BluetoothBee BaudRate to default baud rate 9600
blueToothSerial.print("AT");
delay(500);
blueToothSerial.print("AT+DEFAULT"); // Restore all setup value to factory setup
delay(500);
blueToothSerial.print("AT+NAMEBLTTT"); // set the bluetooth name name must less than 12 characters.
delay(500);
//blueToothSerial.print("AT+ROLEM"); // set the bluetooth work in master mode
delay(500);
blueToothSerial.print("AT+PIN0000"); // set the pair code to connect
delay(500);
blueToothSerial.print("AT+AUTH1");
delay(500); // This delay is required.
//blueToothSerial.flush();
}
[/code]