INMP441 on ESP32, Mic outputs values with respond to voice, but only 1s and 0s

Hi everyone,

I am using ESP32 C3 DevKit V1 with INMP441 using minimal test code from atomic14
The mic responds when I blow in it, but with only 1s and 0s, and I am pretty sure it should give more range

Hardware Setup

INMP441 Pin ESP32 Pin
VDD 3.3 V
GND GND
L/R GND
WS GPIO 22
SCK GPIO 26
SD GPIO 21

Connected using F-F jumper wires directly

#include <driver/i2s.h>



#define SAMPLE_BUFFER_SIZE 512

#define SAMPLE_RATE 8000

#define I2S_MIC_CHANNEL I2S_CHANNEL_FMT_ONLY_LEFT

#define I2S_MIC_SERIAL_CLOCK GPIO_NUM_26

#define I2S_MIC_LEFT_RIGHT_CLOCK GPIO_NUM_22

#define I2S_MIC_SERIAL_DATA GPIO_NUM_21

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,

    .communication_format = I2S_COMM_FORMAT_I2S,

    .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,

    .dma_buf_count = 4,

    .dma_buf_len = 1024,

    .use_apll = false,

    .tx_desc_auto_clear = false,

    .fixed_mclk = 0};


i2s_pin_config_t i2s_mic_pins = {

    .bck_io_num = I2S_MIC_SERIAL_CLOCK,

    .ws_io_num = I2S_MIC_LEFT_RIGHT_CLOCK,

    .data_out_num = I2S_PIN_NO_CHANGE,

    .data_in_num = I2S_MIC_SERIAL_DATA};



void setup()

{
  Serial.begin(115200);

  // start up the I2S peripheral

  i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);

  i2s_set_pin(I2S_NUM_0, &i2s_mic_pins);

}



int32_t raw_samples\[SAMPLE_BUFFER_SIZE\];

void loop()

{

  size_t bytes_read = 0;

  i2s_read(I2S_NUM_0, raw_samples, sizeof(int32_t) \* SAMPLE_BUFFER_SIZE, &bytes_read, portMAX_DELAY);

  int samples_read = bytes_read / sizeof(int32_t);

  // dump the samples out to the serial channel.

  for (int i = 0; i < samples_read; i++)

  {

    Serial.printf("%ld\\n", raw_samples\[i\]);

  }

}

Any insight or code examples will be appreciated.

Thank you,

I think your main issue is here, you are using 32-bit words and formatting left, try using I2S_COMM_FORMAT_I2S_LSB

Here is the config from an example I put together a long time ago in case it helps though:



i2s_mode_t myMode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN);

// This configures the i2s peripheral, configure as necessary...
i2s_config_t i2s_cfg = {
.mode = (i2s_mode_t)myMode,
.sample_rate =  32000,              // The format of the signal using ADC_BUILT_IN
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, // is fixed at 12bit, stereo, MSB
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S_LSB,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 4,
.dma_buf_len = numSamples,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0
};

i2s_driver_install(I2S_NUM_0, &i2s_cfg, 0, NULL);

i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);
i2s_set_clk(I2S_NUM_0, 32000, I2S_BITS_PER_SAMPLE_16BIT, I2S_CHANNEL_MONO);
i2s_stop(I2S_NUM_0);

That device outputs 1's and 0's, it's digital. It should only be read on I2S pins.

When those 1s and 0s are combined into a 32-bit variable and printed, there should be representative output, not just 1s and 0s.