INMP441 I2S microphone

The INMP441 MEMS microphone: a microphone, a 24-bit converter and an I2S port in one, read by an ESP32 with no analog parts at all. Aliases: I2S mic, INMP 441.

The board is the I2S master. It drives SCK (the bit clock) and WS (word select); the microphone answers on SD with 24-bit samples, most significant bit first, one clock after WS changes. LR picks the half of the frame it answers in: low for left, high for right. In the other half SD is let go, so two microphones on one SD make a stereo pair.

The sound is synthetic. Pick a tone, white noise or a voice-like sound and set its level; Mokxi computes what the microphone would hear. It is not your computer's microphone, and nothing is recorded.

Pins

Pin What it does
SCK The bit clock, from the board. 0.5 to 3.2 MHz.
WS Word select, the frame clock, from the board.
LR Low: left half of the frame. High: right half. Tie it to one or the other.
SD The samples, to the board.
VDD Supply, 1.62 V to 3.63 V: 3.3 V, never 5 V.
GND Ground.

Properties

sound is quiet, tone, noise or voice. level is its loudness at the microphone in dB SPL, 30 to 120 (60 is talking at a meter, 120 the microphone's limit). freq is the tone's frequency, 20 Hz to 20 kHz.

While it runs

The key picks the sound, the top slider is the level and the second slider the tone's frequency. The little LED lights while the board is clocking samples out.

What the model gets right

The scale. Sensitivity is -26 dBFS: a 94 dB SPL tone comes out as a sine whose peaks are 0.05 of full scale (2^23 - 1). Every 20 dB louder is ten times bigger, up to full scale, where it clips. Underneath is the microphone's own noise, 33 dB SPL equivalent, about -87 dBFS.

The format. 24 bits, two's complement, in a 32-bit slot: read as 32-bit samples the value is in the top 24 bits, which is why sketches shift right by 8.

The startup. The first 2^18 clocks after power up (about a quarter second at 16 kHz) come out as zero, as on the real part.

The pitch. The sound is a function of time, so a 1 kHz tone is 1 kHz whatever sample rate the sketch asks for, and an FFT finds it in the right bin.

The clock limits. The datasheet wants 64 clocks a frame and 0.5 to 3.2 MHz. Outside that clock range the microphone sends zeros. With 16-bit slots (32 clocks a frame) it sends the top 16 bits of each sample, which is outside the datasheet and what sketches that ask for 16 bits see.

What it does not model

The microphone's internal filters, its standby when the clock stops (the real ESP32's DMA never stops the clock; Mokxi's drivers clock only while the sketch reads), and any sound from the room around it.

Libraries

On the ESP32 boards, the ESP-IDF driver (driver/i2s.h: i2s_driver_install, i2s_set_pin, i2s_read), Arduino-ESP32 3.x's ESP_I2S.h (I2SClass) and 2.x's I2S.h. Mokxi bit-bangs the I2S bus on the pins you set, at the sample rate you ask for, while the sketch is reading.

Reading works on the ESP32 and ESP32-S3 boards. On the ESP32-C3 and C6 the board models cannot yet read a pin back within the bit clock, so the read calls return ESP_ERR_NOT_SUPPORTED (or 0) and say so on the serial monitor, rather than hand the sketch wrong samples. Writing, for the MAX98357A, works on all four.

Common mistakes

Leaving LR unconnected. Tie it to GND for the left slot (or 3.3 V for the right), and read that slot.

Powering it from 5 V. Its absolute maximum is 3.63 V.

Using the raw 32-bit numbers. Shift right by 8 to get the 24-bit sample.

See it in action

ESP32 I2S microphone level meter prints the sound level in dBFS. Open it at /templates.