Hi
I would like to connect a device with a serial output to a Standalone Arduino which then connects via Bluetooth to an arduino attached to the PC at 57600 Baud. In order to tackle this one by one I am starting with the following Setup:
-2 x Arduino Mega2560
-2 x Grove Serial Bluetooth 3.0 Grove - Serial Bluetooth v3.0 | Seeed Studio Wiki
So currently the basich schematic is the following:
PC - Arduino - Bluetooth Module Bluetooth Module - Arduino - PC
On the Arduino I am trying to get the Serial passthrough from Serial to Serial 1 working where I attached the Bluetooth Modules.
The following is the code running on the Central Arduino:
////Central
void setup() {
Serial.begin(9600);
Serial.println("CENTRAL");
// Serial1.begin(57600);
Serial1.begin(9600);
setupBlueToothConnection();
Serial.flush();
Serial1.flush();
// Serial1.begin(57600);
// Serial.flush();
// Serial1.flush();
Serial.println();
Serial.println("Ready");
Serial1.println("Central Ready");
}
void loop() {
if (Serial.available()) { // If anything comes in Serial (USB),
Serial1.write(Serial.read()); // read it and send it out Serial1 (pins 0 & 1)
}
if (Serial1.available()) { // If anything comes in Serial1 (pins 0 & 1)
Serial.write(Serial1.read()); // read it and send it out Serial (USB)
}
}
void setupBlueToothConnection() {
// Serial1.begin(9600);
Serial1.print("AT");
delay(400);
Serial1.print("AT+DEFAULT"); // Restore all setup value to factory setup
delay(2000);
Serial1.print("AT+NAMESeeedMaster"); // set the bluetooth name as "SeeedMaster" ,the length of bluetooth name must less than 12 characters.
delay(400);
Serial1.print("AT+ROLEM"); // set the bluetooth work in slave mode
delay(400);
//Serial1.print("AT+BAUD7");
//delay(400);
Serial1.print("AT+AUTH1");
delay(400);
Serial1.print("AT+CLEAR"); // Clear connected device mac address
delay(400);
Serial1.flush();
}
And on the peripheral Arduino:
/*Peripheral*/
void setup() {
Serial.begin(9600);
Serial.println("PERIPHERAL");
// Serial1.begin(57600);
Serial1.begin(9600);
setupBlueToothConnection();
Serial.flush();
Serial1.flush();
// Serial1.begin(57600);
// Serial.flush();
// Serial1.flush();
Serial.println();
Serial.println("Ready");
Serial1.println("Peripheral Ready");
}
void loop() {
if (Serial.available()) { // If anything comes in Serial (USB),
Serial1.write(Serial.read()); // read it and send it out Serial1 (pins 0 & 1)
}
if (Serial1.available()) { // If anything comes in Serial1 (pins 0 & 1)
Serial.write(Serial1.read()); // read it and send it out Serial (USB)
}
}
void setupBlueToothConnection() {
// Serial1.begin(9600);
Serial1.print("AT");
delay(400);
Serial1.print("AT+DEFAULT"); // Restore all setup value to factory setup
delay(2000);
Serial1.print("AT+NAMESeeedBTSlave"); // set the bluetooth name as "SeeedBTSlave" ,the length of bluetooth name must less than 12 characters.
delay(400);
// Serial1.print("AT+BAUD7");
// delay(400);
Serial1.print("AT+PIN0000"); // set the pair code to connect
delay(400);
Serial1.print("AT+AUTH1"); //
delay(400);
Serial1.flush();
}
The code is modified from the SEEED button/LED example as I have hardware serial ports at my disposal, I don't need to use softwareserial. The LED example works.
At standard 9600 I can connect and the two seem to communicate:
Central side:
CENTRAL
Ready
AT+DEFAULTAT+NAMESeeedBTSlaveAT+PIN0000AT+AUTH1Peripheral ReadySent from peripheral
Peripheral side:
PERIPHERAL
Ready
ATAT+DEFAULTAT+NAMESeeedMasterAT+ROLEMAT+AUTH1AT+CLEARCentral Ready
Test
But I seem to be unable to change the Bluetooth (and the computer-Arduino) baudrate to my desired 57600, no matter what I try, the two won't connect anymore.
AT+BAUD7 does not seem to do anything, in the worst case the two bluetooth modules don't seem to connect anymore and I am getting garbage in the Serial monitor.
I tried with init Serial1 at 9600, send the AT+BAUD7, then serial1.flush, then serial1.begin(57600) but nothing seems to work. I would be grateful if anyone has an idea to get the bidirectional communication working at higher baudrates! After that I will tackle attaching my device to serial2 and have it talk via bluetooth ![]()


