Audio & BLE/SPP Pass-through Module Bluetooth 5.0 Wiki - DFRobot

Introduction

This Bluetooth module features Bluetooth/U-disk/TF-card playback, and Bluetooth call function, supporting simple and clear serial port control function, BLE pass-through, and SPP pass-through functions. The highlight of this product is the dual-mode Bluetooth, which also means that it can run the Bluetooth audio playback and data transmission at the same time, greatly reducing the development difficulty of embedded Bluetooth in other products.

Feature

No. Function
1 16-bit Stereo DAC with headphone amplifier, SNR >= 95dB
2 Support MP3, WAV, WMA, FLAC, AAC, APE format decoding
3 Support 128G U-disk and TF card, breakpoint memory and track memory functions
4 Support bluetooth audio transmission, connect with mobile for music transmission, support play, pause, up and down switch
5 Support bluetooth call function (users can cancel it): answer, hang up, dial back, refuse to answer and other functions
6 Bluetooth 5.0, support HFP/A2 DP/AVRCP/HSP/ GAVDP/IoP/SPP/BLE with a distance of around 10M
7 Support BLE/SPP pass-through function

Application

Specification

Dimension Diagram

Dimension

Board Overview

Pinout

No. Define IO function Description
1 PA3 AUX1L External Audio input channel--left channel
2 PA4 AUX1R External Audio input Channel--right channel
3 PA5 ADKEY ADkey, pull-up resistor of 22k, left floating when not in use
4 USBDM USBD
5 USBDP USBD+
6 3V3 Power Output LDO output of the internal chip. The external load shall not exceed 80mA. Try not to use it.
7 DVDD POWER Bias voltage of the chip DAC, connect a 105 resistor
8 PA0 MIC MIC IO for calling
9 DACR Right Channel Output
10 DACL Left Channel Output
11 SGND Analog Ground Connect to the ground of power supply separately, do not mix with digital ground, single point grounding is best
12 GND Digital Ground
13 VCC Power Input 3.3V -5V, suitable for 3.7 lithium battery power supply
14 PC1 GPIO / PWM1
15 PC3 SDDAT Connect to data pin of external TF card
16 PC4 SDCMD Connect to command pin of external TF card
17 PC5 SDCLK Connect to clock pin of external TF card
18 PR2 GPIO/RESET Can work as normal IO or reset pin, floated at present
19 PR1 LED Connect to external LED, high level to turn it on
20 PB6 GPIO Common GPIO
21 PB5 GPIO Common GPIO
22 PB4 GPIO Common GPIO
23 PB3 GPIO /MUTE Mute pin. Auto-detect when the module powered on, and output the corresponding level. Detecting method: pull up 10K, high level to mute; pull down 10K, low level to mute.
24 PB2 GPIO Common GPIO
25 PB1/RX UART-RX0 Connect to the TX of MCU, 3.3V level, please connect 1K resistor in series for 5V
26 PB0/TX UART-TX0 Connect to the RX of MCU, 3.3V level, compatible with 5V level

Tutorial

Note: it is recommended to use hardware serial to drive this module, since it may be unstable when using software serial, which may result in unknown errors.It is suggested to reduce the module's baud rate to 9600 when using software serial driver.

Requirements

Control by Arduino

Connection

API Function List

 /**
   * @brief Set volume
   * @param volume(0-30)
   * @return true or false
   */
  bool setVOl(uint8_t vol);

  /**
   * @brief Set working mode
   * @param eFunction_t
   * @return true or false
   */
  bool switchFunction(eFunction_t function);

  /**
   * @brief Set play mode 
   * @param ePlayMode_t
   * @return true or false
   */
  bool setPlayMode(ePlayMode_t mode);

  /**
   * @brief Play control  Only valid for playback by TF card and U-disk
   * @param ePlayControl_t
   * @return true or false
   */
  bool playControl(ePlayControl_t cmd);

  /**
   * @brief Next
   * @return true or false
   */
  bool next();

  /**
   * @brief Last 
   * @return true or false
   */
  bool last();

  /**
   * @brief Play the N-th file, play song of the specified number 
   * @param specified number
   * @return true or false
   */
  bool playSpecFile(uint16_t number);

  /**
   * @brief Play song of the specified path
   * @param specified path
   * @return true or false
   */
  bool playSpecFile(const char* path);

  /**
   * @brief Delete the currently playing file 
   * @return true or false
   */
  bool delCurFile();

  /**
   * @brief Dial a phone number 
   * @param phone number
   * @return true or false
   */
  bool callOut(const char* phoneNumber);

  /**
   * @brief Call control 
   * @param eControltalk_t
   * @return true or false
   */
  bool controltalk(eControltalk_t cmd);

  /**
   * @brief Obtain bluetooth status 
   * @return eBtStatus
   */
  eBtStatus getBtStatus();

  /**
   * @brief Obtain calling phone number 
   * @return phone number
   */
  String getTelNumber();

