HC-05 Bluetooth Module Interfacing with ARM MBED
HC-05 Bluetooth Module
HC-05 is a Bluetooth device used for wireless communication with Bluetooth enabled devices (like smartphone). It
communicates with microcontrollers using serial communication (USART).
Default settings of HC-05 Bluetooth module can be changed using certain AT commands.
As HC-05 Bluetooth module has 3.3 V level for RX/TX and microcontroller can detect 3.3 V level, so, there is need to shift TX
voltage level of HC-05 module to microcontroller.
For more information about HC-05 Bluetooth module and how to use it, refer the topic HC-05 Bluetooth module.
Interfacing Diagram
Interfacing HC-05 Bluetooth Module with ARM MBED
Note: Default Bluetooth name of the device is “HC-05” and default PIN (password) for connection is either “0000” or “1234”.
Example
Here, we will transmit any character or string from Smartphone via Bluetooth to the ARM MBED and toggle the LED1 of mbed
board.
Download and install a Bluetooth terminal application on your phone and use it to connect to the HC-05 Bluetooth module.
Data is sent from the Smartphone using the Bluetooth terminal application.
Program
#include "mbed.h"
Serial pc(USBTX, USBRX);
#if defined(TARGET_LPC1768)
Serial blue(p9, p10); // TX, RX
//Serial blue(p13, p14); // TX, RX
#elif defined(TARGET_LPC4330_M4)
Serial blue(P6_4, P6_5); // UART0_TX, UART0_RX
//Serial blue(P2_3, P2_4); // UART3_TX, UART3_RX
#endif
DigitalOut myled(LED1);
DigitalOut myled4(LED4);
int main()
blue.baud(115200);
pc.baud(115200);
pc.printf("Bluetooth Start\r\n");
// echo back characters and toggle the LED
while (1)
if (blue.readable())
pc.putc(blue.getc());
myled = !myled;
if (pc.readable())
blue.putc(pc.getc());
myled4 = !myled4;