In chapter Use HC-06 Bluetooth Module to Realize Micro:bit Communication With Mobile Phone, we have talked about how to use HC-06 to realize communication between micro:bit and mobile phone. Except for HC-06, there is another common Bluetooth module, HC-05. Their usages might have a little difference. Today, we are going to talk about how to use HC-05 to make micro:bit communicate with your mobile phone.
Two Methods for HC-05 Entering AT Mode
1. When the module is charged and unmatched, it is AT mode. The baud rate is the module’s oringinal baud rate, which is defaulted to be 9600. Before matching, the indicator of the module will swiftly flash for about 3 times per second.
2.Set high voltage to KEY and charge the module, then it will enter into AT mode and the baud rate is fixed to be 38400. You can send AT command directly. Before matching, the module indicator blinks slowly with 2-second interval between on and off.
Note: We usually use the first method. When you forget the baud rate of the module, you can use the second mode to enter into AT mode. Normally, we would like to suggest you to choose the first method to enter AT mode.
Common AT Commands of HC-05
Note:
1. HC- is a kind of master-slave integratedBluetooth serial port module.Under the defaulted situation, usually it is slave mode.
2. The AT commands of HC-05 shall be pressed an Enter behind. The relative
blocks in makecode is :
Materials:
1 x BBC Micro:bit Board
1 x ElecFreaks Micro:bit Breakout Board
1 x Bluetooth Modem HC-05
1 x IIC OLED Module
Procedure
Step 1: Connect HC-05 to micro:bit breakout board. Here’s the pins’ connection: GND-G VCC-VC RXD-TX TXD-RX KEY-VCC STATE none
Step 2: Connect OLED module to IIC serial port.
Step 3: Plug micro:bit into breakout board, connect it to computer with a USB cable. Make sure the voltage switch slided to 5V end.
Step 4: Open makecode, search and add OLED library.
Step 5: Initialize OLEDand serial port. You can refer to the parameters in the following picture to do initialization.
Step 6: Press button A to set Bluetooth name and matching code.
Step 7: Write receive and send program.
Here’s the complete program. You can download the program into micro:bit through the link below.
Step 9: Press button A, you can see 4 consecutive OK displayed on the OLED screen. If it is not, please restart your micro:bit and press button A again.
Step 10: To this step, we have already reset the Bluetooth name to be “myhc05” and PIN matching code to be “1234”. Plug out KEY cable from VCC and make its pin stay unconnected. Next, discharge the system, the indicator on HC-05 module will be turned to fast flash from slow flash.
Step 11: Install Bluetooh Terminal APP into your mobile. If you don’t have this APP, you can click here to download one. Note: It is for Android mobile phone only. Both HC-05 or HC-06 do not support IOS system.
Step 12 Open the settings -Bluetooth in your mobile phone, you will see a Bluetooth device called “myhc05”.
Step 13 Click to connect “myhc05” and input PIN code 1234.
Step 14 Open Bluetooh Terminal in your mobile phone and choose BT (Bluetooth). Click the Bluetooth icon in the right top corner.
Step 15 Choose “myhc05” and connect it.
Step 16 Ok. Till this step, all mobile settings are completed. Try to send messages to your micro:bit board with your mobile phone. You will see the messages you sent appeared on the OLED screen. Press button B on micro:bit, then you will see messages from micro:bit displayed on your mobile phone.
Conclusion There might be a little bit difference between HC-05 and HC06 in usage. Here I have made a conclusion for you :
-
They have different methods to enter AT commands. Before charged, HC-06 has entered AT mode. While HC-06 has two methods to enter AT mode: one is to enter directly after being charged, the other is to connect high voltage to KEY so that it can enter AT mode with fixed baud rate.
-
The AT command expressions of HC-05 and HC-06 have some difference. For more details, you can check the columns in the articles.
-
HC-05 can be setted to a master machine. As for how to use its master machine mode, we will tell you in the following chapters.
Relative Readings:
Use HC-06 Bluetooth Module to Realize Micro:bit Communication With Mobile Phone