Use Shengrun Bluetooth 4.0BLE module (model CC2541) to realize the communication between two Bluetooth modules
There is a lot of data on the communication between computers and mobile phones and the Bluetooth module, but the communication data between the Bluetooth modules is relatively small. This article takes the CC2541 module as an example to realize the data communication between two Bluetooth modules.
hardware preparation
- 1. One CC2541 master-slave module
- 2. One module of CC2541 slave
Note: Bluetooth modules with almost the same appearance distinguish master and slave. Generally speaking, two Bluetooth devices that are all slaves cannot communicate with each other. Two masters and slaves can also be integrated. In short: there must be a module that can act as a host
Module introduction diagram
Physical map
Made a simple adapter board to lead out vcc, gnd, tx, rx. The filter capacitor is temporarily connected to 100pf.
software preparation
The debugging software uses the official software. TTC transparent transmission module parameter setting V3.4.9.6 Lite
Software and reference documentation package download
- Method 1: Package and download
- Method 2: A cloud link: https://pan.baidu.com/s/1NBp71S-lHyXA4jUvjE68tw Extraction code: 9x7n . If it doesn't work, comment or send a private message.
Implementation steps
Preparation part: Use two usb to ttl to connect the two bluetooth modules of the host and the slave respectively. (Note that tx is connected to rx, don't be wrong)
- 1. Check and configure the same baud rate
- First click on the detection module function
to detect the two Bluetooth modules I connected
(if not detected, please detect the wiring, welding, power supply, etc.)
According to the detected information, open the serial port.
Set the baud rate to 9600 (two software windows can be opened) and
click to set the serial port baud rate. AT+BAUD=0, there may be no reply at this time.
Close the serial port, change it to 9600 and open it again. The communication test is normal, indicating that the baud rate is successfully changed to 9600.
- 2. The host is set to host mode AT+SETUP=81C0002C
host com4 sendAT+SETUP=81C0002C
, set host mode. (The default is to start in slave mode, and this command is required to switch)
(This command is only valid for the master-slave module, single-slave module is invalid.)
Reply AT+OK, indicating that the setting is successful. Restart the host
com4 and set it to host mode. AT+SET=0
com3 is set to slave AT+SET=1
- 3. Connect to the slave machine AT+SCA=START
scan, the following figure finds device 1, AT+NUM=1
connects to the slave machine AT+CON#1
clicks device 1, and receives AT+CON=SUCCESS indicates that the connection is successful
result test
Send 123, can receive. Indicates that the communication between the two Bluetooth modules is successful.
Instruction Statistics:
instruction | normal reply |
---|---|
AT+SOFT_RST=1 | Soft reset none |
AT+ADV=0 | AT+OK closes the broadcast |
AT+ADV=1 | AT+OK to turn on the broadcast |
AT+SET=1 | AT+OK set slave |
AT+SET=0 | AT+OK set host |
AT+SCA=START | AT+OK AT+NUM=1 to start scanning |
AT+LIST_NUM=? | 1 Get the list |
AT+CON#1 | AT+CON=OK Connection succeeded |
AT+DISCON | AT+OK closes the broadcast and disconnects the current connection |