Dual-mode Bluetooth

From Waveshare Wiki
Jump to: navigation, search
Dual-mode Bluetooth
to TTL serial
Dual-mode Bluetooth

Dual-mode Bluetooth to TTL serial, master/slave-in-one
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

Primary Attribute
Category: Modules, Bluetooth
{{{userDefinedInfo}}}: {{{userdefinedvalue}}}
Brand: Waveshare
Website
English: Website
Chinese: 官网
Onboard Interfaces
Bluetooth XBee UART
Related Products

Introduction

Dual-mode Bluetooth to TTL serial, master/slave-in-one

More

Features

  • Dual-mode Bluetooth, completely compatible with iOS and/or Android devices
  • Works as a full-duplex serial pipe after pairing, requires no Bluetooth protocol knowledge
  • Fully configurable via AT commands
  • XBee interface
  • Comes with iOS and Android demo code, like: mobile robot remote control, data acquisition, device status monitoring, etc.

Unpacking and checking

Before powering on and testing the module, please read the section Unpacking and checking carefully, so as not to damage the module in operation.

Dual-mode Bluetooth is an easy-to-use Bluetooth serial transmission module. User can apply it without knowing any details of Bluetooth protocol, and take it as a full duplex serial port.

Since dual-mode Bluetooth uses TTL level. A RS232 to UART module or USB to UART module is required. Here, we recommends using XBee USB Adapter to connect with your PC for testing.

XBee USB Adapter is a USB to UART module with XBee interface, keys, LEDs and standard 2.54mm pitch pin headers. When working with Dual-mode Bluetooth, you just need to connect the Dual-mode Bluetooth to the XBee (please make sure they are in a correct connection), and connect the Xbee USB Adapter to your PC with a micro USB cable. Here is the hardware connection diagram:

Dual-mode-Bluetooth-User-Manual01.png

Of course, you can use an USB to UART module for testing as well, such as FT232 USB UART Board (micro). Since the pitch of Dual-mode Bluetooth is 2.0mm, you should use a 2.0 to 2.54 conversion cable for the testing.

Here is the hardware connection diagram:

Dual-mode-Bluetooth-User-Manual02.png

After checking the connection described above, you can connect the module to your PC. If you have not installed the USB to UART driver on your PC, you may need to install one. Here we provide some divers, you can choose one of them as you need. (In case of using other USB to UART module, please install the corresponding USB to serial driver):

Open the device manager, to see the corresponding COM.

Scan the QR code below and download the relative APPs to your phone. iOS (iPhone4S or later) builds communication to the module using Bluetooth BLE and Android builds communication to the module using Bluetooth EDR.

Bluetooth ios wsble.pngBluetooth android wsedr.png

Start up the APP, and click the icon "Scan" (Notice: Please turn on the Bluetooth on your mobile phone). After a few seconds, you may see the corresponding Bluetooth device displayed on the list normally. For iOS, please select the option "Waveshare_BLE" device; for Android, please select the option "Waveshare_EDR" device. And then, go to the next page and select the option "UART".

Dual-mode-Bluetooth-User-Manual03.png Dual-mode-Bluetooth-User-Manual04.png

Notices: If the Android mobile phone supports Bluetooth BLE as well, it can scan two Bluetooth devices. In this case, select the device with the MAC address of 00:0E:0E.

Dual-mode-Bluetooth-User-Manual07.png

When you send data to the Dual-mode Bluetooth via the File:Putty.zip on your PC, your mobile phone can receive the data your sent. And the serial debugging software can display the data sent from your mobile phone.

Notice: The factory setting of Dual-mode Bluetooth is baud rate: 115200, parity bit: N, data bit: 8 bits, stop bit: 1 bit. The parameters of Dual-mode Bluetooth, such as baud rate, can be modified by AT command (see below). However, when the module serves as a slave to communicate with mobile phone, such modifications are not recommended and may cause communication fail between the APP and the Dual-mode Bluetooth.

See the figures below:

Dual-mode-Bluetooth-User-Manual06.png

Serial debugging software will receive:

WaveshareWaveshareWaveshareWaveshareWaveshareWaveshare

Functions of Dual-mode Bluetooth

