Sunday, July 5, 2015

Connect Arduino Due with HC-06 (Bluetooth Module)

Last post (direct to Arduino-er: Test HC-06 Bluetooth Module with Android BluetoothChat) show how to use Android Bluetooth Chat test app to talk with standalone HC-06. This post show how to connect Arduino Due to HC-06 via Serial 3, to receive data from Android and echo back to Android, and also send to Serial port for monitoring.


Connection between Arduino Due and HC-06:
Serial (Tx/Rx) communicate to PC via USB
Serial3 (Tx3/Rx3) connect to HC-06
HC-06 Rx - Due Tx3
HC-06 Tx - Due Rx3
HC-06 GND - Due GND
HC-06 VCC - Due 3.3V

DueHC06_AT.ino
/*
Arduino Due + HC-06 (Bluetooth) -echo bluetooth data

Serial (Tx/Rx) communicate to PC via USB
Serial3 (Tx3/Rx3) connect to HC-06
HC-06 Rx - Due Tx3
HC-06 Tx - Due Rx3
HC-06 GND - Due GND
HC-06 VCC - Due 3.3V

*/
#define HC06 Serial3

void setup()
{
  delay(1000);
  Serial.begin(9600);
  HC06.begin(9600);
  
  Serial.write("\nTest Start\n");
}

void loop()
{
  while(HC06.available())
  {
    char data = HC06.read();
    Serial.write(data);
    HC06.write(data);
  }
}

Related:
Android BluetoothChat connect to Arduino Uno + HC-05

2 comments: