Communication connection of HC-05 Bluetooth module

Introduction

The HC-05 Bluetooth module is mainly used in the field of short-distance data wireless transmission. It can be easily connected to a PC Bluetooth device, and can also communicate data between the two modules. Avoid cumbersome cable connections, and can directly replace serial cables. It adopts the British CSR BlueCore4-Ext chip, follows the V2.0+EDR Bluetooth specification, and supports the SPP Bluetooth serial port protocol. Because it has its own master-slave function, it can be connected to each other through serial port commands to transmit data.
Insert picture description here

Ready to work

Prepare two USB to TTL serial boards and two HC-05 Bluetooth modules, connect VCC to 5V, connect GND to GND, and cross-connect TX and RX
Insert picture description here

Two ways to enter AT command mode

1 Before powering on the module (or at the same time), set the KEY pin to high level (or connect to VCC), and then power on the module. At this time, the LED flashes slowly (2S once), and the module enters the AT state. The rate is fixed at 38400.
2 When the module is powered on, set the KEY pin to low level (or connect to GND). At this time, the LED flashes quickly (1S twice), and then set the KEY pin to high level (or connect to VCC). It will also enter the AT command mode, but the LED is still flashing fast, and the baud rate is 9600
as shown in the figure below: Enter the AT command mode
Insert picture description here

AT command setting process

3 : Read the serial port instruction set to query related functions. Below I will list the instructions on how to use the instructions to set the module to become the master and slave mode.
3.1 First, you need to restore the module to the default settings. The instruction is AT+ORGL\r\n, Both Bluetooth modules need to perform this step.
3.2 Set their respective pairing codes, the command is AT+PSWD=XXXX\r\n, I set it to 1234 here
3.3 Then set the module A to host mode The command is AT+ROLE=1\r \n;Set B as slave mode, AT command is AT+ROLE=0\r\n
3.4 Query B address serial debugging assistant B, query Bluetooth B address: AT+ADDR?\r\n (eg: +ADDR :98d3:37:90efca),
3.5 Bluetooth A binds Bluetooth B serial debugging assistant A, Bluetooth A binds Bluetooth B address: AT+BIND=98d3, 37, 90efca\r\n (note that the colon of the address is replaced with a comma ) After the
above steps are completed, you can turn off the power and enter the normal mode.

How to enter normal mode

当以上步骤完成后,就可以断开电源重新给模块上电,此时EN脚置空,上电后两个模块主从机自动匹配连接,然后就可以相互进行通信啦。

Insert picture description here

to sum up

This is the end of the master-slave communication test of the HC-05 Bluetooth module. There are other debugging methods such as transparent transmission of mobile phones. Welcome everyone to
pay attention to and update such articles for a long time. Please leave a message at any time. Leave a message below.

Guess you like

Origin blog.csdn.net/qq_42250136/article/details/107488146