Is there examples for CubeMX library?

I’ve downloaded cubeMX library for STM32L475vg to recognize voice, but i didn’t found any demo or examples to achieve this function.
I want know if there is an example like Arduino Library given named “nano_ble33_sense_microphone” or similar for cube mx?
Thanks for helping me!


So for STM devices we do target the STM32L with firmware that you can download pre-compiled or build from here, but as I think you are saying this is done outside of CubeMX.

For working within CubeMX, our main resource is this guide, which takes you step by step to integrate your generated library with a CubeMX project.

Is this in-line with what you are looking for?


I need to use the other sensor on the device, and recognize voice in the same time.

For example, the arduino library offered some examples so that I can modify the code to use the other sensors

So I want to get an sample code(not a .bin file) that can run voice classify automatically(I don’t know how to call the microphone and recognize), and I can edit the code to realize other functions.
Then I downloaded the CubeMX library.
But the guide just let me to copy raw features from website and paste it in the main() function, still I don’t know how to make it run automatically…

Please forgive me for not being clear enough!

Ah I see thanks for the clarification. Right so the CMSIS library doesn’t have those pre-set examples, mainly because cubemx projects are pretty large and exist on top of the pack itself, but you’ll absolutely still be able to do this in your application, since you can control how data is input into neural network and also when inference gets run.

For a brief example of this in source code, if you look at our stm32 firmware, you’ll see that we directly handle the inferencing loop in this run_nn method. The edge-impulse calls here that obtain a signal and then run inference are all intended to be called in application level logic by the user, and you can freely interlace them with other app logic.

This is the same flow of the while loop shown in the cubemx tutorial (code snippet pasted below for reference). What you’ll want to do is follow the tutorial to get a minimal working cubemx project that runs EI inference, and then add your logic to get input from the other sensor inside the main loop.

// example of minimal main loop for STM32 projects, adapted from
while (1)
    signal_t signal;
    signal.total_length = sizeof(features) / sizeof(features[0]);
    // For signal input, look for the STM HAL drivers with EI wrappers for pre-made input from mic
    // Alternatively if using your own driver, provide its get data method here
    signal.get_data = &ei_microphone_audio_signal_get_data 
    ei_impulse_result_t result = { 0 };
    EI_IMPULSE_ERROR res = run_classifier(&signal, &result, true);

    // Add application logic here. Use the result of inference, sample other sensors, ETC.
1 Like

I don’t know how to start microphone in CubeMX
So I’ve checked the firmware on github, and I copied the code to CubeMX, but plenty of errors occurd, for example “mbed.h” not found. Then I downloaded Mbed studio to open the firmware project downloaded from github, also occured some errors. Like the screenshot shows:

I don’t know what to do next…
I just need it use its own microphone to classify voice and add some functions

Hi @zhongrui,

Our firmware uses mbed so it will not compile within the STM32Cube IDE.

If you’re more comfortable with mbed, I’d suggest following the README in the github project to start with:, we use the GNU ARM toolchain to compile the firmware.

If you know STM32Cube better, then you can follow our CubeMX tutorial as mentioned by @daschwar, and then add the driver for your microphone.

What kind of microphone are you using? @ShawnHymel has developed STM32 examples for I2S mic that could be useful:



I’m using STM32L475VG, its microphone is MP34DT01

Quickest way would be to use - it already has everything setup, including driver code for the microphone and inference code, just in Mbed (but you have STM32HAL available there). Then:

  1. Call run_nn_continuous_normal() directly from int main() to have inference running continuously from the start of the application rather than booting into the AT command firmware.
  2. Add some handling logic here for the output:

And done.

I modified some code , and then the serial shows this when using run_nn:

You have a different Mbed OS version. Run this:

rm -rf mbed-os
mbed deploy

To get the right one.

I made a lot of changes of the code in the two days, it finally works!

Thank you guys, you are all very nice