Teensy 4.1 MEMS INMP441

Menne

Member
Hi, I know the MEMS has been discussed in many threads, but after some days of work i'm still not able to get the basics right.

I tried many configurations (with and without audio shield) with i2s1 with ports (21,20 and 8) and with i2s2 with ports (3,4, and 5). I used the INMP44 and the Adafruit SPH0645. I have an ESP32 working with the INM441, but not with the right quality. I finally, tested the Teensy4.1 with a simple example, but I always get the same strange output from the MEMS SD port.

The oscilloscope shows high values at the MSBs even when I'm quite. I use a simple code and I get rubbish RMS values between 60 and 70 regardless the sound level.

In this example the BCLK (1.4MHz) and LRCLK (44.1kHz) seems to be fine, but the SD is doing strange. In this case the used i2s1.

When using i2s2_1 in the code, I do not get any clock signal on 21 en 20.
 

Attachments

  • IMG_6067.jpg
    IMG_6067.jpg
    56.7 KB · Views: 56
  • IMG_6068.jpg
    IMG_6068.jpg
    63 KB · Views: 55
  • teensy41mems.ino
    729 bytes · Views: 60
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>

AudioInputI2S            i2s1;           
AudioAnalyzeRMS          rms1;
AudioAnalyzeRMS          rms2;
AudioConnection          patchCord1(i2s1, 0, rms1, 0);
AudioConnection          patchCord2(i2s1, 1, rms2, 0);

void setup() {
  Serial.begin(9600);
  AudioMemory(4);
  delay(1000);
}

void loop() {
  if (rms1.available() && rms2.available())  {
    
        float volume_level_l = rms1.read() * 100.0;
        float volume_level_r = rms2.read() * 100.0;

        Serial.print("Volume level L: ");
        Serial.println(volume_level_l);

        Serial.print("Volume level R: ");
        Serial.println(volume_level_r);
        Serial.println();
  }
 
}
 
I tried the code on a Teensy 4.0 first without audio shield and on i2s2_1 and it worked and successfully used it on the Teensy 4.1 with audio shield. Not sure what caused the continuously high MSB bits on the oscilloscope.
 
The oscilloscope shows high values at the MSBs even when I'm quite
Normal - the output is 2's complement so even a small offset can lead all samples to be negative during a quiet patch (or all positive, or a mixture, luck of the draw).
 
The I2S MEMS microphone (especially the one from Adafruit ( SPH0645LM4H)) can have significant negative offset resulting in always negative values (MSB always set). I use ICS-43434 microphones, that have nearly no offset. You can get them e.g. from https://www.tindie.com/stores/onehorse/.
 
Put in a high-pass filter if DC offset is an issue? Some I2S sources are already high pass filtered and some are not, just like real audio signals :)
 
Back
Top