2

I’d like to try using my voice as an input to my Pico. I think I should be able to define a pair of one-word voice commands, and train a Tensor Flow Lite Micro for Pico model on them.

What I can’t figure out is if I can connect a microphone to the Pico. I hope it might be possible to connect a small mic through the ADC GPIO pins, but I’m uncertain and my research has no conclusive answer, one way or the other.

Any thoughts on viability, or suggestions for making it a reality, would be much appreciated. Thanks in advance

3
  • 1
    I think this sort of question would be more appropriate on the raspberrypi.org/forums
    – joan
    Apr 18, 2021 at 21:08
  • 1
    I would look at using a MEMS microphone with a digital output, rather than struggle with analogue input. I believe that it has already been done and documented. Save analogue input for signals with low dynamic range.
    – Mick
    Apr 19, 2021 at 3:42
  • did you manage to connect a microphone to the pi?
    – user17915
    Aug 31, 2021 at 5:50

2 Answers 2

2

Yes, you can actually hook up an analog electret mic and use Pi Pico's inbuilt ADC to convert to Digital values. Then you need to convert those PCM values to suitable PDM values which can be fed into the feature provider.

Because it has DMA, no CPU cycles are wasted to access mic data from ADC. I read somewhere that we can sample up to 0.5 MHz using the built-in ADC !! a lot more than we need - 16khz.

1
  • how is convert those PCM values to suitable PDM values done? From the software stage are the PCM values not already digitized? Or is a software preprocessing needed? If the microphone already outputs PDM then can any GP pins be used?
    – Vass
    Dec 26, 2022 at 15:58
2

I think this blog post details almost exactly what you want to do.

They connect an analogue microphone to one of the ADC pins on the pico. The ADC then samples the raw voltage from the analogue microphone and places the digitised data (i.e. audio data) into a ring buffer. They then run a TensorFlow model on one of the RP2040 cores, which continuously extracts data from the ring buffer and processes it in (near) real time. So as long as the processing data through the TnesorFlow model can keep up with the audio data from the ADC then yes, it is very possible.

4
  • which are the ADC pins on the pico? I can only see 3 of those on my pico sheet, GP26, GP27, GP28 as ADC0, ADC1 and ADC2. So those pins abstract away the analogue so I can use them as digital in software?
    – Vass
    Dec 26, 2022 at 15:55
  • 1
    Note sure I understand your question? The ADC pins depend on the board model (but usually 26, 27, 28) and are on the datasheet - the ADC converts an analogue signal into a digital signal at a sample rate up to 500,000 samples per second. This means that the ADC on the pico can digitise signals with frequencies up to 250kHz. Dec 31, 2022 at 8:02
  • great, and this happens automatically? Does anything need to be coded in micropython or via the C SDK to make that work? And, the 'state' of the pin value can be read through a while loop right?
    – Vass
    Dec 31, 2022 at 15:32
  • 1
    Not sure I understand? Everything needs to be coded in C or Python to work? Please see the blog post link above for example C code. Jan 10 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.