Intermediate
30 min

Make hands-free control with VC-02 and PIC32MX534F064H

Control your device using speech

SpeakUp 3 Click with PIC32MX clicker

Published Feb 28, 2023

Click board™

SpeakUp 3 Click

Development board

PIC32MX clicker

Compiler

NECTO Studio

MCU

PIC32MX534F064H

Pure offline speech recognition solution

A

A

Hardware Overview

How does it work?

SpeakUp 3 Click is based on the VC-02, an offline voice recognition AI module from Ai-Thinker Technology, characterized by high reliability and robust versatility. The VC-02 module uses an integrated voice chip US516P6 from Unisound, which continuously optimizes and innovates algorithms in speech recognition technology. The offline recognition algorithm is deeply integrated with the chip architecture, providing customers with an ultra-low-cost offline voice recognition solution. This board can be widely and quickly applied to all smart small household appliances and products requiring voice control. The US516P6 chip uses a 32-bit RSIC architecture core, running at 240MHz, and incorporates a DSP instruction explicitly set for signal processing and speech recognition, an FPU arithmetic unit that supports floating-point operations, and an FFT accelerator (support 1024-point complex FFT/IFFT operations, or 2048-point real FFT/IFFT operations). What makes this module unique are features like

offline identification of 150 local instructions and self-learning of wake-up words, RTOS lightweight system, 90% recognition rate in a far field distance from 1 up to 5m, firmware update feature, as well as the selection of the communication method with the module. This Click board™ comes with a configurable host interface allowing communication with MCU using the chosen interface. The VC-02 can communicate with MCU using the UART interface, a default communication interface with commonly used UART RX and TX pins, and a default baud rate of 115200bps. Users can also use other interfaces, such as SPI and I2C, to configure the module and write the library by themselves. At the center of the SpeakUp 3 Click, an additional unpopulated header offers full support for debugging and programming capabilities. The Ai-Thinker has provided its users with a VC series development page. With a simple registration, they can create

their own command list/SDK/firmware for this module quickly and easily for free. With this header, the user can use a JTAG interface, in addition to the UART interface, for programming and debugging available through the JTAG interface pins (TCK and TMS). For more information and help when creating custom firmware, you can contact their help center. A special addition to this Click board™ are connectors, marked as MIC and SPK, for an analog omnidirectional microphone and 8Ω 2W cavity speaker from Shenzhen Anxinke Technology. These parts can be found in the same package as the Click board or can be acquired as a solo version in our shop. This Click board™ can only be operated with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. However, the Click board™ comes equipped with a library containing functions and an example code that can be used as a reference for further development.

SpeakUp 3 Click top side image
SpeakUp 3 Click lateral side image
SpeakUp 3 Click bottom side image

Features overview

Development board

PIC32MX Clicker is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC32 microcontroller, the PIC32MX534F064H from Microchip, a USB connector, LED indicators, buttons, a mikroProg connector, and a header for interfacing with external electronics. Thanks to its compact design with clear and easy-recognizable silkscreen markings, it provides a fluid and immersive working experience, allowing access

anywhere and under any circumstances. Each part of the PIC32MX Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the PIC32MX Clicker programming method, using USB HID mikroBootloader, or through an external mikroProg connector for PIC, dsPIC, or PIC32 programmer, the Clicker board also includes a clean and regulated power supply module for the development kit. The USB Mini-B connection can provide up to 500mA of current, which is more

than enough to operate all onboard and additional modules. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several buttons and LED indicators. PIC32MX Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

PIC32MX clicker double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

64

Silicon Vendor

Microchip

Pin count

64

RAM (Bytes)

16384

You complete me!

Accessories

Microphone with PH2.0 female connector is an analog-type omnidirectional electret microphone, an electrostatic capacitor-based microphone, and is available with a lead terminated in a PH2.0 female connector. This microphone eliminates the need for a polarizing power supply by using permanently-charged material. With operating frequencies ranging from 100 to 20.000Hz, the microphone features sensitivity ratings as low as -40dB (±3) and signal-to-noise ratios from 57 to 70dBA (typical 60dBA). Housed in a compact package with diameters as small as 6mm, this omnidirectional microphone is ideally suited for various high-quality recordings in industrial and outdoor applications where moisture and environmental contaminants are present.

SpeakUp 3 Click accessories 1 image

Speaker with PH2.0 female connector is an 8Ω 2W portable all-in-one passive cavity speaker available in wire-lead mount configuration with a PH2.0 female connector with an operating frequency of 100kHz. This speaker is characterized by a long service life based on excellent build-material and technology, which enhance its service life, making it convenient and reliable. It is also built on strict quality control standards (design improved for more durability) with a low distortion rate, keeping the sound stable (clear sound quality providing superb music reproductions). Housed in a compact package with dimensions of 40×20×5.8mm (LxWxH), this cavity loudspeaker offers stable performance ideally suited for various audio-producing applications in consumer, medical, security, and many more.

SpeakUp 3 Click accessories 2 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
NC
NC
CS
SPI Clock
RG6
SCK
SPI Data OUT
RG7
MISO
SPI Data IN
RG8
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
UART TX
RB14
TX
UART RX
RB8
RX
I2C Clock
RF5
SCL
I2C Data
RF4
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

SpeakUp 3 Click Schematic schematic

Step by step

Project assembly

PIC clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the PIC32MX clicker as your development board.

PIC clicker front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Mini B Connector Clicker Access - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Necto_MCU_Select_PICPLC16 hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.

