Inputting audio to an ESP32 from an INMP441 I2S microphone: success
Re: Inputting audio to an ESP32 from an INMP441 I2S microphone: success
I had the same problems a few weeks ago. And finally solved it in a different thread.
-
- Posts: 3
- Joined: Fri Oct 27, 2023 2:46 pm
Re: Inputting audio to an ESP32 from an INMP441 I2S microphone: success
Hi, I do exactly the same as chris_oz but in IDF 4.4.3. But after read I2S, my buffer32 is all zero. When I change to 16 bits per sample, it works. But with 16 bits per sample, when I test with 500Hz, it seems like it's not working correctly. I just really want to know why 32 bits per sample not working in this case.
This is my i2s configuration:
And this is how I read I2S:
Is there any problem with I2S protocol in this version of IDF ? Has anyone ever encountered this problem? If yes and solved the problem please help me.
This is my i2s configuration:
Code: Select all
// Set up I2S Processor configuration
void i2s_install() {
// Set up I2S Processor configuration
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = 4000, // or 44100 if you like
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT, // Ground the L/R pin on the INMP441.
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_STAND_I2S),
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = bufferCount,
.dma_buf_len = bufferLen,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0,
};
i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);
}
Code: Select all
while (1)
{
vTaskDelay(1); // Feed for watchdog, if not watchdog timer will be triggered!
i2s_read(I2S_PORT, &buffer32, sizeof(buffer32), &bytesRead, 100);
int samplesRead = bytesRead / 4;
for (uint8_t i = 0; i < samplesRead; i++) {
uint8_t mid = buffer32[i * 4 + 2];
uint8_t msb = buffer32[i * 4 + 3];
uint16_t raw = (((uint32_t)msb) << 8) + ((uint32_t)mid);
memcpy(&buffer16[i], &raw, sizeof(raw)); // Copy so sign bits aren't interfered with somehow.
printf("%d %d %d\n", 3000, -3000, buffer16[i]);
}
}
Re: Inputting audio to an ESP32 from an INMP441 I2S microphone: success
Try I2S_CHANNEL_FMT_ONLY_RIGHT to receive the data from the "left" INMP441 channel (i.e. the data that the INMP441 provides in the first half of the sampling period when WS is LOW and the L/R pin is tied to GND). For me that does the trick.Has anyone ever encountered this problem? If yes and solved the problem please help me.
KR, Sebastian
Who is online
Users browsing this forum: No registered users and 61 guests