The SPH0645LM4H is a MEMS (Micro-Electro-Mechanical Systems) digital microphone module that outputs audio over the I2S (Inter-IC Sound) interface. For makers in India who want to add high-quality audio capture to their Arduino, ESP32, or Raspberry Pi projects — smart speakers, voice command systems, sound level monitors, or audio recorders — the SPH0645 is one of the best digital microphone modules available at an affordable price. This comprehensive tutorial covers everything from understanding I2S protocol to wiring, coding, and practical applications.
What is a MEMS Microphone?
MEMS microphones use micro-fabricated mechanical structures — a movable diaphragm and a fixed backplate — etched from silicon using semiconductor manufacturing processes. Sound waves cause the diaphragm to move, changing the capacitance between the diaphragm and backplate. An integrated ASIC converts this capacitance change to an electrical signal.
The advantages of MEMS microphones over traditional electret condenser microphones (ECM) include:
- Smaller size: MEMS packages can be as small as 2×3 mm compared to the standard 6mm or 10mm ECM capsules
- Digital output: Many MEMS mics (including the SPH0645) output digital PCM audio via I2S or PDM, eliminating ADC noise from the signal path
- Consistent performance: Semiconductor manufacturing gives tight sensitivity tolerances (±1–2 dB vs ±3–6 dB for ECM)
- Reflow soldering compatible: MEMS mics survive the 260°C peak temperature of standard SMT reflow processes
- Low power: Typically 0.6–1 mA operating current vs 0.3–0.5 mA for ECM + external ADC combination
SPH0645 Module Overview
The SPH0645LM4H from Knowles Acoustics is one of the most popular MEMS microphone ICs used in hobbyist breakout modules. It combines a MEMS acoustic transducer with a 24-bit audio ADC and an I2S output interface all in a tiny LGA package (3.35×2.50×1.00 mm). The breakout module (most popularly the Adafruit SPH0645 breakout, but also many Indian clones) mounts this tiny IC on a convenient board with a JST header or 0.1-inch pitch pins for breadboard use.
Key highlights: 65 dB SNR, 120 dBSPL AOP (Acoustic Overload Point), −26 dBFS sensitivity, I2S output with selectable left/right channel via SEL pin, and 3.3V operation. The 24-bit output is actually 18-bit significant data left-justified in a 32-bit I2S frame — a quirk you need to handle in software.
Understanding I2S Protocol
I2S (Inter-IC Sound), developed by Philips (now NXP), is a serial bus interface standard for connecting digital audio devices. It uses three signal lines:
- BCLK (Bit Clock / SCK): Clock signal that clocks each bit of audio data. Frequency = sample rate × bit depth × channels (e.g., 44100 × 32 × 2 = 2.82 MHz for stereo 32-bit 44.1 kHz)
- LRCLK (Left/Right Clock / WS — Word Select): Toggles at the sample rate frequency. LOW = left channel data, HIGH = right channel data. For a mono mic, your data appears on one channel only.
- DOUT (Data Out / SD): Serial data line. The microphone drives this line; the host (microcontroller) reads it.
The SPH0645 is a receiver perspective microphone — it drives DOUT with serial audio data, clocked by BCLK, framed by LRCLK. The microcontroller provides BCLK and LRCLK (it is the I2S master); the microphone is the I2S slave transmitter.
| SPH0645 Pin | I2S Signal | Direction | Description |
|---|---|---|---|
| SEL | Channel Select | Input | GND = Left channel, VCC = Right channel |
| LRCLK | WS / LRCK | Input | Left/Right word select clock |
| BCLK | SCK / BCLK | Input | Bit clock from host |
| DOUT | SD | Output | Serial audio data out from mic |
| 3V | VDD | Input | 3.3V power supply |
| GND | GND | — | Ground |
SPH0645 vs Analog Electret Microphone
| Parameter | SPH0645 (MEMS I2S) | Analog Electret + MAX4466 |
|---|---|---|
| SNR | 65 dB | 40–55 dB (ADC limited) |
| Noise Floor | 29 dBSPL (A-weighted) | 35–45 dBSPL |
| Frequency Response | 100 Hz – 10 kHz (flat) | 100 Hz – 8 kHz (depends on capsule) |
| Sensitivity Tolerance | ±1 dB (unit-to-unit) | ±3–6 dB |
| Interface | I2S digital | Analog (needs ADC) |
| Board Wiring | 3 signal wires + power | 1 analog wire + power |
| Cost (India) | ₹400–₹700 (breakout) | ₹80–₹200 |
| Microcontroller Support | ESP32, Pi, STM32 (not Uno) | Any with ADC (Arduino Uno works) |
Technical Specifications
- Sensitivity: −26 dBFS (typ) at 94 dBSPL 1 kHz
- SNR: 65 dB(A) at 94 dBSPL
- AOP (Acoustic Overload Point): 120 dBSPL
- Dynamic Range: 91 dB
- Frequency response (−3 dB): 50 Hz – 15 kHz
- Power supply voltage: 1.62V – 3.6V
- Current consumption: 650 µA typical
- I2S clock frequency: 1.0 – 4.0 MHz
- Data format: 18-bit, left-justified in 24-bit I2S frame (with padding)
- Operating temperature: −40°C to +85°C
Wiring to ESP32 (Recommended)
The ESP32 has built-in I2S peripheral support in its Arduino framework, making it the easiest microcontroller to use with the SPH0645. Unlike Arduino Uno (which has no I2S peripheral), ESP32 handles the bit-perfect I2S protocol in hardware with DMA, leaving the CPU free for audio processing.
ESP32 to SPH0645 connections:
- ESP32 3.3V → SPH0645 3V
- ESP32 GND → SPH0645 GND
- ESP32 GPIO 25 → SPH0645 LRCLK (WS)
- ESP32 GPIO 32 → SPH0645 BCLK
- ESP32 GPIO 33 → SPH0645 DOUT
- SPH0645 SEL → GND (left channel)
Note: The SPH0645 requires 3.3V. Do NOT connect to 5V — this will damage the module. ESP32 GPIO pins are 3.3V native, so no level shifting is needed.
Wiring to Raspberry Pi
Raspberry Pi (any model with 40-pin header) has I2S pins on the GPIO header:
- Pi 3.3V (Pin 1) → SPH0645 3V
- Pi GND (Pin 6) → SPH0645 GND
- Pi GPIO 19 (PCM_FS, Pin 35) → SPH0645 LRCLK
- Pi GPIO 18 (PCM_CLK, Pin 12) → SPH0645 BCLK
- Pi GPIO 20 (PCM_DIN, Pin 38) → SPH0645 DOUT
- SPH0645 SEL → GND
On Raspberry Pi, enable I2S in /boot/config.txt with dtparam=i2s=on and install the rpi-sph0645 or equivalent ALSA driver overlay. Then record audio with arecord.
BMP280 Barometric Pressure & Altitude Sensor I2C/SPI
Build a complete environment sensing node — combine MEMS microphone with BMP280 for simultaneous sound level, temperature, and altitude monitoring.
ESP32 Arduino Code: I2S Audio Capture
#include <driver/i2s.h>
// I2S pin definitions (adjust to your wiring)
#define I2S_WS 25 // LRCLK
#define I2S_SCK 32 // BCLK
#define I2S_SD 33 // DOUT from SPH0645
#define SAMPLE_RATE 16000
#define SAMPLE_BITS 32
#define BUFFER_SIZE 512
void i2s_install() {
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = SAMPLE_RATE,
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT, // SEL=GND
.communication_format = I2S_COMM_FORMAT_STAND_I2S,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 4,
.dma_buf_len = BUFFER_SIZE,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0
};
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
}
void i2s_setpin() {
i2s_pin_config_t pin_config = {
.bck_io_num = I2S_SCK,
.ws_io_num = I2S_WS,
.data_out_num = I2S_PIN_NO_CHANGE,
.data_in_num = I2S_SD
};
i2s_set_pin(I2S_NUM_0, &pin_config);
}
void setup() {
Serial.begin(115200);
i2s_install();
i2s_setpin();
i2s_start(I2S_NUM_0);
Serial.println("SPH0645 I2S microphone ready");
}
void loop() {
int32_t buffer[BUFFER_SIZE];
size_t bytes_read;
i2s_read(I2S_NUM_0, &buffer, sizeof(buffer), &bytes_read, portMAX_DELAY);
int samples_read = bytes_read / sizeof(int32_t);
// SPH0645 outputs 18-bit data left-justified in 32-bit frame
// Shift right by 14 bits to get 18-bit signed value
int32_t sample = buffer[0] >> 14;
Serial.println(sample); // Plot in Serial Plotter for waveform
}
Sound Level Meter Example
// RMS sound level meter
void loop() {
int32_t buffer[256];
size_t bytes_read;
i2s_read(I2S_NUM_0, &buffer, sizeof(buffer), &bytes_read, portMAX_DELAY);
int samples = bytes_read / sizeof(int32_t);
// Compute RMS
double sum_sq = 0;
for (int i = 0; i < samples; i++) {
int32_t s = buffer[i] >> 14; // 18-bit sample
sum_sq += (double)s * s;
}
double rms = sqrt(sum_sq / samples);
// Convert to approximate dB SPL
// SPH0645 sensitivity: -26 dBFS at 94 dBSPL, full scale = 131072 (18-bit)
// dBFS = 20*log10(rms / 131072)
// dBSPL ≈ dBFS + 94 + 26 = dBFS + 120
double dBFS = 20.0 * log10(rms / 131072.0 + 1e-10);
double dBSPL = dBFS + 120.0;
Serial.print("Sound level: ");
Serial.print(dBSPL, 1);
Serial.println(" dBSPL");
}
Two Microphones: Stereo Setup
The SPH0645 SEL pin controls whether the microphone outputs on the left (SEL=GND) or right (SEL=VCC) I2S channel. By connecting two SPH0645 modules sharing the same BCLK and LRCLK lines but using separate DOUT lines (or the same DOUT if both share a wire-OR output bus — check module schematic), you can achieve stereo recording.
On ESP32: configure I2S_CHANNEL_FMT_RIGHT_LEFT and wire:
— Mic 1: SEL=GND (left channel), DOUT → ESP32 data pin
— Mic 2: SEL=3.3V (right channel), DOUT → same ESP32 data pin (both can share if open-drain; otherwise use two I2S peripherals)
Two-microphone stereo opens the door to directional audio, beamforming, and noise cancellation using simple delay-and-sum algorithms — surprisingly achievable on an ESP32 with a bit of signal processing code.
GY-BME280 3.3V Precision Altimeter Atmospheric Pressure Sensor
Combine with the SPH0645 on I2C for a rich environment node — measure temperature, humidity, pressure, and sound level simultaneously.
Project Ideas
- Voice-controlled smart home: ESP32 + SPH0645 + Google Home SDK or custom wake-word model (e.g., TensorFlow Lite Micro). Trigger lights, fans, or AC units by voice.
- Industrial noise monitor: Measure factory floor dB levels, log to SD card with timestamps, alert via GSM if noise exceeds OSHA limits.
- Baby monitor with audio streaming: ESP32 + SPH0645 stream audio over Wi-Fi to a smartphone app. Add PIR sensor to trigger recording only on motion.
- Bird call recorder: Raspberry Pi Zero + SPH0645 in a weatherproof box in your garden. Record dawn chorus at full quality and identify species using Python + BirdNET AI.
- Classroom sound level display: ESP32 + SPH0645 + OLED or LED bar graph display showing real-time noise level — great for teaching noise discipline.
- Bat detector (time expansion): Record ultrasonic frequencies by oversampling — SPH0645’s −3 dB bandwidth extends to about 15 kHz, suitable for detecting high-pitched bat calls when processed digitally.
Benewake AD2-S-X3 Automotive-Grade LiDAR
For advanced sensing projects — combine acoustic sensing (SPH0645) with precision LiDAR ranging for a multi-modal robot perception system.
Frequently Asked Questions
Can I use the SPH0645 with a standard Arduino Uno?
Not directly. Arduino Uno has no I2S peripheral hardware. You can implement bit-banged I2S in software but it is unreliable at audio sample rates. Use an Arduino with I2S support — such as the Arduino Zero (SAMD21), Arduino Nano 33 BLE (nRF52840), or better yet, an ESP32 which has dual hardware I2S peripherals.
What is the maximum sample rate of the SPH0645?
The SPH0645 supports BCLK frequencies up to 4 MHz. With 32-bit stereo frames: max sample rate = 4 MHz / (32 bits × 2 channels) = 62,500 Hz. Practically, 44,100 Hz (CD quality) and 16,000 Hz (voice quality) are the most common sample rates used with this microphone.
Why does my SPH0645 output data sound distorted or clipped?
Most commonly, the 18-bit data is not being extracted correctly from the 32-bit I2S frame. The SPH0645 left-justifies 18-bit data in the 32-bit word — the actual audio sample is in bits 31:14 (the top 18 bits). Shift right by 14 bits to get a signed 18-bit integer: sample = raw_32bit >> 14;. Also ensure your I2S mode is set to LEFT (mono) if SEL is connected to GND.
Is the SPH0645 suitable for music recording?
The SPH0645 has an upper frequency limit of about 10–15 kHz (−3 dB at ~15 kHz), which means it will capture voice and most instruments but will roll off high-frequency content like cymbals. For voice recording, speech recognition, and sound monitoring it is excellent. For professional music recording with flat response up to 20 kHz, a studio-grade condenser mic is more appropriate.
Can I use a 5V supply for the SPH0645?
No. The SPH0645 maximum supply voltage is 3.6V. Applying 5V will permanently damage the IC. The Adafruit breakout module includes a 3.3V regulator allowing 5V input on the board VIN pin, but the IC itself always runs at 3.3V. For bare modules without a regulator, use the 3.3V rail from your microcontroller.
How does the SPH0645 compare to the INMP441?
The INMP441 is another popular I2S MEMS microphone module, often cheaper in India. Both are I2S, both output 24-bit data, both are mono with L/R select. The SPH0645 has slightly better SNR (65 dB vs 61 dB) and lower noise floor. The INMP441 is more commonly available on cheap Indian clone boards. For most projects, both work well — the Adafruit/ESP32 I2S library code works for both with minor parameter adjustments.
Build high-quality audio and sensing projects with components from India’s trusted electronics store. Browse the Sensors & Measurement collection at Zbotic.in — fast nationwide delivery, quality guaranteed.
Add comment