Raspberry Pi PICO Impulse deployment with external MIC

I made a completed impulse that I am looking to deploy to my PICO. I initially build the impulse to a UF2 file to drag onto the PICO. This worked and Using the CMD I was able to pull up the impulse. However, it did not seem that it was getting any data from my microphone.
Now backstory the Pico does not have an onboard MIC. So, when I created the impulse, I had to edit the PDM firmware file to get the onboard mic option to work with an external PDM mic.
I am assuming now that I have built my impulse this data again will need to be updated before it is deployed. I also would like to light up two Leds depending on the state of my sound detected.

So could anyone help me locate where I need to edit the C++ files or is there an option to select this before building the code?

Hello @BJOHN159,

The sampling strategy and the “business logic” has to be implemented by you or your team.
What you can get is a C++ library that can be imported in your project.

If you prefer to start from an example, you can either use the standalone examples:

You can then edit the source/main.cpp file to add your logic.

Or you can also have a look at the “official firmware” that we provide, this one is a bit more complex to get started but feel free to try modifying this one to match your needs:

Best,

Louis

I think I see now. I actually edited the firmware file from the “official firmware” that you provide. I see now it has a tflite-model folder. When I download my C++ code for my trained model, I’m assuming I just copy this data into this folder. Edit the main.cpp to trigger my LED’s and rebuild to a new UF2 file and upload to the board. Is this correct logic?
Thanks again.

Correct.

You’ll also need to add the microphone part.
And add your LED logic after your inference results.

Best,

Louis

Started messing with this today, do you know of any example code of using the microphone and initializing everything in main.cpp?

I included #include “ei_microphone.h”
now I am not exactly sure where the rest of the code needs to go.
image
It is my assumption I will need to call each of these functions in the screenshot I provided in the ei_init function in main.cpp.
If I call these functions then I am not sure how to get the pdm data into my impulse.

I see too if I have edge impulse generate the ready to go UF2 file and upload it to my board it is running the impulse with a microphone, but it appears it is not getting any data in. I suspect this is because of the incorrect PDM library. @louis do you know if it is possible to get access to the main.cpp file of the Raspberry Pi Pico deployment firmware for the audio for me to then base my logic state code off of?

Hello @BJOHN159,

I would start by modifying this example which is easier to understand:

From there I’d put all my logic first to the main.cpp (eventually add your custom microphone library so you can grab the data and pass the raw data to the inference buffer.

Best,

Louis