当前位置:网站首页>Bluetooth hc-05 pairing process and precautions

Bluetooth hc-05 pairing process and precautions

2022-07-05 08:00:00 Drink more hot water-

bluetooth HC-05 Pairing process and precautions

such MCU The Bluetooth module used has been integrated , One module is the host , A slave , Send directly through serial port after pairing , The other end of the serial port can receive , Equivalent to one Wireless serial port , It's often said that it's transparent , It's quite simple

【5 I played it years ago Come back and write notes I'm really old 】

To use AT command , The first thing to know is HC-05 Baud rate , And then get into AT Command mode .
Three elements must be known when using serial port , One is baud rate , Second, serial port number , Third, data format ,
HC-05 Only one data format is supported : Data bits 8 position , Stop bit 1 position , No parity bit , No flow control

BOM:
2 individual HC-05, One or 2 A serial port module

Get into AT There are two ways to command :

1, Press and hold the key or EN Pull your feet up , At this time, the light flashes slowly ,SPP-05 Get into AT Command mode , The default baud rate is 38400;
This pattern is called primitive pattern . The original mode has been in AT Command mode status .
2,HC-05 Power on boot , The red light flashes , Press and hold the key or EN pull up ,HC-05 Get into AT Command mode , Default baud rate
yes 9600; This mode is called normal mode . In normal mode, only press and hold the key or pull it up EN Just in AT Command mode status .
Be careful : If the baud rate is not the correct device ,AT The command is invalid .

Because the master side needs to bind the slave , So first get the slave addr :
be-all AT Instructions , Remember to add enter

AT+ORGL
AT+PSWD="1234"
AT+ROLE=0
AT+ADDR?
AT+UART=9600,0,0
AT+UART?
AT+CMODE=0

The host AT Command list , Also add the carriage return
【 After obtaining the address of the slave , Assigned to the host AT+MIND Used as binding 】, But the address should be " : " Switch to " , "

AT+ORGL
AT+ROLE=1
AT+PSWD="1234"
AT+BIND=0021,04,083DB9
AT+UART=9600,0,0
AT+CMODE=0

Problems encountered
After plugging in , The Bluetooth light flashes slowly , Description enter the original mode , Direct use 38400 Baud rate can be configured

however , perform AT+ORGL after , Or after power on , Bluetooth is flashing , Represents that Bluetooth is in normal mode ,
It's the same thing at this time , send out AT Instructions cannot be accepted , This is because : Flash down to enter AT Pattern , Must be raised EN Or press and hold the key , To enter AT Command mode , At this time, the serial port should be changed to 9600 Hold down EN Can only be AT To configure

All in all :

want AT When it comes to configuration , Slow flashing light , Just use 38400 Baud rate , that will do AT Command pairing
Flash lamp , Just press and hold the button , use 9600 Baud rate of AT Command can

Anyway, how does the goddess' heart beat , We'll just jump along
“------------------------------------------------------------------------------------------------------”

After that, you can send and receive in both directions

The last attached HC-05 Of AT Instructions reference

1,AT+ROLE Set master-slave mode : AT+ROLE? Is to query the master-slave status ;AT+ROLE=1 Is set as the master ,AT+ROLE=0
Is set to start from ,AT+ROLE=2 Set it as a loopback role (Slave-Loop( Loopback character )—— Passive connection , Receive far
Process the Bluetooth master device data and return the data to the remote Bluetooth as it is ). 2,AT+RESET:HC-05 Reset
3,AT+VERSION?: obtain HC-05 Software version number of , Can only get , Do not modify .
4,AT+ORGL: Restore factory default settings , When the module is set disorderly , Use this command to restore the default values .
5,AT+ADDR?: obtain HC-05 Bluetooth address code , Can only get , Do not modify .
6,AT+NAME?: obtain HC-05 Name ,AT+NAME=BSP-06, Change the name of the module to BSP-06, Specifically
The name changes itself .
7,AT+CLASS?: Set the type of query device , Try not to modify this parameter . The default is 1F00. 8,AT+IAC?: Query setting query access code , The default is 9E8B33, Try not to modify this parameter .
9,AT+PSWD?: Query and set the pairing password ,AT+PSWD=”0000”, The password should have double quotation marks , The password is four digits .
10, AT+UART:AT+UART? Is to query the baud rate of the current module ,AT+UART= Baud rate is set .
11, AT+CMODE:AT+CMODE? Is to query the current connection mode .AT+CMODE=0,1,2(0—— finger
Set the Bluetooth address connection mode ( The specified Bluetooth address is set by the binding instruction )1—— Any Bluetooth address connection mode
type ( Not bound by the address set by the binding instruction )2—— Loopback character (Slave-Loop) Default connection mode :
0).
12, AT+BIND:AT+BIND? Query the current binding address ,AT+BIND=NAP,UAP,LAP( Separated by commas ).
13, AT+RMADD: Delete all certified devices from the Bluetooth pairing list .
14, AT+STATE?: Get the working status of Bluetooth module .
15, AT+LINK=NAP,UAP,LAP: Establish a connection with the remote device .
16, AT+DISC: disconnect .
17, AT+RNAME?NAP,UAP,LAP: Get the name of the remote Bluetooth device .
18, AT+ADCN?: Get the number of certified devices in the Bluetooth pairing list .
19, AT+MRAD? Get the recently used Bluetooth authentication device address .
20, AT+INQM: Set query mode ,AT+INQM=1,9,48(1- belt RSSI Signal strength indication ,9- exceed 9 individual
The Bluetooth device responds and terminates the query ,48- Set the timeout to 48*1.28=61.44 second )

原网站

版权声明
本文为[Drink more hot water-]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140547485841.html