Reference
Last revision 2025/12/17
The article offers a detailed guide to using the DFRobot DF1101S library and communication protocol, providing commands for managing audio functions such as recording, playback, volume control, and more, along with API descriptions for setting various operation modes efficiently.
Communication Protocol Description
NOTE:
- "\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".
- Default serial baud rate: 115200
- Recording:
- AT+FUNCTION=2 //Enter recording mode
- AT+REC=RP // Start Recording
- AT+REC=SAVE //Save recorded file
- Playing:
- AT+FUNCTION=1 //Enter music mode
- AT+PLAY=PP //Playing
/**
* @brief Test connection
*/
AT //Test connection
/**
* @brief Volume control(volume degree: 0-30)
* @param -n:Volume-n
* +n:Volume+n
* n:Designate volume to n
* ?:Query volume
*/
AT+VOL=-5 //Volume-5
AT+VOL=? //Query volume
Return:VOL = [10] //Current volume is 10
/**
* @brief Function switch
* @param 1: Music mode
* 2: Recording mode
* 3: Slave mode
*/
AT+FUNCTION=1 //Switch to music mode
/**
* @brief Playing mode control
* @param 1: Repeat one song
* 2: Repeat all
* 3: Play one song only
* ?: Query current playing mode
*/
AT+PLAYMODE=1 //Switch to repeat one song
AT+PLAYMODE=? //Query current playing mode
Return:PLAYMODE =1 //Current playing mode: repeat one song
/**
* @brief Playing control
* @param PP: Play & Pause
* NEXT:Next song
* LAST:Last song
*/
AT+PLAY=NEXT //Next song
/**
* @brief Play the file of the designate number (default file name) or specific file once
* @param n: Play the music file with name number n()(0-999),play the first file if there is no one.
* File path: play the file of specific path
*/
AT+PLAYFILE=5 //Play FILE0005.mp3 once
AT+PLAYFILE=/DF_REC/test.MP3 //Play test.mp3 under DF_REC once
/**
* @brief Delete the currently-playing file
*/
AT+DEL
/**
* @brief Recording control
* @param RP:Record & Pause
* SAVE:Save the recorded file
*/
AT+REC=SAVE //Save the recorded file
/**
* @brief Set baud rate(power-down save, valid after repowering on)
* @param 9600, 19200, 38400, 57600, 115200
*/
AT+BAUDRATE=115200 //Set baud rate to 115200
/**
* @brief Prompt tone ON/OFF commands (power-down save)
* @param ON, OFF
*/
AT+PROMPT=ON //Enable prompt tone
//LED prompt ON/OFF commands(power-down save)
/**
* @brief LED Prompt ON/OFF commands(power-down save)
* @param ON, OFF
*/
AT+LED=ON //Enable LED prompt
API Description
/**
* @brief Set baud rate(Need to power off and restart, power-down save)
* @param 9600,19200,38400,57600,115200
* @return true or false
*/
bool setBaudRate(uint32_t baud);
/**
* @brief Set playback mode
* @param ePlayMode_t:SINGLECYCLE,ALLCYCLE,SINGLE
* @return true or false
*/
bool setPlayMode(ePlayMode_t mode);
/**
* @brief Set indicator LED(Power-down save)
* @param true or false
* @return true or false
*/
bool setLED(bool on);
/**
* @brief Set prompt tone(power-down save)
* @param true or false
* @return true or false
*/
bool setPrompt(bool on);
/**
* @brief Set volume
* @param vol:0-30
* @return true or false
*/
bool setVol(uint8_t vol);
/**
* @brief Set working mode
* @param eFunction_t:MUSIC,RECORD,UFDISK
* @return true or false
*/
bool switchFunction(eFunction_t function);
//bool operation( );
/**
* @brief Next
* @return true or false
*/
bool next();
/**
* @brief Last
* @return true or false
*/
bool last();
/**
* @brief Play(in music mode) or Record (in recording mode)
* @return true or false
*/
bool start();
/**
* @brief Playing Pause(in music mode) or recording pause(in recording mode)
* @return true or false
*/
bool pause();
/**
* @brief Save the recorded voice
* @return true or false
*/
String saveRec();
/**
* @brief Delete the currently-playing file
* @return true or false
*/
bool delCurFile();
/**
* @brief Play the file of specific path
* @param The designated path
*/
void playSpecFile(String str);
/**
* @brief Play the file of specific number(only valide for the default file name),
* @ play the first one if there is no file designated.
* @param File name number: 0-999
*/
void playSpecFile(int16_t num);
/**
* @brief Get volume
* @return vol
*/
uint8_t getVol();
/**
* @brief Get playback mode
* @return ePlayMode_t
*/
ePlayMode_t getPlayMode();
Other Supplementary Information
Get AD Button from DFRobot Store or DFRobot Distributor.
| Key | Resistor in Series | Click | Long-press |
|---|---|---|---|
| K0 | 0R | Pause & Play | |
| K1 | 3K | Last | Volume + |
| K2 | 6.2K | Next | Volume - |
| K3 | 9.1K | Switch Play Mode | |
| K4 | 15K | REC | |
| K5 | 24K | PLAY | |
| K6 | 33K | Volume - | Volume - |
| K7 | 51K | Volume + | Volume + |
| K8 | 100K | Switch Working Mode | |
| K9 | 220K | Delete Currently-playing File |

Was this article helpful?
