INPM441 not working on Nano ESP32

Hi!
I have a mini project where i am using using nano esp32 with inmp441 microphone. Below you can see the prototype.

The code is as follows:

#include <driver/i2s.h>

#define I2S_WS D7
#define I2S_SCK D8
#define I2S_SD D6


#define I2S_PORT I2S_NUM_0

#define bufferLen 64 
int16_t buff [bufferLen]; //immagazziniamo 16 campioni da 16 bit

//creare struttura tipo i2s config (i2s_config_t offerta dalla libreria )

const i2s_config_t i2s_config = {
    .mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX), //il dispositivo si comporta da MASTER e RICEVE i dati (dal mic)
    .sample_rate = 44100, // frequenza di campionamento
    .bits_per_sample = i2s_bits_per_sample_t(16), // quanti bit per campione (16)
    .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT, // solo canale sinistro
    .intr_alloc_flags = 0,
    .dma_buf_count = 8,
    .dma_buf_len = bufferLen, // lunghezzza del buffer
    .use_apll = false
};

// config per impostare i pin (const i2s_pin_config_t offerta dalla libreria)

const i2s_pin_config_t pin_config = {
    .bck_io_num = D7,
    .ws_io_num = D8,
    .data_out_num = -1,
    .data_in_num = D10
};

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  delay(2000);
  Serial.println("I2s MIC");
  //installiamo configurazioni 

  i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL); //0 e null se non vogliamo una coda di eventi
  i2s_set_pin(I2S_PORT, &pin_config);
  i2s_start(I2S_PORT); //avviamo processore

  delay(1000); //piccolo delay per permettere a tutto di partire

}

void loop() {
  // qui riceviamo i dati

//  size_t bytesRicevuti = 0; // quanti bit ricevuti
//  esp_err_t res = i2s_read(I2S_PORT, &buff, bufferLen, &bytesRicevuti, portMAX_DELAY); //funzione di ricezione: prende processore, campioni ricevuti, lunghezza del buffer, quanti bit ricevuti, attendi se non ci sono campioni. risultato della lettura è oggetto esp_err_t
//  if (res == ESP_OK) { //se res è uguale a esp ok↓
//    int n = bytesRicevuti / 16; //andiamo a leggere i campioni. quanti ne abbiamo ricevuti ce lo dice bytesRicevuti diviso per 16
//    if (n > 0) { // se il numero è > 0 vuol dire che abbiamo ricevuto qualcosa e possiamo leggerlo quindi processarlo 
//      for (int i = 0; i < n, i++;) {
//        Serial.println(buff[i]); //li andiamo a stampare (i valori)
//      }

    }

Which should display some audio signal in the serial plotter. However, when I open the serial plotter nothing shows.

I have tried running this test code which should basically do the same thing (changing the pins accordingly), but even with this script the serial plotter stays flat, though in this case with x-values increasing (which doesn't happen in my code).

How can I manage it to work? I doubt it to be a hardware problem as both the mic and the Arduino are quite brand-new.

any help appreciated!!

Check this link, they have demos and explanations with the Arduino UNO. A Complete Guide to the INMP441 I2S Microphone – Easyelecmodule

Hi @francescomennella. From the picture you shared, it appears that you did not solder the headers on the INMP441 module. You must solder the headers in order to get a reliable electrical connection to the module. Lack of reliable electrical connections could be the cause of the problem you are experiencing.

Even if it looks like the header pins probably are in contact with the pads on the board, this is often not the case, or if so only in an intermittent fashion.

See your other topic on the same subject for the solution

In that sample code they are reading the i2s input buffer (from the mic and send it to the serial port but you are not doing that. You are just starting the i2S rx channel and it is just filling up your buffers but your not reading them. Also you do not need a delay after starting i2s .

I dont know if you intended that the code commented out be active or not.

One thing i do see is you are dividing bytes read by 16, I think you meant 2 to get number of samples read since each sample is two bytes.

the code in void (loop) is to be uncommented, my bad. However even with that uncommented the serial plotter still shows nothing. Also, if I change the bytes divisor from 16 to 2 the Arduino enters in a bootloop state (see this topic).