Common used AT command

Open File:Putty.zip and set as: baud --> 115200, data bits --> 8, stop bits --> 1, Parity --> None (If you have modified the serial configuration of the module, you should set the serial software accordingly). Then, Send out the uppercase letters "AT" ( which should not be followed by any character, such as \r\n and the likes. Some of the serial software may has the checkbox "send a new line". Don’t check that.), then returns "OK" if the hardware is in correct connection and the module works properly.


In normal mode, you can configure the Dual-mode Bluetooth by AT command when the Bluetooth connection is not established or disconnect (If the module is in the connected state, you should disconnect the Bluetooth connection before using the AT command.)


  • Test or disconnection commands
Command Answering Parameter
AT OK\ER\disconnect None

When the module is in the standby state, it will return :"OK".

When the module is in the error state, it will return :"ER", informing that the Bluetooth chip works improperly and needs to be restarted or reset the parameters.

When the module is in the Bluetooth connection, sending out the command :"AT" from the serial interface of the module can break the connection.


  • Reset command
Command Answering Parameter
AT+RESET OK+RESET None

After executed this command, the module may take 3 seconds to restart after a delay of 500ms.


  • Query the EDR mode MAC address
Command Answering Parameter
AT+ADDE? OK+Get:MAC address None


  • Query the BLE mode MAC address
Command Answering Parameter
AT+ADDB? OK+Get: MAC address None


  • Query the remote host address that the EDR once linked to
Command Answering Parameter
AT+RADE? OK+Get: MAC address None


  • Query the remote Master address that the BLE once linked to
Command Answering Parameter
AT+RADB? OK+Get: MAC address None


  • Clear the address information of the latest connection
Command Answering Remarks
AT+CLEAE OK+CLEAE clear the EDR connection information
AT+CLEAB OK+CLEAB clear the BLE connection information

  • Query\set the initialization message of the module
Command Answering Parameter
Query:AT+INIT? OK+Get:[P1] P1:0 or1(Default setting: 0)
  • 0: Do not send out initialization message
  • 1: Send out initialization message
Set :AT+INIT[P1] OK+Set:[P1]

If the initialization message function is enabled, the module will send out the string "OK+INIT" after the initialization finished.

Note: After executed the command, you should power up the module again, to enable the new setting to take effect.


  • Query\set the EDR working mode
Command Answering Parameter
Query:AT+IMME? OK+Get:[P1] P1:0 or 1(Default setting: 0)
  • 0: Work automatically
  • 1: Work when the command comes after powered up.
Set :AT+IMME[P1] OK+Set:[P1]

Note: After executed the command, you should power up the module again, to enable the new setting to take effect.


  • Query\Set the BLE working mode
Command Answering Parameter
Query:AT+IMMB? OK+Get:[P1] P1:0 or 1(Default setting: 0)
  • 0: Work automatically
  • 1: Work when the command comes after powered up.
Set :AT+IMMB[P1] OK+Set:[P1]

Note: After executed the command, you should power up the module again, to enable the new setting to take effect.


  • Set the start working command of EDR mode
Command Answering Parameter
AT+STARE OK+STARE None


  • Set the stop working command of EDR mode
Command Answering Parameter
AT+STOPE OK+STOPE None


  • Set the start working command of BLE mode
Command Answering Parameter
AT+STARB OK+STARB None


  • Set the stop working command of BLE mode
Command Answering Parameter
AT+STOPB OK+STOPB None

If you have make the setting with AT+IMME1, the module under EDR mode will not work until it receives the command AT+STARE. When receiving the command AT+STOPE, the module under EDR mode stops working.

If you have make the setting with AT+IMMB1, the module under BLE mode will not work until it receives the command AT+STARB. When receiving the command AT+STOPB, the module under BLE mode stops working.

Set the broadcasting name

  • Query\Set the EDR device name
Command Answering Parameter
Query:AT+NAME? OK+Get:[P1] P1: device name
  • The device name is recommended to use the 11 digits or letters, hyphens and underscore included. Other characters are not recommended.
Set :AT+NAME[P1] OK+Set:[P1]


  • Query\Set BLE device name
