当前位置:网站首页>Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f
Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f
2022-07-07 23:32:00 【Little river god is tangled】
List of articles
Preface
Last month, I showed you how to use ESP-C3-12F To control WS2812 RGB Light Bar ( Anxinco ESP32-C3 Module Alibaba cloud remote control WS2812RGB Light Bar ( be based on ESP-IDF Of SDK)), The third section mentioned VB-01 This module . Because the module was still completely confidential , It is not allowed to make too many introductions .
And this blog will not mention how to do secondary development of modules , Only external MCU How to communicate with VB-01 communicate .
One 、VB-01 Module introduction
VB-01 It is an upcoming product of Anxin Ke Offline voice control module , And bring your own bill MIC Input and single speaker output . Users can directly put 2 Linear MIC and 2 Line speaker access , No need to attach Power amplifier circuit and MIC Filter circuit , Control commands can be controlled by intelligent AI Voice decoding .
Bloggers test their experience , The probability of false identification is still quite small , Almost none, so to speak . Given that it is still in a confidential state , Bloggers don't show VB-01 The true face of (VB-01 Soon, an official treasure of Anxin will be on the shelves , You can pay attention to it , The link is at the end of this article ). In order to cooperate with the following , Only pin diagram can be given .
Two 、 Communication serial port selection
1. Communication serial port introduction
VB-01 A total of three groups of serial ports are given : RX0_5V-TXD0_5V、RXD0_3V3-TXD0_3V3 and RXD1-TXD1. among ,RX0_5V-TXD0_5V、RXD0_3V3-TXD0_3V3 It's common. UART0, It's also MCU Communication interface ,. and TXD1 and RXD1 yes UART1 For downloading programs .
2.UART0
VB-01 And the outside MCU Communication interface is recommended UART0, Default baud rate :38400, That's what this is : RX0_5V-TXD0_5V、RXD0_3V3-TXD0_3V3.
3. Print information description
UART0 The printed content of is as follows :
ASR Result: Hello, Wei // In Chinese Windows Environmental presentation Garbled status
Wakeup: Hello, Wei // In Chinese Windows Environmental presentation Garbled status
Send data len:4
Send uart data:0xAA 01 00 BB
ReadmePlay ID: 4
All the information printed is in String mode Print .
ASR Result: For is the instruction to be received
Wakeup: For wake-up command Other instructions will not print this
Send data len: Number of bytes of data sent
Send uart data: Data sent
ReadmePlay ID: Play the prompt tone ID Number
notes : The data sent and the prompt sound played are usually one-to-one correspondence .
3、 ... and 、ESP-C3-12F End and VB-01 Data interaction
ESP-C3-12F The role of is external MCU, The purpose is to show more intuitively VB-01 The voice recognition function of .
1. Read instructions and parse control
From the previous section VB-01 Print the information to see : There are two ways to identify control :
1. analysis VB-01 Data sent : for example :0xAA 01 00 BB;
2. Analyze the prompt tone ID Number :
Both ways are possible . Bloggers think the second way is easier , And flexible , The first way is more complex , But it will also be more reliable .
There is another reason to choose the second way because ID Number It also represents the prompt tone , And it's a string number , have access to atoi() Function is directly converted to an integer number . ESP-C3-12F Data parsing code :
int uartDataHandle(uint8_t *data)
{
uint8_t *temp;
char *TAG = "uartDataHandle";
int ID_NUM = 0;
temp = data;
if (temp != NULL)
{
temp = (uint8_t *)strstr((const char *)temp, "ID:"); // distinguish “ID:” character string
if (temp != NULL)
{
temp = (uint8_t *)strstr((const char *)temp, ":");// Get string ID The following string number
++temp; // Cross the colon “ : ”
ID_NUM = atoi((const char *)temp); // Put the string ID Convert to integer
ESP_LOGI(TAG, "Cmd ID:%d", ID_NUM);
goto __RETURN_ID;
}
else
goto __RETURN_ID;
}
else
goto __RETURN_ID;
__RETURN_ID:
return ID_NUM;
}
In this way, you can use different prompt tones ID No. 1 does different actions .
2. control VB-01 Play the tone
Sending and receiving play prompt sound instructions are different , Can't send ID Orders VB-01 Play the tone . because VB-01 The program does not receive serial port ID No. to play the prompt sound , It is through a group 4 16 bits of data to control the playback , for example :
unsigned char rcv_uart_buf[RCV_UART_DATA_NUM][RCV_UART_DATA_LEN] =
{
{0xAA, 0x02, 0x00, 0xBB}, // Play the tone BEEP_00
{0xAA, 0x02, 0x01, 0xBB}, // Play the tone BEEP_01
{0xAA, 0x02, 0x02, 0xBB}, // Play the tone BEEP_02
{0xAA, 0x02, 0x03, 0xBB}, // And so on
{0xAA, 0x02, 0x04, 0xBB},
{0xAA, 0x02, 0x05, 0xBB},
{0xAA, 0x02, 0x06, 0xBB},
{0xAA, 0x02, 0x07, 0xBB},
{0xAA, 0x02, 0x08, 0xBB},
{0xAA, 0x02, 0x09, 0xBB},
{0xAA, 0x02, 0x0A, 0xBB},
So the outside MCU Want to control VB-01 When playing the prompt tone , Direct transmission 4 The corresponding 16 bit data is enough ,VB-01 The default control data is the same as the above . Here is ESP-C3-12F control VB-01 Play the relevant code of the prompt tone :
/* control array */
unsigned char beep[][4] = {
{
0xAA, 0x02, 0x03, 0xBB}, // turn on the light
{
0xAA, 0x02, 0x04, 0xBB}, // Turn off the lights
{
0xAA, 0x02, 0x05, 0xBB}, // Turn it green
{
0xAA, 0x02, 0x06, 0xBB}, // Turn it red
{
0xAA, 0x02, 0x07, 0xBB}, // Turn it blue
{
0xAA, 0x02, 0x08, 0xBB}, // Make it purple
{
0xAA, 0x02, 0x09, 0xBB}, // Make it orange
{
0xAA, 0x02, 0x0A, 0xBB}, // Start running
{
0xAA, 0x02, 0x0B, 0xBB}, // Stop running
{
0xAA, 0x02, 0x0C, 0xBB}, // To speed up
{
0xAA, 0x02, 0x0D, 0xBB}, // Deceleration
{
0xAA, 0x02, 0x0E, 0xBB}, // Still running
};
// Control code snippet
switch (RGB_24Bit)
{
case 0XFF00:
uart_write_bytes(UART_NUM_1, beep[2], sizeof(beep[0]));
break;
case 0xFF0000:
uart_write_bytes(UART_NUM_1, beep[3], sizeof(beep[0]));
break;
case 0xFF:
uart_write_bytes(UART_NUM_1, beep[4], sizeof(beep[0]));
break;
case 0XF05308:
uart_write_bytes(UART_NUM_1, beep[6], sizeof(beep[0]));
break;
case 0X8C0BEE:
uart_write_bytes(UART_NUM_1, beep[5], sizeof(beep[0]));
break;
case 0xFFFFFF:
uart_write_bytes(UART_NUM_1, beep[0], 4); // Play : The light has been turned on
break;
case 0x0:
uart_write_bytes(UART_NUM_1, beep[1], 4); // Play : The light has been turned off
break;
default:
break;
}
Four 、 summary
MCU And VB-01 In fact, the communication of is just normal serial communication , You only need to know some string operations to parse data , And make control action . Trust everyone , More attention is not how to control the playback prompt sound , But how DIY Voice commands , Let's say VB-01 distinguish “ Little love students ”, distinguish “ Tmall elves ” Such as instruction , Or some more coquettish voice instructions . Everyone is looking forward to this knowledge . The demo video will be updated to this blog in two days .
This article will be synchronized to the official blog of anxinko Technology :
Welcome to anxinco's official blog :https://aithinker.blog.csdn.net/
Anxin can purchase connection modules : Anxin Keke technology Youbao connection , Pay attention to getting first-hand information
边栏推荐
猜你喜欢
New potential energy of industrial integration, Xiamen station of city chain technology digital summit successfully held
List. How to achieve ascending and descending sort() 2020.8.6
PCI-Express接口的PCB布线规则
Given an array, such as [7864, 284, 347, 7732, 8498], now you need to splice the numbers in the array to return the "largest possible number."
B_ QuRT_ User_ Guide(37)
RE1 attack and defense world reverse
云原生正在吞噬一切,开发者该如何应对?
Explain
B / Qurt Utilisateur Guide (36)
leetcode-520. Detect capital letters -js
随机推荐
Sequence of entity layer, Dao layer, service layer and controller layer
PCB wiring rules of PCI Express interface
Windows set redis to start automatically
LeeCode -- 6. Zigzag transformation
Coreseek: the second step is index building and testing
经纬度PLT文件格式说明
Summary of SQL single table query 2020.7.27
[compilation principle] lexical analysis design and Implementation
13、 System optimization
UE4_ Ue5 combined with Logitech handle (F710) use record
B_QuRT_User_Guide(37)
2022 Season 6 perfect children's model Shaanxi finals came to a successful conclusion
SRM supplier cloud collaborative management platform solution for building materials industry to realize business application scalability and configuration
Illegal behavior analysis 1
ROS2专题(03):ROS1和ROS2的区别【01】
The 19th Zhejiang Provincial College Programming Contest VP record + supplementary questions
B_ QuRT_ User_ Guide(36)
In the field of software engineering, we have been doing scientific research for ten years!
List. How to achieve ascending and descending sort() 2020.8.6
SLAM面试总结