Welcome to STM32-BoardCar repository
11.AI voice interaction integration module
Voice Interaction Control
Voice Interaction Control1. Software-Hardware2. Brief Principle1. Hardware Schematic2. Introduction to Voice Interaction Module1. Introduction to Voice Interaction Module2. Working Principle3. Notes4. Hardware interface description5. Control principle6. Physical connection diagram3. Control principle3. Main functions4.Voice module instructions5. Experimental phenomenon6. Voice Module Firmware Burning
This tutorial is a comprehensive experiment combining multiple peripherals. You can first understand a single peripheral and then conduct this experiment.
1. Software-Hardware
STM32F103CubeIDE
STM32 Robot Development Board
Intelligent Voice Interaction Module: External
Type-C Data Cable or ST-Link
Download or simulate the development board
2. Brief Principle
1. Hardware Schematic

2. Introduction to Voice Interaction Module
1. Introduction to Voice Interaction Module
CI1302 is a new generation of high-performance neural network intelligent voice chip developed by Qiying Tailun, integrating Qiying Tailun's self-developed brain neural network processor BNPU V3 and CPU core, with a system frequency of up to 220MHz, built-in SRAM up to 640KByte, integrated PMU power management unit and RC oscillator, integrated dual-channel high-performance low-power Audio Codec and multi-channel UART, IIC, IIS, PWM, GPIO, PDM and other peripheral control interfaces. The chip only needs a small number of peripheral devices such as resistors and capacitors to realize various intelligent voice product hardware solutions, with extremely high cost performance.
Using 3rd generation hardware BNPU technology, supporting neural networks such as DNN\TDNN\RNN\CNN and parallel vector operations, it can realize voice recognition, voiceprint recognition, command word self-learning, voice detection and deep learning noise reduction. The chip solution also supports multiple global languages such as Chinese, English, and Japanese, and can be widely used in home appliances, lighting, toys, wearable devices, industry, automobiles and other product fields to realize voice interaction and control and various intelligent voice solution applications.
The CI1302 chip has a brain neural network processor core (BNPU), supports offline NN accelerated computing and voice signal processing hardware acceleration, etc. The CPU main frequency can reach 220MHz, can be offline far-field voice recognition, built-in 2MB FLASH storage, and can support 300 command words.
2. Working Principle
The module adopts the command mode to wake up. The user needs to say the set wake-up word to activate the voice interaction module first. After activation, voice recognition can be performed. The default wake-up keyword of the factory firmware is "Xiaoya Xiaoya". If no voice is recognized after 20 seconds, the module will enter sleep mode and need to be re-awakened when used again.
When the CI1302 chip recognizes the corresponding voice entry, it will be sent out through the serial port and IIC interface, and feedback will be broadcast; the IIC chip will store the received voice command and send it out through the IIC slave protocol.
The module supports wake-up word modification, command word modification and custom entry. You can learn how to operate in the tutorials ** "2. Modify wake-up words and command words" and "3. Customize protocol entry production" ** tutorials.
3. Notes
Use 5V voltage for power supply. Exceeding 5V will damage the module
The usage scenario should be quiet. A noisy environment will affect the recognition effect
When speaking the entry, the voice should be loud and the speed should not be too fast. It is recommended to keep within 5 meters of the module
4. Hardware interface description


| Serial number | Hardware name | Description |
|---|---|---|
| 1 | Speaker | Convert analog signals into sound |
| 2 | Slide switch | Switch serial port for firmware burning |
| 3 | Microphone | Convert sound into analog signals |
| 4 | RST button | Reset button |
| 5 | Power indicator (red light) | Always on when power is normal |
| 6 | Type-C interface | For power supply and CI1302 chip, SCT8 firmware update download |
| 7 | Amplifier chip | Convert digital signals into analog signals to drive speakers |
| 8 | CI1302 chip | High-performance voice recognition chip, recognizes voice and outputs signals |
| 9 | Anti-reverse connection setting | 5v, GND reverse connection protection |
| 10 | IIC interface | As a slave, used for power supply and communication with the host device |
| 11 | Serial port interface | The external serial port provided can control the broadcast through the protocol |
| 12 | STC8H chip | Convert the voice chip instructions into IIC protocol instructions and serial port instructions |
5. Control principle
| (schematic name) | Control pin | Specific meaning |
|---|---|---|
| UART4_RX | PC11 | Serial port 4 receiving end |
| UART4_TX | PC10 | Serial port 4 transmitting end |
Serial communication:
UART (Universal Asynchronous Receiver Transmitter) is a full-duplex universal asynchronous serial receiver/transmitter module, mainly used for printing program debugging information, communication between the host and the slave, and ISP program download. UART requires at least two data lines for both parties to transmit data in both directions at the same time. The simplest UART interface consists of three lines: TxD, RxD, and GND. Among them, TxD is used to send data, RxD is used to receive data, and GND is the signal ground line. Serial communication between two chips is realized through cross connection.
6. Physical connection diagram
Voice module wiring:
| Intelligent voice interaction module | STM32 |
|---|---|
| 5V | 5V |
| GND | GND |
| TX1 | PC11 |
| RX1 | PC10 |

