Use HC-06 Bluetooth Module to Realize Micro:bit Communication With Mobile Phone

Lots of friends around me who play micro:bit tell me that the Bluetooth connection of micro:bit is not stable. It is easy to disconnect. If we use micropython, the Bluetooth cannot even be put to use. Before this problem is solved by micro:bit official, here we have another compromized method. That is to use HC-05/HC-06 module. Today I am going to share with you how to use micro:bit to drive HC-06 module. The hardware of HC-05 and HC-06 are the same. They adpot BC417143 chip from CSR (Cambridge Silicon Radio). It supports Bluetooth 2.1+EDR regulations.  

Two Operations Of Bluetooth Module

Automatic connection, also called transparent communication. Order-response, also called AT mode. Automatic connection we normally used is just for converting the RxD input data into wireless Bluetooth signal and send it out, or transmit the received wireless data from TxD to the controller. The module itself can not read data nor accept command. All commands used to control Bluetooth module are called AT command (AT-command). ATcommand do not transmit by Bluetooth but the footer Txd and RxD of the module. Only under AT mode can Bluetooth module accept AT command.  

Common AT Command For HC06

Note: Once being charged, HC-06 module will enter AT mode automatically. At this time, the indicator will swiftly flash. After matched, the indicator will change into constant light mode.  


1 x BBC Micro:bit Board

1 x ElecFreaks Micro:bit Breakout Board

1 x Bluetooth Modem HC-06

1 x IIC OLED Module


Step 1 Connect HC06 module to micro:bit breakout board. Here's the connection of HC06 and micro:bit breakout board: GND-G VCC-VC RXD-TX TXD-RX STATE and KEY do npt connect.

Step 2 Connect OLED module to IIC serial port.

Step 3 Plug your micro:bit into breakout board, and connect it to your computer with a USB cable.

Step 4 Open makecode, search for OLED library and add it.

Step 5 Initialize OLED and serial port. You can refer to the parameters in the following pictures to do initialization.

Step 6 When button A is pressed, it will set the name of Bluetooth and matching code.

Step 7 Edit receive and send program .

Here's the complete program. You can download it into your micro:bit through the link below.

  Step 9 Press button A, we can see the information showed in the picture below on the OLED screen. If it is not like this, restart your micro:bit and press button A again.

Step 10 Install Bluetooth Terminal APP into your mobile phone. If you do not have this APP, you can click here to download one. Note: HC-06 do not support IOS system. You have to use Android mobile phone only.

Step 11 Open your Bluetooth in your mobile setting, you will see "myhc06" Bluetooth device.

Step 12 Click to connect "myhc06" and input PIN code 1234.

Step 13 Open Bluetooth Terminal on your mobile, choose BT (Bluetooth), and then click the Bluetooth icon in the right top corner.

Step 14 Choose "myhc06" and connect it.

Step 15 Ok! Right now to this step, we have finished the mobile settlement. Let's try to use your mobile to send some messages to micro:bit. You will see texts sent out from your mobile phone will be displayed on the OLED screen. Press button B on micro:bit, then you will see micro:bit messages displayed on your mobile phone. Quite amazing!

  What if we choose HC05 to do this communication?

There will have few difference between the AT command of HC-05 and the command of HC-06. As for the communication between HC05 and micro:bit, I will tell you in the next chapter. So just keep on watching us!