Command Answering Parameter
Query:AT+NAMB? OK+Get:[P1] P1: device name
  • The device name is recommended to use the 11 digits or letters, strike and dash included. Other characters are not recommended.
Set :AT+NAMB[P1] OK+Set:[P1]

For example:

Command to be sent out Answering Remarks
AT OK testing command, for judging whether the AT commands can be used for configuration.
AT+NAMB? OK+Get: current BLE device name Query BLE device name
AT+NAMBtestBLE OK+Set:testBLE Set the device name of BLE to "testBLE"
AT+NAME? OK+Get: current EDR device name Query EDR device name
AT+NAMEtestEDR OK+Set:testEDR Set the device name of EDR to "testEDR"
AT+RESET OK+RESET Reset the module or power up the module again

Executing the AT commands listed above in sequence, the module will reset. Then, apply the APP on your mobile phone to scan the Bluetooth device again. You can find that the scanned device name has been changed.

Configure iBeacon

For iBeacon, the default setting of UUID is :74288BDA-B644-4520-8F0C-720EAF059935. And the device will not send out iBeacon broadcasting packet under the master mode.

  • Query\Set iBeacon On-Off
Command Answering Parameter
Query:AT+IBEA? OK+Get:[P1] P1:0 or 1(Default setting: 0)
  • 0: Turn off iBeacon
  • 1: Turn on iBeacon
Set:AT+IBEA[P1] OK+Set:[P1]

Note: After executed the command, you should power up the module again, to enable the new setting to take effect.


  • Query\Set iBeacon UUID value
Command Answering Parameter
Query:AT+IBE0? OK+Get:[P1] P1:00000001~FFFFFFFE
  • (Default setting: 74278BDA)
Set:AT+IBE0[P1] OK+Set:[P1]

iBeacon UUID: 74288BDA-B644-4520-8F0C-720EAF059935

This command can modify the red word section in the UUID.


  • Query\Set iBeacon UUID vaule
Command Answering Parameter
Query:AT+IBE1? OK+Get:[P1] P1:00000001~FFFFFFFE
  • (Default setting: B6444520)
Set:AT+IBE1[P1] OK+Set:[P1]

iBeacon UUID: 74288BDA-B644-4520-8F0C-720EAF059935

This command can modify the green word section in the UUID.

  • Query\ Set iBeacon UUID value
Command Answering Parameter
Query:AT+IBE2? OK+Get:[P1] P1:00000001~FFFFFFFE
  • (Default setting : 8F0C720E)
Set :AT+IBE2[P1] OK+Set:[P1]

iBeacon UUID: 74288BDA-B644-4520-8F0C-720EAF059935

This command can modify the blue word section in the UUID.

  • Query\Set iBeacon UUID value
Command Answering Parameter
Query:AT+IBE3? OK+Get:[P1] P1:00000001~FFFFFFFE
  • (Default setting: AF059935)
Set:AT+IBE3[P1] OK+Set:[P1]

iBeacon UUID: 74288BDA-B644-4520-8F0C-720EAF059935

This command can modify the purple word section in the UUID.

  • Query\Set iBeacon Major value
Command Answering Parameter
Query:AT+MAJO? OK+Get:[P1] P1:0001~FFFE
  • (Default setting: 0001)
Set:AT+MAJO[P1] OK+Set:[P1]


  • Query\Set iBeacon Minor value
Command Answering Parameter
Query:AT+MINO? OK+Get:[P1] P1:0001~FFFE
  • (Default setting: 0001)
Set:AT+MINO[P1] OK+Set:[P1]


For example:

1. To perform iBeacon configuration, you need to install the testing software to your mobile phone firstly. Here, we will take the iOS system as an example to illustrate the testing. And the similar configuration can be applied to Android system.

Search the Locate in App Store, and install it to your mobile phone, as the figure shows below:

Dual-mode-Bluetooth-User-Manual09.png

2.Open the Locate in App, and configure the access permission (Note: you should configure the access permission before using this App).

3.Now, the configuration of your mobile phone is finished. You should configure the device by send the following command via serial port:

