ESP32 using ICS43434 as MEMS microphone in Arduino IDE

tolo69
Posts: 8
Joined: Thu Nov 16, 2017 7:32 pm

ESP32 using ICS43434 as MEMS microphone in Arduino IDE

Postby tolo69 » Sun Jan 28, 2018 8:33 pm

Hi all,

I want to connect the MEMS-microphone ICS43434 to the ESP32. This microphone chip comprises I2S Interface to transmit the audion data stream. There is an "I2S.h" library compatible for the Arduino board MKRZero. I'm looking for a library for ESP32. Has somebody already done the porting or using similiar library for ESP32 ?

onehorse
Posts: 70
Joined: Mon Feb 15, 2016 1:35 am

Re: ESP32 using ICS43434 as MEMS microphone in Arduino IDE

Postby onehorse » Mon Jan 29, 2018 4:28 am

+1

I am able to use these mics with the nRF52 and STM32L4 and Teensy (various) but am not sure if there is an easy way to do so with the ESP32 Arduino core.

User avatar
rudi ;-)
Posts: 1729
Joined: Fri Nov 13, 2015 3:25 pm

Re: ESP32 using ICS43434 as MEMS microphone in Arduino IDE

Postby rudi ;-) » Mon Jan 29, 2018 8:04 pm

tolo69 wrote:Hi all,

I want to connect the MEMS-microphone ICS43434 to the ESP32. This microphone chip comprises I2S Interface to transmit the audion data stream. There is an "I2S.h" library compatible for the Arduino board MKRZero. I'm looking for a library for ESP32. Has somebody already done the porting or using similiar library for ESP32 ?
did you try simple insert the megaphone c code example in your arduino project?
try it - i am sure it work's

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

tolo69
Posts: 8
Joined: Thu Nov 16, 2017 7:32 pm

Re: ESP32 using ICS43434 as MEMS microphone in Arduino IDE

Postby tolo69 » Mon Jan 29, 2018 10:31 pm

The microphone data can be captured. But in the Serial plotter I'm facing square wave, but I would expect analog graph. What do I have to change in my Code?

Code: Select all

#include <WiFi.h>
#include "driver/i2s.h"

void i2s_config() {
  // http://esp-idf.readthedocs.io/en/latest/api/perip herals/i2s.html
  // input
  i2s_config_t i2s_in_config = {
    mode: (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
    sample_rate: 44100,
    bits_per_sample: (i2s_bits_per_sample_t)32,
    channel_format: I2S_CHANNEL_FMT_RIGHT_LEFT,
    communication_format: (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
    intr_alloc_flags: ESP_INTR_FLAG_LEVEL1,
    dma_buf_count: 14,
    dma_buf_len: 64
  };
  i2s_pin_config_t i2s_in_pin_config = {
    bck_io_num: 16,
    ws_io_num: 4,
    data_out_num: -1, //Not used
    data_in_num: 17
  };

   pinMode(17, INPUT);
   pinMode(16, OUTPUT);
   pinMode(4, OUTPUT);

  i2s_driver_install((i2s_port_t)0, &i2s_in_config, 0, NULL);
  i2s_set_pin((i2s_port_t)0, &i2s_in_pin_config);
}

void read_i2s() {
  uint32_t sample_val[2] = {0, 0};
  uint8_t bytes_read = i2s_pop_sample((i2s_port_t)0, (char *)sample_val, portMAX_DELAY);
  Serial.println(sample_val[0]);
}

void setup()
{
    Serial.begin(115200);
    delay(4000);

    i2s_config();
}

void loop()
{
  read_i2s();
}

User avatar
hassan789
Posts: 156
Joined: Thu Jun 29, 2017 2:15 am

Re: ESP32 using ICS43434 as MEMS microphone in Arduino IDE

Postby hassan789 » Sun Feb 04, 2018 2:51 am

tolo69 wrote:The microphone data can be captured. But in the Serial plotter I'm facing square wave, but I would expect analog graph. What do I have to change in my Code?
I don't use arduino, but just looking at your code, here are some ideas:
1. "sample_val" should be signed (aka "int32_t", not "uint32_t")
2. the println might be slowing down your sampling. Might want to buffer up (maybe 100 samples atleast?) and print them all at once

tolo69
Posts: 8
Joined: Thu Nov 16, 2017 7:32 pm

Re: ESP32 using ICS43434 as MEMS microphone in Arduino IDE

Postby tolo69 » Thu Feb 15, 2018 9:07 pm

Correcting the data type of sample_val to int32_t solved the problem :D Not it works

Thanks a lot

onehorse
Posts: 70
Joined: Mon Feb 15, 2016 1:35 am

Re: ESP32 using ICS43434 as MEMS microphone in Arduino IDE

Postby onehorse » Sat Feb 17, 2018 3:09 am

Please post the entire working Arduino sketch or link to a github repository where I can find it. Thanks!

tolo69
Posts: 8
Joined: Thu Nov 16, 2017 7:32 pm

Re: ESP32 using ICS43434 as MEMS microphone in Arduino IDE

Postby tolo69 » Tue Mar 06, 2018 4:43 pm

It is same sketch as posted above. Just 1 line has to be replaced:
uint32_t sample_val[2] = {0, 0}; ---> int32_t sample_val[2] = {0, 0};

Who is online

Users browsing this forum: No registered users and 15 guests