HC-05 Bluetooth Module Interfacing with ARM MBED

Overview of Bluetooth

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).

The default settings of the HC-05 Bluetooth module can be changed using certain AT commands.

As the HC-05 Bluetooth module has a 3.3V level for RX/TX and the microcontroller can detect the 3.3V level, so, there is a need to shift TX voltage level of the HC-05 module to the microcontroller.

 

For more information about the HC-05 Bluetooth module and how to use it, refer the topic HC-05 Bluetooth module.

 

Connection Diagram of HC-05 Bluetooth with ARM MBED (LPC1768)

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”.

 

Control LED using HC-05 Bluetooth and ARM MBED (LPC1768)

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.

 

HC-05 Bluetooth Code for ARM MBED (LPC1768)

#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;
        }
    }
}

Components Used

ARM mbed 1768 LPC1768 Board
ARM mbed 1768 Board
1
Bluetooth Module HC-05
Bluetooth is a wireless communication protocol used to communicate over short distances. It is used for low power, low cost wireless data transmission applications over 2.4 – 2.485 GHz (unlicensed) frequency band.
1

Downloads

HC05_bluetooth_mbed_uvision5_lpc1768 Download
Ad