Command to be sent out Answering Remarks
AT OK testing command, for judging whether the AT commands can be used for configuration.
AT+IBEA1 OK+Set:1 Open iBeacon
AT+MAJO1234 OK+Set:1234 configure iBeacon Major
AT+MINO4567 OK+Set:4567 configure iBeacon MINO
AT+RESET OK+RESET Reset the module or power up the module again

After the module reset, you can scan the following information as the figure shows below:

Dual-mode-Bluetooth-User-Manual10.png

Note: The "1234" and "4567" in Hex are the equivalents to "4660" and "17767" in Dec., respectively.

In which, 74288BDA-B644-4520-8F0C-720EAF059935 consist of the UUID by default. You can modify the setting by the commands listed below.

1. Modify the red section: AT+IBE001234567

2. Modify the green section: AT+IBE18901ABCD

3. Modify the blue section: AT+IBE2EFEF0123

4. Modify the purple section: AT+IBE3456789AB

5. Power up the module again or execute the command "AT+RESET"

After the modification, the module will perform broadcasting according to the new UUID. You should customize the UUID setting in the Locate to the same one of the module, so that you can view your device in the Locate. Here is the setting in the Locate.

Dual-mode-Bluetooth-User-Manual11.png

Here is the result:

Dual-mode-Bluetooth-User-Manual12.png

Set the three-way mode

The three-way mode need to use the commands "AT+ATOB" and "AT+DUAL". When you establish Bluetooth connections under EDR mode and BLE mode at a same time and enable the three-way mode, the data from the device A to the module will be transmitted to the device B as well. Also, the device A can receive the data that is sent from the device B to the module.

Dual-mode-Bluetooth-User-Manual13.png

  • Query\Set the three-way mode of the module
Command Answering Parameter
Query:AT+ATOB? OK+ Get:[P1] P1: 0 or 1(Default setting :0)
  • 0: Disable three-way mode
  • 1: Enable three-way mode
Set:AT+ATOB[P1] OK+ Set:[P1]


  • Set the module connection mode
Command Answering Parameter
Query:AT+DUAL? OK+Get:[P1] P1:0 or 1(Default setting: 1)
  • 0: Dual-mode standby, and two modes can receive and transmit data at a same time.
  • 1: Dual-mode standby, but one mode can receive and transmit data.
Set:AT+DUAL[P1] OK+Set:[P1]

For example:

Command to be sent out Answering Remarks
AT OK testing command, for judging whether the AT commands can be used for configuration.
AT+DUAL0 OK+Set:0 Dual-mode standby, and two modes can receive and transmit data at a same time.
AT+ATOB1 OK+Set:1 Enable three-way mode
AT+RESET OK+RESET Reset the module or power up the module again

IO control

  • Query\Set the output state of LED(PIO1)
Command Answering Parameter
Query:AT+PIO1? OK+Get:[P1] P1:0 or 1(Default setting: 0)
  • 0: The LED is flickering slowly when module is on standby, and always lighting up when connection is established.
  • 1: The LED is Off when module is on standby, and always lighting up when connection is established.
Set:AT+PIO1[P1] OK+Set:[P1]


  • Query\Set the PIO state
Command Answering Parameter
Query:AT+PIO[P1]? OK+Get:[P2] P1: 2\3\4\5\8\9\A\B

P2: 0,1,?

  • 0: Output LOW level
  • 1: Output HIGH level
  • ?: Query the state
Set:AT+PIO[P1][P2] OK+Set:[P2]

For example:

If you only query the output state of a PIO, please use the command "AT+PIO2?" or "AT+PIO3?".

Set the output state of PIO2: "AT+PIO2X", in which the value of X can be 0 or 1, 0 for Low level, and 1 for High level.

For example, when sending out the command "AT+PIO21", you will get "OK+Set:1", which indicates that the PIO2 is in High level output.

If you use XBee USB Adapter for testing, the connection between the Dual-mode Bluetooth and the XBee USB Adapter is as follows:

Dual-mode Bluetooth XBee USB Adapter
LED(PIO1) LED1
PIO5 LED2

The following figure shows the corresponding IOs:

Dual-mode-Bluetooth-User-Manual14.png

Set the parameters of the serial port

Again, we do not recommend user to modify the parameter of the serial port, even though Dual-mode Bluetooth allow user to do it. (The default setting is in most common use).

  • Query\Set the Baud rate of the module
Command Answering Parameter
Query:AT+BAUD? OK+Get:[P1] P1:1~7(Default setting: 6)
  • 1=4800
  • 2=9600
  • 3=19200
  • 4=38400
  • 5=57600
  • 6=115200
  • 7=230400
Set:AT+BAUD[P1] OK+Set:[P1]

Here is an example. Set the Baud rate to 9600:

Send: AT+BAUD2

Return: OK+Set:2

Note: After executed the command to set the baud rate, you should power up the module again, to enable the new setting to take effect.


  • Query\Set the serial port parity setting
Command Answering Parameter
Query:AT+PARI? OK+Get:[P1] P1:0~2(Default setting: 0)
  • 0: No parity
  • 1: EVEN
  • 2: ODD
Set:AT+PARI[P1] OK+Set:[P1]

Note: After executed the command, you should power up the module again, to enable the new setting to take effect.


  • Query\Set stop bit
Command Answering Parameter
Query:AT+STOP? OK+Get:[P1] P1: 0 or 1(Default setting: 0)
  • 0: 1 stop bit
  • 1: 2 stop bits
Set:AT+STOP[P1] OK+Set:[P1]

Note: After executed the command, you should power up the module again, to enable the new setting to take effect.


  • Query\Set hardware flow
Command Answering Parameter
Query :AT+FLOW? OK+Get:[P1] P1:0 or 1(Default setting: 0)
  • 0: OFF
  • 1: ON
Set:AT+FLOW[P1] OK+Set:[P1]

Note: After executed the command, you should power up the module again, to enable the new setting to take effect.

Mater mode or Slave mode

To extent the communication range, two Dual-mode Bluetooth modules may work together and perform full-duplex communication, in which one of them will be under Master mode and the other will be under Slave mode.

In the testing, you need two Dual-mode Bluetooth module. One of them should be set to Master mode, and the other one remain at Slave mode. Then, turn off other Bluetooth devices surrounding. The Dual-mode Bluetooth module under Master mode will search and link to the Dual-mode Bluetooth module under Slave mode.

Query\Set EDR to Master or Slave mode

Command Answering Parameter
Query:AT+ROLE? OK+Get:[P1] P1: 0 or 1(Default setting: 0)
  • 0: Slave mode
  • 1: Master mode
Set:AT+ROLE[P1] OK+Set:[P1]

Note: After executed the command, you should power up the module again, to enable the new setting to take effect.


Query\Set BLE to Master or Slave mode

Command Answering Parameter
Query:AT+ROLB? OK+Get:[P1] P1: 0 or 1(Default setting: 0)
  • 0: Slave mode
  • 1: Master mode
Set:AT+ROLB[P1] OK+Set:[P1]

Note: After executed the command, you should power up the module again, to enable the new setting to take effect.


The commands "AT+ROLE1" and "AT+ROLB1" can not be applied at a same time. Either BLE device or EDR device is supported to be the Master device. But they can not be the Master at a same time. Normally, the command "AT+ROLE1" is recommended.

Other AT commands

  • Set the module working mode
Command Answering Parameter
Query:AT+MODE? OK+Get:[P1] P1: 0 or 1(Default:0)
  • 0: Transparent mode
  • 1: Transparent + Remote Control mode
Set:AT+MODE[P1] OK+Set:[P1]

This command is used for switching between Transparent mode and Remote Control mode.

In remote control mode, you can query and set the Bluetooth module by sending AT command to the relative device.

For example:

Command to be sent out Answering Remarks
AT OK testing command, for judging whether the AT commands can be used for configuration.
AT+MODE1 OK+Set:1 Set Transparent mode+ Remote Control mode

Sending out the AT command "AT+PIO51" or "AT+PIO50" via the APP on your mobile phone, you can control the ON and OFF of the LED2 on you r XBee USB Adapter board.


  • Set whether inform the connection state to upper machine
Command Answering Parameter
Query:AT+NOTI? OK+Get:[P1] P1:0 or 1(Default setting: 0)
  • 0: Do not inform the upper machine that connection is established.
  • 1: Inform the upper machine that connection is established.
Set:AT+NOTI[P1] OK+Set:[P1]

Note: After setting the command "AT+NOTI1", when the connection between the module and the device is established or broken, the module will send out the connection state information in the following format via the serial port.

OK+CONE ----- connect to EDR

OK+LSTE ----- disconnect from EDR

OK+CONB ----- connect to BLE

OK+LSTB ----- disconnect from BLE

OK+LSTA ----- break the connection on exception under dual mode, and the module reset.


  • Set the hinting type of informing the connection state to upper machine
Command Answering Parameter
Query:AT+NOTP? OK+Get:[P1] P1:0 or 1(Default setting: 0)
  • 0: The notification contains no remote IP address
  • 1: The notification contains remote IP address
Set:AT+NOTP[P1] OK+Set:[P1]

Note: This function, based on the command "AT+NOTI1", is used to set the hinting information content for connection and disconnection.

For the setting that the notification contains no remote IP address, the notification is the same with the hinting information set by the command "AT+NOTI1". For the setting that contains remote IP address, the hinting information is as follows:

OK+CONE:001122334455 ----- connect to EDR, remote IP address included

OK+LSTE:001122334455 ----- disconnect from EDR, remote IP address included

OK+CONB:001122334455 ----- connect to BLE, remote IP address included

OK+LSTB:001122334455 ----- disconnect from BLE, remote IP address included


  • Query\Set whether use BLE mode under Android system
Command Answering Parameter
Query:AT+ONEM? OK+Get:[P1] P1:0 or 1(Default setting: 0)
  • 0: Use BLE
  • 1: Do not use BLE
Set:AT+ONEM[P1] OK+Set:[P1]

Note1: After executed the command, you should power up the module again, to enable the new setting to take effect.

Note 2: After executing the command "AT+ONEM1",you can search the BLE mode under android system. However, only SSP mode can be used, BLE mode is unavailable. The BLE address, starting with 00: 0E: 0B, will be hided.


  • Query\Set the standby parameters under EDR mode
Command Answering Parameter
Query:AT+SCAN? OK+Get:[P1] P1: 0 or 1(Default setting: 0)
  • 0: Discoverable and connectable
  • 1: Not discoverable, but connectable
Set:AT+SCAN[P1] OK+Set:[P1]

Note: After executed the command, you should power up the module again, to enable the new setting to take effect.


  • Query\Set the PIN of EDR
Command Answering Parameter
Query:AT+PINE? OK+Get:[P1] P1: 1~8 bits of numeric characters
  • Default setting: 1234
Set:AT+PINE[P1] OK+Set:[P1]

Here is the example:

Send: AT+PINE008888

Return: OK+Set:008888

Now, the PIN is modified to 008888. In factory setting, the default PIN of EDR is "1234".

  • Query\Set PIN of BLE
Command Answering Parameter
Query:AT+PINB? OK+Get:[P1] P1: 1~6 bits of numeric characters
  • Default setting: 000000
Set:AT+PINB[P1] OK+Set:[P1]

Here is the example:

Send: AT+PINB008888

Return: OK+Set:008888

Now, the PIN is modified to 008888. In factory setting, the default PIN of BLE is "000000".


  • Renew the module
Command Answering Parameter
AT+RENEW OK+RENEW None

After executed this command, the module may restart after a delay of 500ms, and all the settings will be reset. This command should be used with caution.


For example:

Command to be sent out Answering Remarks
AT OK testing command, for judging whether the AT commands can be used for configuration.
AT+RENEW OK+RENEW Renew the module
AT+NAMBWaveshareBLE OK+Set:testBLE Set the device name of BLE to "WaveshareBLE"
AT+NAMEWaveshare_EDR OK+Set:testEDR Set the device name of EDR to "WaveshareEDR"
AT+RESET OK+RESET Reset the module or power up the module again

APP communication

APP communication protocol

The Demo APP provided by Waveshare has three modes: UART, remote control and device control. Since the UART mode has been presented above, we are going to describe more about the communication protocol of the remote control and the device control. User can easily build up the communication with the APP by sending out the data with the format we required.

Description

The communication protocol we used here is the standard JSON format (a lightweight data exchange format). To make data parse more easier, we employ the simplest key-value pair as following:

{"key":"Value"}

Here are the features of the key-value pair:

  • The key-value pair stores information;
  • The key-value pair is enclosed in the double quotation marks;
  • The key and the value in the key-value pair are separated by a colon;
  • The curly brackets marks are the symbols of the start and the end of the data frame, respectively.

All these features make data packaging and analysis easier. For more detailed information, please refer to the baseboard program and APP source code provided by Waveshare.

Remote control mode

The following figure shows the remote control mode, which includes State display, Speed control and Direction control.

Dual-mode-Bluetooth-User-Manual15.png

The table below lists the default protocol items:

Description State Command
Display Dual-mode Bluetooth information Receive {"State":"MSG"}
Set the speed-Low Press the key and send out {"Low":"Down"}
Set the speed- Medium Press the key and send out {"Medium":"Down"}
Set the speed-High Press the key and send out {"High":"Down"}
Direction control-Up Press the key and send out {"Forward":"Down"}
Direction control-Up Release the key and send out {"Forward":"Up"}
Direction control-Down Press the key and send out {"Backward":"Down"}
Direction control-Down Release the key and send out {"Backward":"Up"}
Direction control-Left Press the key and send out {"Left":"Down"}
Direction control-Left Release the key and send out {"Left":"Up"}
Direction control-Right Press the key and send out {"Right":"Down"}
Direction control-Right Release the key and send out {"Right":"Up"}

For example:

  • If you want to display the message "Init Success" in the APP, you can send out {"State":"Init Success"} with the Dual-mode Bluetooth. Then, the APP will receive and display the message, as the figure shows below.

Dual-mode-Bluetooth-User-Manual16.png

  • If you want to send out the command via the APP, you should press the corresponding key, and then, the Dual-mode Bluetooth module will receive the command. Of course, you can also customize the content to be sent by configuring the key setting.

Device control

The figure below shows the Device control, they are RGB LED control, buzzer control、OLED control and state displays.

Dual-mode-Bluetooth-User-Manual17.png

The following table lists the default protocol:

Description State Command
RGB LED control Press the key and select, Release the key and send out {"RGB":"R,G,B"}
Buzzer control Press the key and send out {"BZ":"on"} \ {"BZ":"off"}
OLED control Enter the relative data into the input box, and click the button Send for displaying {"OLED":"input string"}
Real time clock display Receive {"RTC":"data time"}
Acceleration display Receive {"ACC":"acc data"}
Voltage display Receive {"ADC":"adc value"}
Joystick state display Receive {"JOY":"key value"}
Temperature display Receive {"TEMP":"temperature"}

Notes:

Buzzer control employs single handshake. When you click the key "buzzer: on", the Dual-mode Bluetooth module will receive {"BZ":"on"}.

Now, the Dual-mode Bluetooth module should return the data it received to the APP, informing that it has been received the command (Send out {"BZ":"on"}).

When the APP receives {"BZ":"on"}, the state of the key will be switched (Switch to: "buzzer: off").

If you click the key "buzzer: off" once more, the Dual-mode Bluetooth module will receive {"BZ":"off"}.

Now, the Dual-mode Bluetooth module should return the data it received to the APP, informing that it has been received the command (Send out {"BZ":"off"}).

When the APP receives {"BZ":"off"}, the state of the key will be switched (Switch to: "buzzer: on").

Apply XNUCLEO-F103RB and Accessory Shield to perform device control

Testing steps:

1. The hardware connection is shown as following (If you have not enough jumper cap, you can remove the jumper from XNUCLEO-F103RB JP7 and tie it to JP4):

Dual-mode-Bluetooth-User-Manual18.png

2.Use ST-LINK/V2 (mini) to download the STM32 testing program (it is recommended to use the keil4.72 or Higher version for compiling).

3.Open the APP and connect your phone to the Dual-mode Bluetooth, then, select the option "device control" to test the functions of Accessory Shield.

Resources

Related Product

Support

Mail.png Contact your seller (fast response and most recommended)

or send emails to service@waveshare.com (not fast enough but please be patient) for help.

Our working time: 09:00-18:00 (UTC+8 Monday to Saturday)