Use of I2S digital MEMS for streaming via USB

WHG2023

Member
My goal is to store high-quality audio (at least 16 bit, 16 kHz) via USB on my Windows PC, captured by a digital I2S MEMS microphone (I use the models INMP441 and SPH0645) and a Teensy 4.1 (or 4.0). I have not succeded with Arduino examples that use the serial port. I am a biotechnologist, eager to learn about audio engineering.
 
If you're not familiar with audio on Teensy, this tutorial is the place to start.

https://www.pjrc.com/store/audio_tutorial_kit.html

To save time, you might just skip forward to page 8 to learn about using the design tool. You can also find a full walkthrough video on that page, if you prefer to watch a demo.

To send I2S from the mic to USB on your PC, you would use this:

screenshot.png

Before uploading from Arduino, set Tools > USB Type to Audio, so Teensy will become a USB sound card when your program runs.

The SPH0645 mic has some special issues. To see an example that shows how to deal with SPH0645, in Arduino (with Teensy selected) click File > Examples > Audio > HardwareTesting > Microphones > SPH0645.
 
Thank you for the fantastic help. Since I just started to consume the information: Is it correct that I require the Audio Shield to achieve my beforementioned goal?
 
Thank you for the fantastic help. Since I just started to consume the information: Is it correct that I require the Audio Shield to achieve my beforementioned goal?

No, connect I2S MEMS directly to Teensy replacing the Audio shield.

Run the following program
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputI2S            i2s1;           //xy=291.04747009277344,174.0625
AudioOutputUSB           usb1;           //xy=521.0474700927734,174.0625

AudioConnection          patchCord1(i2s1, 0, usb1, 0);
AudioConnection          patchCord2(i2s1, 1, usb1, 1);

// GUItool: end automatically generated code

void setup() {
  // put your setup code here, to run once:
  AudioMemory(12);
}

void loop() {
  // put your main code here, to run repeatedly:

}
that should stream data to PC
The codes is from GUI Paul has shown
The only additional line is the AudioMemory one in setup().
No more coding is needed.

HOWEVER,
if you are not happy with volume of your microphone, you will need some coding.
 
Thanks a lot! I have connected the SPH0645 and uploaded the code from above. I do not see a normal signal after uploading and checking in Audacity. When I normalize the signal, I see a periodic pattern with a periodicity of ~93ms (reminds me of the "magic eye" books...). I will continue reading the documentation and try to figure out what the issue might be.


Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputI2S            i2s1;           //xy=291.04747009277344,174.0625
AudioOutputUSB           usb1;           //xy=521.0474700927734,174.0625

AudioConnection          patchCord1(i2s1, 0, usb1, 0);
AudioConnection          patchCord2(i2s1, 1, usb1, 1);

// GUItool: end automatically generated code

void setup() {
  // put your setup code here, to run once:
  AudioMemory(12);
}

void loop() {
  // put your main code here, to run repeatedly:

}


Spectrogram of Audacity recording:
t_sph_audio.JPG

Connections of T4.1 and SPH0645
t_sph.JPG
 
Last edited:
I accidentally used pin 22 for the BCLK signal. That's excellent help. Thanks so much!

I would like to test different sensor-to-T4.1 cable lengths/qualities to see how these factors affect signal transmission. Are there any usefeul references for analog vs digital (PDM vs. I2S) signals?
 
Are there recommendation with regard to cable qualities and cable lengths for connections between a Teensy and a analog or digital MEMS PCB?
 
The "I2" part of I2S and I2C stands for Intra-Integrated circuit.

I2S isn't really meant to be used over any sort of cable. It's meant to connect between chips on the same printed circuit board, or perhaps an assembly of multiple circuit boards connected in close proximity by header pins or other board-to-board connectors. That's why it's name starts with "I2".

I'm not aware of any specific requirement on the PCB trace length, though all the usual aspects of digital logic come into play (propagation delays, setup and hold times, characteristic impedance & signal quality) if you attempt a non-straightforward design, especially if adding buffer chips and long wires.

This PDF is the official spec.

https://www.nxp.com/docs/en/user-manual/UM11732.pdf
 
Back
Top