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

Picture of 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.

Step 1: 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.

Step 2: 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.

Step 3: Materials:

Step 4: Procedure

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 5: Procedure

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 6: Procedure

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!

Step 7: Consideration

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!

Step 8: Source

This article is from: https://www.elecfreaks.com/11214.html

If you have any questions, you can contact: louise@elecfreaks.com.

Comments

About This Instructable

756views

14favorites

License:

Bio: ElecFreaks is an open design house founded in March 2011. Our goal is to create rapid prototypes and give small-batch manufacture solution for makers and ... More »
More by ElecFreaks:Elecfreaks Motor:bit User GuideCreate an Electric Spirit LevelHC-08 Bluetooth UART Communication Module V2.4 User Guide
Add instructable to: