Intro: 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
Connect HC06 module to micro:bit breakout board.
Here's the connection of HC06 and micro:bit breakout board:
STATE and KEY do npt connect.
Step 5: Procedure
Connect OLED module to IIC serial port.
Plug your micro:bit into breakout board, and connect it to your computer with a USB cable.
Open makecode, search for OLED library and add it.
Initialize OLED and serial port. You can refer to the parameters in the following pictures to do initialization.
When button A is pressed, it will set the name of Bluetooth and matching code.
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
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.
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.
Open your Bluetooth in your mobile setting, you will see "myhc06" Bluetooth device.
Click to connect "myhc06" and input PIN code 1234.
Open Bluetooth Terminal on your mobile, choose BT (Bluetooth), and then click the Bluetooth icon in the right top corner.
Choose "myhc06" and connect it.
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： firstname.lastname@example.org.