L&R Microphones on I2S using ESP32 S3 DevKitC-1

waszee
Posts: 5
Joined: Sat May 20, 2023 2:27 am

L&R Microphones on I2S using ESP32 S3 DevKitC-1

Postby waszee » Thu Jun 29, 2023 11:25 pm

I am evaluating a ESP32-S3-DevKitC-1 with INMP441 [or other MEMS microphone] for a stethoscope application. The microphone is using the left channel. That is working. I now want to add a second microphone of same type and lot to monitor ambient background using the right channel. I am not sure of the configuration changes and hardware lines. Can I use the same I2S port for second mike? Do I wire one microphone L/R to ground and the other to 3.3V and let all other lines connect to same pins on each microphone in parallel? I have looked for a i2s example with a stereo left and right channel but haven't found one. Can somebody point me to something more complex than a single channel input. Ideally could use some example that actually does a noise cancel or amplitude and phase adjustment of the ambient channel to optimize background reduction. I know none of this is really new but where in open source? Saw a similar query in this forum for a SPK0838HT mems microphone but no one has answered so posting this. I wonder if anybody can recommend the microphone that I should use for heart sound. I saw a video that said the INMP441 is out of date and should consider a ICS43434. Hoping you guys can help me sort the options. Most of the stereo settings should go here I think.

void i2s_install() {
// Set up I2S Processor configuration
const i2s_config_t i2s_config = {
.mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = 44100,
.bits_per_sample = i2s_bits_per_sample_t(16),
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
.communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S),

.intr_alloc_flags = 0,
.dma_buf_count = 8,
.dma_buf_len = bufferLen,
.use_apll = false
};

waszee
Posts: 5
Joined: Sat May 20, 2023 2:27 am

Re: L&R Microphones on I2S using ESP32 S3 DevKitC-1

Postby waszee » Sat Jul 01, 2023 6:22 pm

I guess I should mention I found 266 examples of stethoscope codes on github. About 10 percent of those examples use the ESP32 microcontroller. Examples include Wifi and Bluetooth, but I did not find any that add a second microphone for ambient background correction. There were some that used several microphones to form a microphone beam to improve direction of the input sound. I tried to split the read signal into left and right stereo using even and odd readings but my code not working, probably counting the bytes per readings wrongs. I did link both microphones for stereo input, I think, but not sure did correctly until I can actually view the two separate R&L channels. Would love an example code that splits the I2sread buffer into two streams. I did see how it is done in hardware using the output i2s amplifier and solder pins for the WS line, but I want to do in software. I think my ESP32 S3 should be fast enough to handle the splitting in real time but could also do this after storing the data. Actually realtime monitoring is not necessary just capturing a good input signal. I am finding that somewhat of a challenge.

ESP_Sprite
Posts: 9052
Joined: Thu Nov 26, 2015 4:08 am

Re: L&R Microphones on I2S using ESP32 S3 DevKitC-1

Postby ESP_Sprite » Sun Jul 02, 2023 2:00 am

You are right in that the hw setup described in your first post should work. I think you'd modify I2S_CHANNEL_FMT_ONLY_LEFT to I2S_CHANNEL_FMT_STEREO for it to record both mic streams, but I don't have the hw to test that here. What you will get is an interleaved stereo stream, that is, an array of uint16s where the even ones are the left samples and the odd ones the right samples. (Or the other way around, I don't remember.)

Who is online

Users browsing this forum: Google [Bot] and 131 guests