Infineon Team
Published © MIT

I2S MEMS Microphone IM69D130 for Arduino MKR & Infineon XMC

Connect our I2S MEMS Microphone to an XMC4700 Relax Lite Kit, XMC2Go or Arduino MKR WiFi 1010.

BeginnerProtip1 hour2,144
I2S MEMS Microphone IM69D130 for Arduino MKR & Infineon XMC

Things used in this project

Hardware components

S2GO MEMSMIC IM69D MEMS Microphone
Infineon S2GO MEMSMIC IM69D MEMS Microphone
×1
KIT XMC47 RELAX LITE V1
Infineon KIT XMC47 RELAX LITE V1
×1
XMC2GO - industrial microcontroller kit
Infineon XMC2GO - industrial microcontroller kit
×1
Arduino MKR WiFi 1010
Arduino MKR WiFi 1010
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long

Story

Read more

Schematics

Arduino MKR WiFi 1010 with Infineon IM69D130 Mems Microphone

XMC4700 Relax Lite Kit with Infineon IM69D130 Mems Microphone

S2Go MEMS IM69D130 Fritzing file

Fritzing file of Infineons S2Go MEMS IM69D130

XMC2Go with Infineon IM69D130 Mems Microphone

Code

Arduino MKR WiFi 1010 - IM69D130 Microphone Shield2Go | Sound pressure level

Arduino
Full code for Arduino MKR WiFi 1010 and MEMS Microphone Shield2Go.
Copy and paste it into an Arduino IDE sketch and flash it to your board.
/*
 This example reads audio data from an Invensense's ICS43432 I2S microphone
 breakout board, and prints out the samples to the Serial console. The
 Serial Plotter built into the Arduino IDE can be used to plot the audio
 data (Tools -> Serial Plotter)

 Circuit:
 * Arduino/Genuino Zero, MKRZero or MKR1000 board
 * ICS43432:
   * GND connected GND
   * 3.3V connected 3.3V (Zero) or VCC (MKR1000, MKRZero)
   * WS connected to pin 0 (Zero) or pin 3 (MKR1000, MKRZero)
   * CLK connected to pin 1 (Zero) or pin 2 (MKR1000, MKRZero)
   * SD connected to pin 9 (Zero) or pin A6 (MKR1000, MKRZero)

 created 17 November 2016
 by Sandeep Mistry
 */

#include <I2S.h>

void setup() {
  // Open serial communications and wait for port to open:
  // A baud rate of 115200 is used instead of 9600 for a faster data rate
  // on non-native USB ports
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start I2S at 16 kHz with 32-bits per sample
  if (!I2S.begin(I2S_PHILIPS_MODE, 16000, 32)) {
    Serial.println("Failed to initialize I2S!");
    while (1); // do nothing
  }
}

#define SAMPLES 128 // make it a power of two for best DMA performance

void loop() {
  // read a bunch of samples:
  int samples[SAMPLES];

  for (int i=0; i<SAMPLES; i++) {
    int sample = 0; 
    while ((sample == 0) || (sample == -1) ) {
      sample = I2S.read();
    }
    // convert to 18 bit signed
    sample >>= 14; 
    samples[i] = sample;
  }

  // ok we hvae the samples, get the mean (avg)
  float meanval = 0;
  for (int i=0; i<SAMPLES; i++) {
    meanval += samples[i];
  }
  meanval /= SAMPLES;
  //Serial.print("# average: " ); Serial.println(meanval);

  // subtract it from all sapmles to get a 'normalized' output
  for (int i=0; i<SAMPLES; i++) {
    samples[i] -= meanval;
    //Serial.println(samples[i]);
  }

  // find the 'peak to peak' max
  float maxsample, minsample;
  minsample = 100000;
  maxsample = -100000;
  for (int i=0; i<SAMPLES; i++) {
    minsample = min(minsample, samples[i]);
    maxsample = max(maxsample, samples[i]);
  }
  Serial.println(maxsample - minsample);
}

XMC4700 Relax Lite Kit - IM69D130 Microphone Shield2Go | Sound pressure level

Arduino
Full code for XMC4700 Relax Lite Kit and MEMS Microphone Shield2Go.
Copy and paste it into an Arduino IDE sketch and flash it to your board.
#include <I2S.h>