Application Output Step 3

Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.

Application Output Step 4

Software Support

Library Description

This library contains API for SpeakUp 3 Click driver.

Key functions:

  • speakup3_generic_read This function reads a desired number of data bytes by using UART serial interface.

  • speakup3_wait_for_reply This function waits up to @b wait_ms for a reply to the voice command.

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * @file main.c
 * @brief SpeakUp 3 Click Example.
 *
 * # Description
 * This example demonstrates the use of the SpeakUp 3 click board by reading
 * and displaying the voice commands reply messages.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes driver and logger.
 *
 * ## Application Task
 * Waits for the reply message to a voice command and displays it on the USB UART.
 *
 * ## Additional Function
 * - static void speakup3_display_reply ( void )
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "speakup3.h"

static speakup3_t speakup3;
static log_t logger;

/**
 * @brief SpeakUp 3 display reply function.
 * @details This function displays on the USB UART the reply message for the selected
 * reply instruction code.
 * @param[in] reply_ins : Reply instruction code.
 * @return None.
 * @note None.
 */
static void speakup3_display_reply ( uint8_t reply_ins );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    speakup3_cfg_t speakup3_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    speakup3_cfg_setup( &speakup3_cfg );
    SPEAKUP3_MAP_MIKROBUS( speakup3_cfg, MIKROBUS_1 );
    if ( UART_ERROR == speakup3_init( &speakup3, &speakup3_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    uint8_t reply_ins;
    if ( SPEAKUP3_OK == speakup3_wait_for_reply ( &speakup3, &reply_ins, 1000 ) )
    {
        speakup3_display_reply ( reply_ins );
    }
}

void main ( void ) 
{
    application_init( );

    for ( ; ; ) 
    {
        application_task( );
    }
}

static void speakup3_display_reply ( uint8_t reply_ins )
{
    log_printf( &logger, " Reply: " );
    switch ( reply_ins )
    {
        case SPEAKUP3_INS_ENTER_WAKE_UP:
        {
            log_printf( &logger, "Hi, how can I help? / Hi, what's up? / Yes, I'm here.\r\n" );
            break;
        }
        case SPEAKUP3_INS_EXIT_WAKE_UP:
        {
            log_printf( &logger, "See you later.\r\n" );
            break;
        }
        case SPEAKUP3_INS_LEARN_MATCH_AC:
        {
            log_printf( &logger, "OK, match the air conditioner.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TURN_ON:
        {
            log_printf( &logger, "OK, turn on the air conditioner.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TURN_OFF:
        {
            log_printf( &logger, "OK, turn off the air conditioner.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_MODE_AUTO:
        {
            log_printf( &logger, "OK, automatic mode.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_MODE_COLD:
        {
            log_printf( &logger, "OK, cold mode.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_MODE_HEAT:
        {
            log_printf( &logger, "OK, heat mode.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_MODE_DRY:
        {
            log_printf( &logger, "OK, dry mode.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_MODE_FAN:
        {
            log_printf( &logger, "OK, fan mode.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_MODE_SLEEP:
        {
            log_printf( &logger, "OK, sleeping mode.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_WIND_AUTO:
        {
            log_printf( &logger, "OK, automatic fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_WIND_LOW:
        {
            log_printf( &logger, "OK, low fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_WIND_MID:
        {
            log_printf( &logger, "OK, medium fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_WIND_HIGH:
        {
            log_printf( &logger, "OK, high fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_WIND_INC:
        {
            log_printf( &logger, "OK, higher the fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_WIND_DEC:
        {
            log_printf( &logger, "OK, lower the fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_16:
        {
            log_printf( &logger, "OK, sixteen centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_17:
        {
            log_printf( &logger, "OK, seventeen centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_18:
        {
            log_printf( &logger, "OK, eighteen centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_19:
        {
            log_printf( &logger, "OK, nineteen centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_20:
        {
            log_printf( &logger, "OK, twenty centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_21:
        {
            log_printf( &logger, "OK, twenty one centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_22:
        {
            log_printf( &logger, "OK, twenty two centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_23:
        {
            log_printf( &logger, "OK, twenty three centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_24:
        {
            log_printf( &logger, "OK, twenty four centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_25:
        {
            log_printf( &logger, "OK, twenty five centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_26:
        {
            log_printf( &logger, "OK, twenty six centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_27:
        {
            log_printf( &logger, "OK, twenty seven centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_28:
        {
            log_printf( &logger, "OK, twenty eight centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_29:
        {
            log_printf( &logger, "OK, twenty nine centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_30:
        {
            log_printf( &logger, "OK, thirty centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_INC:
        {
            log_printf( &logger, "OK, warmer.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_DEC:
        {
            log_printf( &logger, "OK, cooler.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_SWEPT_ON:
        {
            log_printf( &logger, "OK, start to fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_SWEPT_OFF:
        {
            log_printf( &logger, "OK, stop to fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_SWEPT_VERT:
        {
            log_printf( &logger, "OK, air swing up and down.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_SWEPT_CROSS:
        {
            log_printf( &logger, "OK, air swing left and right.\r\n" );
            break;
        }
        case SPEAKUP3_INS_SET_RESTORE:
        {
            log_printf( &logger, "OK, air conditioner reset.\r\n" );
            break;
        }
        default:
        {
            log_printf( &logger, "Unknown.\r\n" );
            break;
        }
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources