[
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\ngithub: [atomic14]\nko_fi: atomic14\n"
  },
  {
    "path": "README.md",
    "content": "# The Simplest Test Code for an I2S Microphone on the ESP32 I can Imagine\n\n[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Z8Z734F5Y)\n\nI've got a lot of audio projects. And I've tried to make these all available on GitHub.\n\nYou can see all my projects here: [atomic14](https://www.youtube.com/channel/UC4Otk-uDioJN0tg6s1QO9lw) - please take a look and subscribe if you like them!\n\nQuite a few of the issues I get on the projects seem to boil down to people having problems with their microphones. This is understandable - there's a lot to take in on some of the projects as they are pretty complicated.\n\nIt can be hard to tell if the problem is with the microphone, the code, or something completely unrelated.\n\nWithout actually recording and playing back the audio, it's hard to know what the problem is.\n\nIt's easy if you have an amplifier and speaker - but that's just adding another failure point. Is it the microphone or the speaker that is the problem?\n\nWe can play audio directly back via the ADC through headphones - but again, this is another failure point.\n\nI think the most minimal thing we can do is to use the serial plotter in Arduino. This should work for everyone without any issues and is a very simple test.\n\nOpen this sketch up using the Arduino IDE and hit run. Now go to Tools->Serial Plotter.\n\nThere's only a few lines of code that you will need to change:\n\n```c++\n#define I2S_MIC_SERIAL_CLOCK GPIO_NUM_26\n#define I2S_MIC_LEFT_RIGHT_CLOCK GPIO_NUM_22\n#define I2S_MIC_SERIAL_DATA GPIO_NUM_21\n```\n\n# Wiring up the INMP441\n\nThis is a popular cheap microphone with readily available breakout board\n|INMP441 | ESP32| Info|\n|---|---|---|\n|VDD|3v3|Power - DO NOT USE 5V!|\n|GND|GND|GND|\n|L/R|GND|Left channel or right channel|\n|WS|22|Left right clock|\n|SCK|26|Serial clock|\n|SD|21|Serial data|\n\n# Wiring up the ICS-43434\n\nThis is a better microphone (IMHO) with a less popular breakout board that I sell... [Available Here](https://www.tindie.com/products/21519/)\n|ICS43434 | ESP32| Info|\n|---|---|---|\n|VDD|3v3|Power - DO NOT USE 5V!|\n|GND|GND|GND|\n|LR|GND|Left channel or right channel|\n|WS|22|Left right clock|\n|SCK|26|Serial clock|\n|SD|21|Serial data|\n\nFeel free to change the pins - but make sure you adjust the code to match.\n\nYou should see a waveform that looks like this if you whistle (if you can't whistle - try screaming 😱).\n\n![Whistling](./images/whistling.png)\n\nOnce you've got your microphone up and running, here are some projects that you might enjoy: [Audio Project Playlist](https://www.youtube.com/playlist?list=PL5vDt5AALlRfGVUv2x7riDMIOX34udtKD)\n"
  },
  {
    "path": "i2s_mic_test/i2s_mic_test.ino",
    "content": "#include <driver/i2s.h>\n\n// you shouldn't need to change these settings\n#define SAMPLE_BUFFER_SIZE 512\n#define SAMPLE_RATE 8000\n// most microphones will probably default to left channel but you may need to tie the L/R pin low\n#define I2S_MIC_CHANNEL I2S_CHANNEL_FMT_ONLY_LEFT\n// either wire your microphone to the same pins or change these to match your wiring\n#define I2S_MIC_SERIAL_CLOCK GPIO_NUM_32\n#define I2S_MIC_LEFT_RIGHT_CLOCK GPIO_NUM_25\n#define I2S_MIC_SERIAL_DATA GPIO_NUM_33\n\n// don't mess around with this\ni2s_config_t i2s_config = {\n    .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),\n    .sample_rate = SAMPLE_RATE,\n    .bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,\n    .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,\n    .communication_format = I2S_COMM_FORMAT_I2S,\n    .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,\n    .dma_buf_count = 4,\n    .dma_buf_len = 1024,\n    .use_apll = false,\n    .tx_desc_auto_clear = false,\n    .fixed_mclk = 0};\n\n// and don't mess around with this\ni2s_pin_config_t i2s_mic_pins = {\n    .bck_io_num = I2S_MIC_SERIAL_CLOCK,\n    .ws_io_num = I2S_MIC_LEFT_RIGHT_CLOCK,\n    .data_out_num = I2S_PIN_NO_CHANGE,\n    .data_in_num = I2S_MIC_SERIAL_DATA};\n\nvoid setup()\n{\n  // we need serial output for the plotter\n  Serial.begin(115200);\n  // start up the I2S peripheral\n  i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);\n  i2s_set_pin(I2S_NUM_0, &i2s_mic_pins);\n}\n\nint32_t raw_samples[SAMPLE_BUFFER_SIZE];\nvoid loop()\n{\n  // read from the I2S device\n  size_t bytes_read = 0;\n  i2s_read(I2S_NUM_0, raw_samples, sizeof(int32_t) * SAMPLE_BUFFER_SIZE, &bytes_read, portMAX_DELAY);\n  int samples_read = bytes_read / sizeof(int32_t);\n  // dump the samples out to the serial channel.\n  for (int i = 0; i < samples_read; i++)\n  {\n    Serial.printf(\"%ld\\n\", raw_samples[i]);\n  }\n}\n"
  }
]