SD Card is a SPI driven device; so, leave it connected with (Vcc ----> 3.3V; CS ----> 4; MOSI ----> 51; SCK ----> 52; MISO -----> 50).
HC05 is UART driven device. MEGA has four hardware UART ports. UART0 has been used for the Serial Monitor. UART1 (TX1, RX1) can safely be used for the HC05.
A: The following is the connection diagram between HC05 and MEGA using UART1 (Tested)
B: Tseting Codes for HC-05. Use Android based Smart Phone as the Master Bluetooth Module
char c = ' ';
void setup()
{
Serial.begin(9600);
Serial.println("Arduino is ready");
// HC-05 default serial speed for communication mode is 9600
Serial1.begin(9600);
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (Serial1.available())
{
c = Serial1.read();
Serial.write(c);
}
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
{
c = Serial.read();
// Copy the serial data back to to the serial monitor.
// This makes it easy to follow the commands and replies
Serial.write(c);
Serial1.write(c); //send to Bluetooth Master (Smart Phone) via UART1
}
}
C: Operating Procedures
(1) Build circuit as per diagram of Section-A.
(2) Compile and upload the sketch of Section-B. Bring in the Serial Monitor.
(c) Collect an Android based Smart Phone with a Bluetooth Terminal App installed. This is the Master Bluetooth Terminal and connect/pair it with the the Slave Bluetooth Terminal which is attached with MEGA.
(d) Send the character A from the Master; check that the character has appeared on the screens of both the Master and the Serial Monitor.
(e) Send the character R from the Serial Monitor; check that the character has papered on the screen of the Master.