Uncategorized

On Pico, how to feed speaker from MEMS microphone ouput on GPIO pin directly?

Ask Question

Asked yesterday

Modified today

Viewed 51 times

0

Using the Raspberry Pico Pi, how can micropython be used to get the values from a MEMS microphone such as the Adafruit Silicon MEMS Microphone Breakout - SPW2430 link to ada fruit Product ID: 2716.

Can this be connected to a GPIO pin and then in a while true loop read the pin outputs which are then fed into a speaker? Since the breakout board should be returning digital signals then the CPIO pins can be used directly and if so how should it be implemented? If code directly is not provided some overall pseudo code would be great.

Share

EditFollowClose 2Flag

asked yesterday

Vass's user avatar

Vass

11944 bronze badges

 New contributor

  • 1I goggled :How to convert PDM to analog?” and got the following answer: The process of decoding a PDM signal into an analog one is simple: one only has to pass the PDM signal through a low-pass filter. This works because the function of a low-pass filter is essentially to average the signal. – tlfong01 yesterday  
  • 1Have you actually read the link you posted. This device outputs line-level analog. – Milliways yesterday
  • Converting PDM Data to analog – EESE, Asked 1 year, 11 months ago, Viewed 566 times electronics.stackexchange.com/questions/542348/… – tlfong01 yesterday  
  • electronics.stackexchange.com/questions/435996/… – tlfong01 yesterday  
  • There are 60+ PDM Q&A’s in EESE! – tlfong01 yesterday  
  • 1@Vass: It is not clear what sort of audio signal you wish to process. I would suggest to begin with experimenting with the simplest, say 1 kHz: 1k Hz Tone Test Tone – Sonic Electronix youtube.com/watch?v=TbPh0pmNjo8 – tlfong01 yesterday  
  • 1If you agree 1kHz tone signal is good to start with, I would then suggest how to connect the MEMS mic output to a PicoW GPIO pin and count the number of pulses, … – tlfong01 yesterday  
  • 1@tlfong01, that is a great recommendation, do you know the pseudo-code for that in micropython or C? – Vass 21 hours ago
  • 1pseudo code is not specific to any programming language … for example, assign a loop variable – jsotola 18 hours ago 
  • @Vass: Oh yes, I usually start with Chinese in my little head, then broken English, then pseudo code, then perhaps microPython, … – tlfong01 10 hours ago  
  • Let me first brainstorm a preliminary project spec, you counter suggest something, then we together scratch the pseudo code. – tlfong01 10 hours ago  
  • First thing first, our dream spec is a human speech recognition device: (1) Stupid human speaks to MEMS mic which outputs PDM signal fed to any PicoW GPIO pin. (2) For prototyping, we can perhaps start with two signals: (a) 1k tone, (b) 2k tone, … – tlfong01 10 hours ago  
  • picoW would would say, continuously count the bits per second. If count is a multiple of 1,000, then it should be 1kHz. If a multiple of 2,000, then it should be a 2k tone. Of course it is, as the Chinese saying goes, just first step of a one thousand miles long journey, … – tlfong01 10 hours ago  
  • I bought a couple of MEMS mic’s from TaoBao sometime ago (MP34DT01 麦克风模块 PDM MEMS Microphone ¥25.00), but I could no longer find them in my junk bin, item.taobao.com/…. Perhaps I would try harder searching, … – tlfong01 10 hours ago   
  • 1This whole exchange reminds me of my time as an engineering manager. I had a number of young engineers working for me. They loved solving problems (they reminded me of puppies with a ball) BUT they never actually defined the problem they were trying to solve. – Milliways 10 hours ago
  • I googled another reference: PDM — Pulse density modulation interface – NordicSemi infocenter.nordicsemi.com/… – tlfong01 6 hours ago  

Add a comment

1 Answer

Sorted by:

Reset to default                                              Highest score (default)                                                                   Date modified (newest first)                                                                   Date created (oldest first)                              

0

Question

How can PicoW read MEMS digital microphone output?


Answer

Introduction

1. Overview.

We can connect the MEMS microphone output pin to a PicoW GPIO pin and read signal, into a list for later processing.


2. Simulation

For prototyping, we can simulate the microphone output signal as a GPIO output pin connected blinking LED, and use another GPIO input pin to read the blinking LED pin.


3. / to continue, …


References

(1) Adafruit PDM Microphone Breakout 1

(2) Adafruit PDM Microphone Breakout 2

(3) AliExpress Digital MP34DT01 Microphone Module Simple Pulse Density Modulation Output PDM Digital MEMS Microphone Module – HK$27

(4) TaoBao MP34DT01 MEMS PDM Microphone – ¥25


Appendices

Appendix A – MicroPython program blinking two LEDs simulating two MEMS digital microphone output signals

# Pico W Blink Two LEDs - tlfong01 2023jan01hkt1941

# *** Modules ***
import machine
from machine import Pin, Timer

# *** Configuration***
redLed      = Pin(0, Pin.OUT)
greenLed    = Pin(1, Pin.OUT)

redFreq     = 2
greenFreq   = 4

redTimer    = Timer()
greenTimer  = Timer()

# *** Callbacks ***
def blinkRedLed(dummy):
    redLed.toggle()
    return

def blinkGreenLed(dummy):
    greenLed.toggle()
    return

# *** Main ***
redTimer.init(freq = redFreq, mode = Timer.PERIODIC, callback = blinkRedLed)
greenTimer.init(freq = greenFreq, mode = Timer.PERIODIC, callback = blinkGreenLed)

# *** End of program ***


Appendix B – Blinking LEDs Video

PicoW blinking two LEDS


Share

EditDeleteFlag

edited 4 mins ago

answered 29 mins ago

tlfong01's user avatar

tlfong01

4,45433 gold badges99 silver badges2424 bronze badges

Add a comment

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.