当前位置:网站首页>Hc-05 Bluetooth module debugging slave mode and master mode experience
Hc-05 Bluetooth module debugging slave mode and master mode experience
2022-07-28 12:41:00 【yi_ tianchou】
HC-05 Bluetooth module debugging slave mode and master mode experience
The boards obtained are as follows , I want to realize that Bluetooth module can be used as master station or slave station ,

I have no previous experience in Bluetooth debugging ( A little white ), Get it from the manufacturer AT Instructions and Bluetooth test software .exe, With a vacant face , What is all this , Read it over and over again AT Instruction set , The meaning of each instruction is clear , But I don't know the sending order of each instruction , I don't know which instructions should be called in main mode , What should be called from the mode , Although very confused , But be positive , If it's not good, I still have Du Niang , Begin your search .............
First page , Too deep , Do not understand
Second page , Still in the clouds
Third page , Know how to connect
.......
The first n Pages , Take care of my little white , Write clearly step by step hand , Although it is just a simple slave configuration and connection , It is also a step closer to success . Try it first ,
10 Minutes later, according to the configuration of the web page , Set up the success , Both mobile phones and computers can search for Bluetooth modules , Excited , The first step of the long march has been completed , The rest is more troublesome , I not only want to realize the slave station , Also realize the master station , Search again ,99% All of them are similar helloworld Of , Only the configuration of the slave , There are few main stations or according to mac Address bound , Not what I want , Lost again .
Calm down and analyze , Online things are also written according to official documents , Only by growing your own food can you have endless dishes , To analyze AT Instruction set , Try bit by bit
In half an hour , At last , You can send data to the Bluetooth module through the serial port tool , Connect to Bluetooth printer , Print out the data , Both Chinese and English are ok .
Think about your debugging experience , It also refers to a lot of materials , Now I decide to sort it out for the reference of friends who need it .
Don't spray
Using tools :TTL turn usb modular
Serial assistant uses sscom3.2
Wiring way : Bluetooth and USB Connection mode of serial port module ,RXD-TX TXD-RX VCC-VCC GND-GND
The default parameters of the module are as follows :

test AT Instructions :
1、 How to access Bluetooth AT Pattern :HC-05 You need to press and hold the button in the upper left corner of the module , And then power on , Let a pin go through the process of turning a high-level platform into a low-level , You can enter AT Instruction setting mode . At the same time, pay attention to the actual HC05 In the process of purchase , Some businesses will directly put some HC-05 Sold as a slave , So some HC05 The module has no welding button , So we can weld the buttons by ourselves , Or use conductive objects ( DuPont line 、 Tweezers ), Set that pin high . about HC05 Come on , The flash of the module indicator indicates that Bluetooth is not connected , Slow flashing indicates entering AT Pattern , Double flashing indicates that Bluetooth is connected and the port is opened .
Ps: If the board is like the board I bought , You can also enter AT Pattern , Press the button on the Bluetooth module to enter AT Pattern , Release and enter the communication mode .
2、 Turn on the serial assistant , Select the correct port number .
3、 Set up AT It needs to be set under the fixed initial baud rate specified by the module (HC05 by 38400), Some Bluetooth modules need to be carried out at the baud rate you set last AT Sending instructions .
4、 Some modules are sending AT When the command , It needs to be written in the sending area AT Add carriage return after the instruction "\r\n", At the same time, pay attention to case sensitivity .
5、 What are the details AT Instructions and their meanings need to refer to the 《AT Instruction set 》
Slave configuration :
Press key Then power on the Bluetooth module , The computer software is set
The setting is as shown in the figure :

If sent AT There was no response after the order , Press new key Access to electricity .
The computer can be installed BluetoothView.exe It is convenient to check whether the Bluetooth module is working .

Instruction, ( You can refer to AT The instruction set is very detailed ):
AT: Test instruction , return OK Indicates that the communication is successful
AT+PSWD=1234: Set up Bluetooth pairing password
AT+PSWD?: Query whether the setting is successful
AT+NAME=Bluetooth-Slave : Set the Bluetooth display name , It can be set arbitrarily, but it cannot exceed 20 character
AT+ROLE=0: Set the Bluetooth module as a slave ,

AT+UART=38400,0,0 Set the baud rate of Bluetooth in working mode , And modules in AT Baud rate in mode is two different things . It is recommended to set the same during debugging , In this way, there is no need to frequently switch the baud rate of the serial port tool .

Set the configuration information of the master station
Pictured

1、 Detailed explanation of main instructions
AT+ROLE=1
AT+CMODE=0/1 ( I used it for the test 0 Is connected before , It is recommended to use 1)
AT+CMODE=0 Need to cooperate with AT+bind Use it together

AT+INIT initialization SPP Specification Library , As the master station, it must be initialized once , Otherwise, in the perform at+inqm=1,10,15 and at+inq Or return error(16) mean spp Library not initialized .
AT+pair and AT+link It's pairing and connecting
here The master-slave pairing has been completed, and the Bluetooth module is also slave AT The mode is switched to normal mode even if you press key Button (pio10 For the high )
If you want to disconnect Need to press again key Button , send out AT+DISC.
Add two instructions :
AT+CLASS=0 I use the default , The usage scenario of Bluetooth module represented by this instruction , See instruction set for details , through AT+class Modify the device class of the module , in other words If the module is modified to 0x1f1f, Then the main module can only search class by 0x1f1f From the station
AT+iac

AT+iac The default is 0x9e8b33, This code is a general access code , It can be changed to any value ,
The main function is filtering , The master station can only query the same as itself iac Yard slave station .
边栏推荐
- 揭秘界面控件DevExpress WinForms为何弃用受关注的MaskBox属性
- HMS core audio editing service supports 7 kinds of audio effects to help one-stop audio processing
- 公司在什么情况下可以开除员工
- 用C语言开发NES游戏(CC65)08、背景 碰撞
- SQL injection less24 (secondary injection)
- Unity加载Glb模型
- JSP自定义标签之自定义分页标签02
- leetcode:数组
- Solve the PHP prompt warning: division by zero in error
- 聚变云原生,赋能新里程 | 2022 开放原子全球开源峰会云原生分论坛圆满召开
猜你喜欢

Open source huizhichuang future | 2022 open atom global open source summit openatom openeuler sub forum was successfully held

Exploration on cache design optimization of community like business

FlexPro软件:生产、研究和开发中的测量数据分析

New progress in the implementation of the industry | the openatom openharmony sub forum of the 2022 open atom global open source summit was successfully held

Marketing play is changeable, and understanding the rules is the key!

图书馆自动预约脚本

Design a thread pool

MMA8452Q几种模式的初始化实例

Developing NES games with C language (cc65) 08. Background collision

Not optimistic about Apple making AR, Luo Yonghao: I'll do it myself
随机推荐
Analysis of new retail e-commerce o2o model
With the continuous waves of infringement, the U.S. patent and trademark office began to study the impact of NFT on copyright
新东方单季营收5.24亿美元同比降56.8% 学习中心减少925间
03 pyechars 直角坐标系图表(示例代码+效果图)
Developing NES games with C language (cc65) 06. Sprites
与元素类型 “item” 相关联的 “name” 属性值不能包含'<” 字符解决办法
HC-05蓝牙模块调试从模式和主模式经历
用C语言开发NES游戏(CC65)05、调色板
Redis实现分布式锁
Developing NES games with C language (cc65) 11. Metatiles
金九银十 再不卷就来不及了
Knowledge points of MySQL (13)
How to realize more multimedia functions through the ffmpeg library and NaPi mechanism integrated in openharmony system?
界面控件Telerik UI for WPF - 如何使用RadSpreadsheet记录或评论
Multi Chain and multi currency wallet system development cross chain technology
Unity 安装 Device Simulator
stm32 回环结构接收串口数据并处理
图书馆自动预约脚本
恋爱男女十禁
Developing NES games with C language (cc65) 02. What is v-blank?