Introduction: Use HC-05 Bluetooth Module to Realize Micro:bit Communication With Mobile Phone
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.
Step 1: 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.
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.
Step 2: Common AT Commands of HC-05
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 :
Step 3: Materials:
Step 4: Procedure
Connect HC-05 to micro:bit breakout board.
Here's the pins' connection:
Connect OLED module to IIC serial port.
Step 5: Procedure
Plug micro:bit into breakout board, connect it to computer with a USB cable. Make sure the voltage switch slided to 5V end.
Open makecode, search and add OLED library.
Initialize OLEDand serial port. You can refer to the parameters in the following picture to do initialization.
Press button A to set Bluetooth name and matching code.
Write receive and send program.
Here's the complete program. You can download the program into micro:bit through the link below.
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 6: Procedure
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.
Install Bluetooh Terminal APP into your mobile. If you don't have this APP, you can click here to download one.
It is for Android mobile phone only. Both HC-05 or HC-06 do not support IOS system.
Open the settings -Bluetooth in your mobile phone, you will see a Bluetooth device called "myhc05".
Click to connect "myhc05" and input PIN code 1234.
Open Bluetooh Terminal in your mobile phone and choose BT (Bluetooth). Click the Bluetooth icon in the right top corner.
Choose "myhc05" and connect it.
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.
Step 7: 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.
- You have to press an Enter behind AT command of HC-05, while you don't have to do so behind AT command of HC-06.
- 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.
Step 8: Relative Readings:
Step 9: Source
This article is from: https://www.elecfreaks.com/11311.html
If you have any questions, you can contact： email@example.com.