9 years, 5 months ago.

Bluetooth HC-06 Communication with Mbed ST Nucleo F401RE

Hi , I am trying for bluetooth communication using mbed and HC06 bluetooth module. Also I am using Bluetooth SPP Manager app (from playstore) to send commands from mobile bluetooth paired with HC-06 module. With the above code I am able to operate LED from HTerm installed on PC. Its not working when trying to operate from mobile

  1. include "mbed.h"

Serial bt(D1,D0);

DigitalOut myled(D13);

int main() {

bt.baud(9600);

bt.printf("Connection Established");

bt.printf("Recieved data to LED \n\r");

while(1) {

if (bt.readable()) {

char x = bt.getc();

if ( x == 'a') {

myled = 1;

}

if (x == 'b') {

myled = 0;

}

}

}

}

Has anyone done bluetooth communication using HC-06 module.If so please let me know where I am doing wrong

have u established BT connection? Is LED indicator on HC06 is on constantly, or flashes?

posted by Anton Boyt 26 Nov 2014

Thanks for your quick reply. Connection is established and I am getting data. When I am trying to send data from mobile to mbed through bluetooth only I am facing issue.Led on HC-06 is on constantly.

posted by Avinash Babu 27 Nov 2014

1 Answer

9 years, 5 months ago.

Hi, have you manged the bridges like described here: http://developer.mbed.org/teams/ST/wiki/Use-of-D0D1-Arduino-pins Another thing, I have checked they use

Serial bt(D0,D1); 

but you write

Serial bt(D1,D0); 

I'm not sure what version is correct, but some guy from here http://developer.mbed.org/questions/5255/Communicating-with-HC-06-bluetooth-modul/ does like

Serial HC06(D0,D1);

according to the manual the sequenсe must be as you do: Tx first (D1), then RX(D0).

upd: I use Serial 6 to communicate with HC 06. There is no need to solder bridges, as you need to do It in case with Serial2, Serial6 connected to Morpho pins by default. code for initialization:

Serial pc(PA_11, PA_12);/* Serial6 tx rx */

It works well: sends and recieves data