Skip to content
Home > Components > Audio > I2S MEMS Microphone

I2S MEMS Microphone (SPH0645)

A digital microphone that outputs pristine audio directly over the I2S bus, bypassing analog noise.

Component Preview

I2S MEMS MicrophoneSPH0645

The SPH0645 is a tiny MEMS microphone that includes a built-in analog-to-digital converter (ADC) and an I2S interface. Instead of outputting a messy analog voltage that your microcontroller has to sample, it outputs a clean, digital stream of 24-bit audio data. It's perfect for microcontrollers with hardware I2S support, like the ESP32, Teensy, or Arduino Mega.

AudioI2SInput

Overview

Because this microphone uses I2S (Inter-IC Sound), it requires three dedicated data pins: Word Select (LRCL / WS), Bit Clock (BCLK), and Data Out (DOUT). The SEL pin determines whether the microphone outputs its data on the Left or Right channel of the stereo I2S stream (usually pulled to Ground for Left).

Pin Reference

PinTypeDescription
3VpowerPower input. Connect to 3.3V.
GNDpowerGround. Connect to GND.
BCLKdigitalI2S Bit Clock. Connect to the microcontroller's I2S clock pin.
DOUTdigitalI2S Data Out. Connect to the microcontroller's I2S data input pin.
LRCLdigitalI2S Word Select (Left/Right Clock). Connect to the I2S WS pin.
SELdigitalChannel Select. Pull to GND for Left channel, or VCC for Right.

Configurable Attributes

AttributeTypeDefaultDescription
audioFilestring""A URL to a `.wav` or `.mp3` file to use as the simulated audio source for the microphone.

Wiring Diagram (Arduino Mega)

The Arduino Uno does not have hardware I2S, so for this example we are using the Arduino Mega (or typically an ESP32).

  1. Connect 3V to 3.3V.
  2. Connect GND to GND.
  3. Connect SEL to GND (configuring the mic as the Left channel).
  4. Connect LRCL to the I2S WS pin.
  5. Connect DOUT to the I2S Data IN pin.
  6. Connect BCLK to the I2S Clock pin.

Wiring Diagram

Example Arduino Code

Reading from I2S requires an I2S library (such as the standard I2S.h for ESP32/SAMD architectures). Here is a standard configuration block.

cpp
#include <I2S.h>

void setup() {
  Serial.begin(115200);
  while (!Serial) { ; }

  // Start I2S receiver
  // I2S.begin(mode, sampleRate, bitsPerSample)
  if (!I2S.begin(I2S_PHILIPS_MODE, 16000, 32)) {
    Serial.println("Failed to initialize I2S!");
    while (1); // halt
  }
}

void loop() {
  // Read a 32-bit sample from the I2S bus
  int sample = 0;
  if (I2S.available()) {
    I2S.read(&sample, sizeof(sample));
    
    // Convert 24-bit data to 16-bit by shifting
    sample >>= 14; 
    
    // Print for the Serial Plotter
    Serial.println(sample);
  }
}

Simulation Notes

  • The SPH0645 generates a simulated sine wave audio signal over the virtual I2S bus by default.
  • You can override the default sine wave by specifying an audioFile attribute, which points to a remote audio file to "play" into the microphone.

Released under the MIT License.