Motor wiring:

3. Control principle
| Module | Function |
|---|---|
| Voice interaction module | Communicate with the microcontroller and perform voice broadcast |
Procedure Flowchart
After we power on, we need to wake up the voice interaction module first. After we say "Xiao Ya Xiao Ya" in voice, the voice module will send a data frame to the MCU, but the host does not need to send data back to the module. Then the voice module will voice broadcast "Yes". After we hear the broadcast, we can send voice commands to the voice module. The voice module and the MCU will send data frames to each other for communication.
Voice module: After receiving the voice command, send a data frame to the MCU serial port.
MCU part: Receive the data frame and then judge each byte of the data frame. Our data frame protocol is a hexadecimal byte stream, the format is: AA 55 00 XX FB (active broadcast), AA 55 FF XX FB (passive broadcast), where the frame header is the starting two bytes AA 55 and the frame tail is a fixed byte FB. The third byte in the middle controls the active and passive broadcast of the voice module, and the fourth byte is the command data we need. We return the fourth byte data, and then process the data to make the car give corresponding feedback. After the car has given feedback, the MCU will send the specified content to the voice module, and the voice module will broadcast it after receiving it.
3. Main functions
Function: Get_Cmd
| Function prototype | uint16_t Get_Cmd(void) |
|---|---|
| Function description | Get the latest command information of the voice interaction module |
| Input parameters | None |
| Return value | None |
Function: Change_RGB
| Function prototype | void Change_RGB(Control_RGB_t rgb_flag) |
|---|---|
| Function description | Voice control RGB light |
| Input parameters | The last two ids sent by the corresponding voice module to the host |
| Return value | None |
4.Voice module instructions
| Semantic Tag | Command Word | Function Type | Broadcast Sentence | Broadcast Mode | Sending Protocol | Receiving Protocol |
|---|---|---|---|---|---|---|
| 1 | WELCOME | Welcome Message | welcome | Passive | AA 55 01 00 FB | AA 55 01 00 FB |
| 2 | BYE | Rest Message | bye | Active | AA 55 02 00 FB | AA 55 02 00 FB |
| 3 | HI-YAHBOOM | Wake-up Word | I am here | Active | AA 55 03 00 FB | AA 55 03 00 FB |
| 4 | VOLUME-UP | Increase Volume | Volume Up | Active | AA 55 04 00 FB | AA 55 04 00 FB |
| 5 | VOLUME-DOWN | Decrease Volume | Volume down | Active | AA 55 05 00 FB | AA 55 05 00 FB |
| 6 | MAX-VOLUME | Maximum Volume | Maximum volume | Active | AA 55 06 00 FB | AA 55 06 00 FB |
| 7 | MID-VOLUME | Medium Volume | Medium volume | Active | AA 55 07 00 FB | AA 55 07 00 FB |
| 8 | MINI-VOLUME | Minimum Volume | Minimum Volume | Active | AA 55 08 00 FB | AA 55 08 00 FB |
| 9 | START-REPORT | Start Broadcasting | Start broadcasting | Active | AA 55 09 00 FB | AA 55 09 00 FB |
| 10 | STOPT-REPORT | Stop Broadcasting | Stop Broadcast | Active | AA 55 0A 00 FB | AA 55 0A 00 FB |
| 11 | ROBOT-STOP | Command Word | ok I am stop | Active | AA 55 00 01 FB | AA 55 00 01 FB |
| 12 | STOP | Command Word | ok I am stop | Active | AA 55 00 02 FB | AA 55 00 02 FB |
| 13 | ROBOT-SLEEP | Command Word | ok dormant | Active | AA 55 00 03 FB | AA 55 00 03 FB |
| 14 | GO-AHEAD | Command Word | ok let's go | Active | AA 55 00 04 FB | AA 55 00 04 FB |
| 15 | BACK | Command Word | ok i am back | Active | AA 55 00 05 FB | AA 55 00 05 FB |
| 16 | TURN-LEFT | Command Word | ok i am turning left | Active | AA 55 00 06 FB | AA 55 00 06 FB |
| 17 | TURN-RIGHT | Command Word | ok i am turning right | Active | AA 55 00 07 FB | AA 55 00 07 FB |
| 18 | ENTER-A-MODE | Command Word | ok I am working on A mode. | Active | AA 55 00 08 FB | AA 55 00 08 FB |
| 19 | ENTER-B-MODE | Command Word | ok I am working on B mode. | Active | AA 55 00 09 FB | AA 55 00 09 FB |
| 20 | CLOSE-LIGHT | Command Word | ok light is closed. | Active | AA 55 00 0A FB | AA 55 00 0A FB |
| 21 | RED-LIGHT-UP | Command Word | ok red light is on | Active | AA 55 00 0B FB | AA 55 00 0B FB |
| 22 | GREEN-LIGHT-UP | Command Word | ok green light is on | Active | AA 55 00 0C FB | AA 55 00 0C FB |
| 23 | BLUE-LIGHT-UP | Command Word | ok blue light is on | Active | AA 55 00 0D FB | AA 55 00 0D FB |
| 24 | YELLOW-LIGHT-UP | Command Word | ok yellow light is on | Active | AA 55 00 0E FB | AA 55 00 0E FB |
| 25 | RED-DETECTED | Command Word | Recognize red | Active | AA 55 FF 49 FB | AA 55 FF 49 FB |
| 26 | GREEN-DETECTED | Command Word | Recognize green | Active | AA 55 FF 43 FB | AA 55 FF 43 FB |
| 27 | BLUE-DETECTED | Command Word | Recognize blue | Active | AA 55 FF 44 FB | AA 55 FF 44 FB |
| 28 | YOU-WON | Command Word | You won nice job | Passive | AA 55 FF 5E FB | AA 55 FF 5E FB |
| 29 | YOU-LOSE | Command Word | You are down let us have another round | Passive | AA 55 FF 5F FB | AA 55 FF 5F FB |
| 30 | TIE | Command Word | Stalemate let’s have a rematch! | Passive | AA 55 FF 60 FB | AA 55 FF 60 FB |
| 31 | RIGHT-TURN-SIGN-DETECTED | Command Word | Recognize the right turn sign the car turns right | Passive | AA 55 FF 61 FB | AA 55 FF 61 FB |
| 32 | HORN-SIGN-DETECTED | Command Word | Recognize the horn sign the car honks | Passive | AA 55 FF 62 FB | AA 55 FF 62 FB |
| 33 | FORWARD-SIGN-DETECTED | Command Word | Recognize the forward sign the car moves forward | Passive | AA 55 FF 63 FB | AA 55 FF 63 FB |
| 34 | UPWARD-GESTURE-DETECTED | Command Word | Recognize the forward gesture the car moves forward | Passive | AA 55 FF 64 FB | AA 55 FF 64 FB |
| 35 | DOWNWARD-GESTURE-DETECTED | Command Word | Recognize the backward gesture the car moves backward | Passive | AA 55 FF 65 FB | AA 55 FF 65 FB |
| 36 | LEFT-GESTURE-DETECTED | Command Word | Recognize the left gesture the car turns left | Passive | AA 55 FF 66 FB | AA 55 FF 66 FB |
| 37 | RIGHT-GESTURE-DETECTED | Command Word | Recognize the right gesture the car turns right | Passive | AA 55 FF 67 FB | AA 55 FF 67 FB |
5. Experimental phenomenon
After successfully downloading the program, connect the voice interaction module and wake up the voice interaction module. The wake-up method is to say "Xiao Ya Xiao Ya" to the voice interaction module, and the module will reply "Yes".
After we hear the reply, we can issue instructions to the car. This tutorial mainly controls the indicator lights on the expansion board, and the car motion control instructions are not available (The interval between issuing instructions and instructions needs to be within 20 seconds, otherwise the voice interaction module needs to be re-awakened.)
After each instruction operation, the voice interaction module will have a corresponding broadcast reply.
For program download, please refer to [Chapter 2: Development Environment Construction and Use → 2.6 Program Download and Simulation]
6. Voice Module Firmware Burning
xxxxxxxxxxBurning the CI1302_ EN _ SingleMic_ V00916_UART1_115200_2M.bin file we provide can realize the relevant cases of this car's intelligent voice interaction module, without multiple burning.Download the voice module firmware CI1302_ EN _ SingleMic_ V00916_UART1_115200_2M.bin we provide
Connect the Type-C of the voice module to your PC and push the slider of the voice module to pin 1. 1 represents the firmware burning of the voice chip (that is, the left side)


Open the voice chip firmware burning tool

Select the CI1302 chip and click "Firmware Upgrade"

Find the factory firmware “CI1302_ EN _ SingleMic_ V00916_UART1_115200_2M.bin” and select the corresponding firmware

Find the corresponding serial port number and click to select

Press the RST button on the board and the firmware will be automatically downloaded to the voice module(After the burning is completed, bend the slider to the right, that is, the pin2 position)