/*
 * This example reads audio data from Infineon's IM69D130 Microphone Shield2Go 
 * and processes it to provide feedback based on the sound pressure level.
 * 
 * Open the serial plotter with baudrate of 1000000 and make noise to see the results.
 *
 * It is based on an example published by Sandeep Mistry (https://github.com/sandeepmistry)
 */

void setup()
{
    // Open serial communication with a baudrate of 1000000
    Serial.begin(1000000);
    // Wait until the serial port is connected
    while (!Serial);

    I2S.disableMicrophones();
    // Enable the microphone when word select is low
    I2S.enableMicrophoneHigh();

    Serial.println("Try to initzialize I2S!");
    // Start I2S at 11 kHz with 20 bits per sample
    if (I2S.begin(I2S_PHILIPS_MODE, 11000, 16) != 0)
    {
        Serial.println("Failed to initialize I2S!");
        // Do nothing and wait
        while (true);
    }
}

void loop()
{
    // Array to store the samples
    int32_t samples[128];
    if (I2S.available() > 128)
    {
        // Read 128 samples into the array
        I2S.read(samples, 128);

        float meanValue = 0;
        for (int i = 0; i < 128; i++)
        {
            meanValue += samples[i];
        }
        meanValue /= 128;

        // Substract it from all samples to normalize output
        for (int i = 0; i < 128; i++)
        {
            samples[i] -= meanValue;
        }

        // Get the peak to peak maximum
        float maxSample, minSample;
        minSample = 100000;
        maxSample = -100000;
        for (int i = 0; i < 128; i++)
        {
            minSample = min(minSample, samples[i]);
            maxSample = max(maxSample, samples[i]);
        }
        Serial.println(maxSample - minSample);
        //I2S.flush();
    }
    
}

XMC2Go - IM69D130 Microphone Shield2Go | Sound pressure level

Arduino
Full code for XMC2Go and MEMS Microphone Shield2Go.
Copy and paste it into an Arduino IDE sketch and flash it to your board.
#include <I2S.h>

/*
 * This example reads audio data from Infineon's IM69D130 Microphone Shield2Go 
 * and processes it to provide feedback based on the sound pressure level.
 * 
 * Open the serial plotter with baudrate of 1000000 and make noise to see the results.
 *
 * It is based on an example published by Sandeep Mistry (https://github.com/sandeepmistry)
 */

void setup()
{
    // Open serial communication with a baudrate of 1000000
    Serial.begin(1000000);
    // Wait until the serial port is connected
    while (!Serial);

    I2S.disableMicrophones();
    // Enable the microphone when word select is low
    I2S.enableMicrophoneLow();

    // Start I2S at 11 kHz with 20 bits per sample
    if (I2S.begin(I2S_PHILIPS_MODE, 11000, 16))
    {
        Serial.println("Failed to initialize I2S!");
        // Do nothing and wait
        while (true);
    }
}

void loop()
{
    // Array to store the samples
    int samples[128];
    if (I2S.available() > 128)
    {
        // Read 128 samples into the array
        I2S.read(samples, 128);

        float meanValue = 0;
        for (int i = 0; i < 128; i++)
        {
            meanValue += samples[i];
        }
        meanValue /= 128;

        // Substract it from all samples to normalize output
        for (int i = 0; i < 128; i++)
        {
            samples[i] -= meanValue;
        }

        // Get the peak to peak maximum
        float maxSample, minSample;
        minSample = 100000;
        maxSample = -100000;
        for (int i = 0; i < 128; i++)
        {
            minSample = min(minSample, samples[i]);
            maxSample = max(maxSample, samples[i]);
        }
        Serial.println(maxSample - minSample);
        //I2S.flush();
    }
    
}

IM69D130 Microphone Shield2Go

Summary of information about the IM69D130 Microphone Shield2Go and its implementation for the Arduino IDE.

XMC4700 Relax Lite Kit

Summary of information about the XMC4700 Relax Kit and its implementation for the Arduino IDE.

XMC2Go

Summary of information about the XMC2Go and its implementation for the Arduino IDE.

Credits

Infineon Team
104 projects • 166 followers
Contact

Comments

Please log in or sign up to comment.