Sample Code 1- Playback

When the module powered on, enter the music mode, start playing the last recorded file, pause playing after 3S, play the next song after 3S, play the previous song after 3S, and play the first file copied into the device after 3 seconds.

/*!
 * @file playMusic.ino.ino
 * @brief Play song in TF card 
 * @n Experiment Phenomenon:play music and do the related actions 
 * @copyright  Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @licence     The MIT License (MIT)
 * @author [Eddard](Eddard.liu@dfrobot.com)
 * @version  V1.0
 * @date  2020-12-29
 * @get from https://www.dfrobot.com
 * @url https://github.com/cdjq/DFRobot_ID809
*/

#include <DFRobot_BT401.h>
#include <SoftwareSerial.h>

SoftwareSerial btSerial(2, 3);  //RX TX

DFRobot_BT401 bt;

void setup(){
  btSerial.begin(115200);
  /*Delay 2s for the BT401 to start*/
  delay(2000);
  while(!bt.begin(btSerial)){
    Serial.println("Init failed, please check wire connection!");
    delay(1000);
  }
  bt.setVOl(30);
  bt.switchFunction(bt.eTFCard);
  bt.setPlayMode(bt.eDeviceCycle);
}

void loop(){
  //Play
  bt.playControl(bt.ePlay);
  delay(3000);
  //Pause 
  bt.playControl(bt.ePause);
  delay(3000);
  //Next 
  bt.next();
  delay(3000);
  //Last 
  bt.last();
  delay(3000);
  //Play song in the first file
  bt.playFileNum(1);
  while(1);
  /*Delete the currently playing file*/
  //bt.delCurFile();
}

Sample Code 2 - Incoming Call Control

/*!
 * @file answerCall.ino.ino
 * @brief Get incoming call information 
 * @n Experiment Phenomenon:Print phone number and answer the phone when a call comes 
 * @copyright  Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @licence     The MIT License (MIT)
 * @author [Eddard](Eddard.liu@dfrobot.com)
 * @version  V1.0
 * @date  2020-12-29
 * @get from https://www.dfrobot.com
 * @url https://github.com/cdjq/DFRobot_ID809
*/

#include <DFRobot_BT401.h>
#include <SoftwareSerial.h>

SoftwareSerial btSerial(2, 3);  //RX TX

DFRobot_BT401 bt;

void setup(){
  Serial.begin(115200);
  btSerial.begin(115200);
  /*Delay 2s for the BT401 to start*/
  delay(2000);
  while(!bt.begin(btSerial)){
    Serial.println("Init failed, please check wire connection!");
    delay(1000);
  }
  bt.setVOl(30);
  bt.switchFunction(bt.eBluetooth);
}

void loop(){
    //If a call comes, print phone number and answer it 
    if(bt.getBtStatus() == bt.eCalling){
      Serial.println(bt.getTelNumber());
      delay(1000);
      //Answer
      bt.controltalk(bt.eAnswer);
      //Refuse to answer
      //bt.controltalk(bt.eRejectCall);
    }
    //If you are on the phone, print the incoming phone number 
    if(bt.getBtStatus() == bt.eOnphone){
      Serial.print("On the phone:");
      Serial.println(bt.getTelNumber());
      delay(1000);
      //Hang Up
      //bt.controltalk(bt.eHangUp);
    }
}

Connection

Connection 2

AT Command List

Note:

  1. "\r\n is" omitted in all the commands below, and you need to add it to the end of the command in actual use. For example "AT+VOL=5\r\n", designate volume to "5".
  2. Default serial baud rate: 115200

Volume Command

Control

Command Function Description
AT+CA05 Designate volume to "5" Volume Degree: 00-30
AT+CE Increase volume
AT+CF Decrease volume
AT+CU00 Unmute
AT+CU01 Mute
AT+CU02 Mute & Unmute Switch
AT+CS00 Disable DAC DAC output high impedance
AT+CS01 Enable DAC DAC is playing normally

