Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Simple I2S input with INMP441 Microphone

  1. #1
    Junior Member
    Join Date
    Dec 2019
    Posts
    12

    Simple I2S input with INMP441 Microphone

    Im working on a project that needs a microphone input that i would like to do a FFT analysis on.
    Im using a teensy 4.0 but dont have an audio shield. I cant seem to find much documentation on the audio library for teensy 4.0 and i dont quite understand how the I2S protocol works.
    Is there a simple way to hook up only the microphone to the teensy 4.0 and get the audio output in the sketch? like a .read() function or similar to get the current microphone value?

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,762
    You've found the Audio lib design tool? Just click on the I2S input object and it gives documentation including I2S pinouts for T3.x and T4.x

    For FFT docs click on the fft256 or fft1024 objects in the analyze section.

    For an arbitrary I2S device just ensure its running in slave mode and connect BCLK/MCLK/DOUT/LRCLK plus power and ground - should just work.
    Note that the INMP441 doesn't have MCLK so you don't connect that line. The datasheet names BCLK,DOUT,LRCLK as SCK,SD,L/R note.

    When using the audio lib I'd suggest starting with on of the example sketches, then you won't forget something important like the call to AudioMemory()

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,799
    Except for the specific pins where you connect the 3 signals, this is identical on Teensy 4.0 and 3.2. So please keep in mind anything you find about Teensy 3.x applies to Teensy 4.0 too. They work the same way. For this particular use, the only difference is which pins get the I2S signals. Both are shown on the I2S input documentation in the design tool (right side panel, scroll down to hawrdware).

    https://www.pjrc.com/teensy/gui/?info=AudioInputI2S

    You'll see one column says "T3.X Pin" and the other is "T4.X pin". This is the sort of documentation published for Teensy 4.0. When everything else is the same for all supported boards, the documentation doesn't specifically mention Teensy 4.0. In places like thing pinouts, the boards are mentioned.


    like a .read() function or similar to get the current microphone value?
    That's not how it works. Reading each sample and trying to keep up at 44100 Hz while also doing other work is extremely difficult. The audio library is designed to let you easily build reliable processing that keeps up with the audio rate even if your program does other work. The high speed processing happens entire within the library.

    Check out this 31 page tutorial. Turn to page 24 for how to do FFT analysis. You will probably need to read pages 8-11 first to learn how the design tool works.

    Again, don't let the mention of Teensy 3.x frighten you. Teensy 4.0 did not exist when this tutorial was written. But again, except for the specific pins, it all applies to Teensy 4.0. The audio library works the same way.

    Also in the tutorial you will see the audio shield in every example. The use a MEMS mic, just connect it to the I2S pins instead of the audio shield, and delete any code which configures the SGTL5000 chips. Those MEMS mics don't use any config, as they have no settings or options to control. You just turn on the I2S hardware and they transmit data.

    While it might be overkill, you might click File > Examples > Audio > HardwareTesting > Microphones > SPH0645 to see an example for one of the hardest-to-use MEMS mics. Most of them don't have the DC offset issue of SPH0645, so you probably don't need that filter and maybe not the amp either.

  4. #4
    Junior Member
    Join Date
    May 2022
    Posts
    5

    Wish to connect I2S microphone and use AUDIO SHIELD for headphones output

    Quote Originally Posted by PaulStoffregen View Post
    The use a MEMS mic, just connect it to the I2S pins instead of the audio shield, and delete any code which configures the SGTL5000 chips. Those MEMS mics don't use any config, as they have no settings or options to control. You just turn on the I2S hardware and they transmit data.

    While it might be overkill, you might click File > Examples > Audio > HardwareTesting > Microphones > SPH0645 to see an example for one of the hardest-to-use MEMS mics. Most of them don't have the DC offset issue of SPH0645, so you probably don't need that filter and maybe not the amp either.

    High Paul,
    My intention is to use a I2S MEMS microphone as input and to hear the audio captured signal in headphones using the output of AUDIO SHIELD ( to benefit also of SGTL5000 output capabilities). As I understood from you post, it would be possible to use SPH0645 / INMP441 or compatible I2S format microphone. Is it OK to cut the SGTL5000 Rx/Dout connection to Teensy 4.0 pin 8 and connect the Data line of the I2S microphone to Teensy 4.0 pin 8 ? I already tried this using the MSM261S4030H0 microphone but it didn't work (https://forum.pjrc.com/threads/70270...2s+microphone). Thanks a lot for your support.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,799
    Easiest way is to use I2S2 for the mic.

    https://www.pjrc.com/teensy/gui/?info=AudioInputI2S2

    Then just connect its 3 wires to pins 4, 5, 3 which aren't used at all by the audio shield.

  6. #6
    Junior Member
    Join Date
    May 2022
    Posts
    5
    Thanks Paul for your fast answer. I will buy an INMP microphone and I will test your solution.

  7. #7
    Junior Member
    Join Date
    May 2022
    Posts
    5
    Quote Originally Posted by PaulStoffregen View Post
    Easiest way is to use I2S2 for the mic.

    https://www.pjrc.com/teensy/gui/?info=AudioInputI2S2

    Then just connect its 3 wires to pins 4, 5, 3 which aren't used at all by the audio shield.
    Thanks Paul... I bought a PDM microphone ( IM69D130 INFINEON, SNR= 65 dB !!! ) and I used Stereo PDM-to-I2S Conversion IC ( ADAU7002 ). It worked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •