2

I have code that allows me to record I2S audio from the INMP441 MEMS microphone module using an ESP32. The data is read from the data out pin of the device.

When I take the Fourier transform of this signal while recording a 2 kHz tone, I get a large low-frequency noise component that seems to saturate the ADC, see below. The first has 2048 samples while the second has 8192:

Fourier transform

Fourier transform 2

I am not sure what the source of this noise is and how one can remove it.

Things that may be important:

  • I am transmitting WiFi signals at the same time I am recording.

Setup:

Setup

ocrdu
  • 8,705
  • 21
  • 30
  • 42
Grabt234
  • 66
  • 4
  • 1
    Where are you measuring this signal? You mention it saturating the ADC but from what I can tell, the ADC is internal to the INMP441. – Matt S Dec 28 '22 at 21:39
  • 1
    The INMP441 should include a high-pass filter that attenuates those low frequencies. Presumably your signal processing has a DC bias. – sh- Dec 28 '22 at 21:50
  • 2
    2048 point FFT with a ~8KHz sampling rate only gives you ~ 4 Hz resolution, so that peak may just be the DC offset on the signal. – user1850479 Dec 29 '22 at 00:22
  • Is the device USB powered (gnd hum)? Can you try a battery(bank)? – RemyHx Dec 29 '22 at 05:19
  • Breadboard? Use really short connectors/wires, can you supply a photo of the setup? Use a bulk cap on the power rail. – RemyHx Dec 29 '22 at 05:24
  • I will update the question with a picture of the setup now. – Grabt234 Dec 29 '22 at 06:28
  • Yes I guess you will have much better results shortening the wires. If you have an oscilloscope, connect the ground lead of the probe to the pin and check the noise on the scope (separate from your project). These wires are practically catching EM fields, this will disturb the power in of the mic. The data is not disturbed directly because it’s digital. – RemyHx Dec 29 '22 at 10:51
  • Also the USB cable can inject noise by (radiation and conducted ). Use a short USB cable and preferably with a battery(pack). You could try a cap between the pins of vcc/gnd of the mic. Something like a 10nF. – RemyHx Dec 29 '22 at 10:54
  • 1. I shortened the cables - no real change 2. I added the cap - no real change 3. Tried the battery bank - no real change 4. I added a custom HP filter which helped a bit but has not solved the issue – Grabt234 Dec 29 '22 at 12:24
  • @Grabt234 so you put the pins of the esp onto the breadboard? And used max 1-2 cm wires? – RemyHx Dec 29 '22 at 13:45
  • @Grabt234, I'm also seeing similar issue, you could find my experiments with this mic [here](https://github.com/ikostoski/esp32-i2s-slm/issues/19) – Stas S Jan 27 '23 at 19:40

1 Answers1

1

The issue was due to the fact that my software implementation was incorrect. The microphone I am using samples using 24 bits and I did not account for this.

Previously I would read and cast sets of 2 consecutive bytes assuming each sample was two bytes where in reality each sample was three. This meant I was casting incorrectly

Reading bytes from the samples buffer and converting them to uint_16 should have been done as follows:

i2s_read((i2s_port_t)uI2SInterfaceIndex, &buffer16, 4*256, &bytesRead, 100);

int samplesRead = bytesRead / 4;
for (int i = 0; i < samplesRead; i++) {
    m_pTimeChunk->m_vvfTimeChunks[uI2SInterfaceIndex][i] = ((buffer16[4*i+2] << 8) | (buffer16[4*i+3])); 
}

Where every third byte is discarded and only two are used.

Grabt234
  • 66
  • 4