Query

Command Function Description
AT+QA Query the volume of current device Return “QA+30”, represent the host volume is 30

Working Mode Command

Control

Command Function Description
AT+CM01 Bluetooth playback mode
AT+CM02 "U-disk" playback mode If there is no U-disk, return error information, and do nothing
AT+CM03 "TF-card" playback mode If there is no TF-card, return error information, and do nothing
AT+CM08 Idle mode Release all sources, in waiting status

Query

Command Function Description
AT+QM Query the working mode of current device Return “QM+01”, means it is in “Bluetooth playback mode”
01-Bluetooth;02-U-disk play mode;03-TF card play mode;09-idle

TF-card or U-disk Command

Control

Command Function Description
AT+AA00 Stop
AT+AA01 Play
AT+AA02 Pause
AT+AA03 Play&pause switch
AT+CC Next
AT+CD Last
AT+AA04 Fast forward
AT+AA05 Fast backward
AT+AA06 Play next file
AT+AA07 Play last file
AT+AA08 Delete the currently playing file
AT+AB15 Play the 15th file of the device Refer to the order that the file is copied into the device
AT+AF/MY_MUSIC/*.??? Repeat song in the specified file Repeat song in the specified file folder “MY_MUSIC”
(* for wildcard, ??? for all files)
AT+AF/MY_MUSIC/test.mp3 Play song in the specified file once Play the file test.mp3 in file folder MY_MUSIC once (Can use wildcard)
AT+AC00 Repeat all When both U-disk and TF-card are there, repeat all files in the two devices
AT+AC01 Repeat songs in one device
AT+AC02 Repeat one song
AT+AC03 Play songs randomly in one device
AT+AC04 Repeat songs in file folder If the currently playing song is in the current folder, repeat songs in this folder, otherwise, invalid

Query

Command Function Description
AT+M1 Query the physical serial number of the currently playing file in device Return“M1+000002”,means the serial number of the currently playing file is 2
AT+M2 Query the total number of files in the current device Return “M2+000010”, means the current device has 10 files in total
AT+MC Query the current play mode Return “MC+00”, means repeat all
00-repeat all; 01-repeat songs in one device; 02-repeat one song; 03-play songs randomly in one device;04-repeat songs in a folder
AT+MD Query the currently playing device Return “MD+01”, means it is playing the song in the U-disk
AT+MF Query the currently playing file name Return “MF+test.mp3”, means the currently playing file name is “test.mp3”
AT+MP Query the currently playing status Return “MP+01”, means it is playing now
00-stop;01-playing;02-pause
AT+MT Query the length of the currently playing file Return “MT+0000001D”, means the length of the currently playing file is 0x1Ds
AT+MK How long has the current file been playing? Return “MK+00000000”, the current file has been playing for 0 second
AT+MV Query the current online device Return “MV+04”, TF-card is online
00-both are not online; 01-U-disk is online; 02-TF card is online; 03-both are online
AT+MU Device plug in/out message Return “MU+03”, means TF-card plug in
01-U-disk plug out; 02-U-disk plug in;03-TF card plug in; 04-TF plug out

Bluetooth Audio Command

Control

Command Function
AT+CB Play & Pause
AT+CC Next
AT+CD Last
AT+BT10086 Dial “10086”
AT+BA00 Dial back last phone number
AT+BA01 Disconnect Bluetooth
AT+BA02 Refuse to answer
AT+BA03 Hang up
AT+BA04 Answer

Query

Command Function Description
AT+TS Query EDR status Return “TS+00”, means wait for pairing
00-wait for pairing; 01-Connected, idle; 02-Playing music now; 03-Incoming call not answered; 04-On the phone
AT+TT Query Bluetooth incoming call phone number(return automatically, once every 2s) Return “TT+10086”, means the incoming number is 10086

BLE Command

Control

Command Function
AT+U0F000 Designate service UUID as F000
AT+U0F001 Designate attribute code 1 as F001, “write” +“monitoring”
AT+U0F002 Designate attribute code 2 as F002, “write” +“monitoring”
AT+U0F003 Designate attribute code 3 as F003, “write”, send AT command from phone to control Bluetooth chip

BLE Query

Command Function Description
AT+TL Query BLE Status(auto-return) Return “TS+01”, means in idle state
00-Not connected; 01-Idle; 02-Broadcast; 03-Connected; 04-Disconnect; 05-Monitoring enabled; 06-Scanning(host); 07-Scanned(host)
AT+T6 Query service UUID
AT+T7 Query attribute code 1
AT+T8 Query attribute code 2
AT+T9 Query attribute code 3

Setting Command

Control

Most of the settings will take effect when repowering on the module.

Common Setting

Command Function Description
AT+CT05 Set baud rate to 115200 Parameter: 01-06(9600, 19200, 38400, 57600, 115200, 25600)
AT+CZ Reset Software reset
AT+CW Restore factory settings Restore factory settings, clear all the previous parameters
AT+CN01 Turn on hint tone Play the tone when powering on or switching mode
AT+CN00 Turn off hint tone
AT+CJ01 Enable trigger playing Stop when completed
AT+CJ00 Disable trigger playing
AT+CP00 Enter Bluetooth mode when powered on
AT+CP01 Enter idle mode when powered on Users need to send mode command
AT+CP02 Auto judge when powered on Play song in device if there is one, otherwise, enter bluetooth
AT+CR01 Enable auto-return function of key informatin Key information will return back automatically (Bluetooth status,every 0.5S, TF-card or U-disk, every 1S), for example: incoming call inforamtion
AT+CR00 Disable auto-return function of key information
AT+BDAUDIO Set Bluetooth name Set bluetooth name as “AUDIO”
AT+BE0000 Set Bluetooth connection password Set Bluetooth connection password as “0000”
AT+BMDFROBOT Set BLE Bluetooth name Set BLE Bluetooth name as “DFROBOT”
AT+B101 Enable pair password
AT+B100 Disable pair password Password is not required for next connection
AT+C401 Enable reconnect when powered on Auto connect the last paired device when powered on
AT+C400 Disable reconnect when powered on
AT+C201 Enable information auto return Auto return information when powered on or switching status
AT+C200 Disable information auto return Chip returns information only when query actively; the chip will not return "OK" when sending control command
AT+C101 Enable AD key PA5 needs to pull up 22K
AT+C100 Disable AD key

Uncommon Setting

Command Function Description
AT+CK01 Enable auto switch to Bluetooth Play files in TF card now, if there is audio or call on Bluetooth, then auto switch to Bluetooth
AT+CK00 Disable auto switch to Bluetooth
AT+CG01 Enable Bluetooth background Release Bluetooth when playing files in TF card
AT+CG00 Disable Bluetooth background
AT+B201 Enable Bluetooth call function
AT+B200 Disable Bluetooth call function Cannot call through Bluetooth
AT+B301 Enable Bluetooth audio function
AT+B300 Disable Bluetooth audio function Connected, cannot play music
AT+B401 Enable BLE function
AT+B400 Disable BLE function BLE name cannot be searched, the chip does not broadcast out
AT+B501 Enable EDR function
AT+B500 Disable EDR function The audio Bluetooth name cannot be searched, the Bluetooth audio play function disabled
AT+BS123456781234 Set Bluetooth MAC address EDR MAC address: 0x12 0x34 0x56 0x78 0x12 0x34
BLE MAC address: the first byte of the EDR MAC address + 1
BLE MAC address: 0x13 0x34 0x56 0x78 0x12 0x34

Query

Command Function Description
AT+QT Query baud rate Return “QT+05”, means the baud rate is 115200
01-06(9600, 19200, 38400, 57600, 115200, 25600)
AT+QN Query hint tone Return “QN+01”, means hint tone enabled
00-disable; 01-enable
AT+QK Query auto switch to Bluetooth Return“ QK+01”, means auto switch to Bluetooth function enabled
00-Disable; 01-Enable
AT+TE Query password
AT+TD Query Bluetooth name
AT+TA Query Bluetooth MAC address
AT+TM Query BLE name
AT+TB Query BLE MAC address
AT+T1 Query whether pair password enabled Return “T1+01”, enabled
00-disable;01-enable
AT+T2 Query whether Bluetooth call function is enabled Return “T2+01”, enabled
00-disable;01-enable
AT+T3 Query whether Bluetooth audio function is enabled Return “T3+01”, enabled
00-disable; 01-enable
AT+T4 Query whether BLE function is enabled Return “T4+01”, enabled
00-Disable; 01-Enable
AT+T5 Query whether EDR function is enabled Return“T5+01”, enabled
00-disable;01-enable

BLE Pass-through

To use BLE Pass-through, please connect to BT401-BLE

SPP Pass-through

To use SPP Pass-through, please connect to BT401-AUDIO

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents