-
-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Hey! I have lillygo ttgo t-camera module with i2s mic. Initially I used https://github.com/atomic14/esp32_audio/tree/master/i2s_sampling project, configured pins and all worked fine.
(from working code)
// i2s config for reading from left channel of I2S
i2s_config_t i2sMemsConfigLeftChannel = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = 32000,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S_LSB, //i2s_comm_format_t(I2S_COMM_FORMAT_I2S),
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 4,
.dma_buf_len = 1024,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0};
// i2s pins
i2s_pin_config_t i2sPins = {
.bck_io_num = GPIO_NUM_26,
.ws_io_num = GPIO_NUM_32,
.data_out_num = I2S_PIN_NO_CHANGE,
.data_in_num = GPIO_NUM_33};
Next, i have tried this your project https://github.com/atomic14/diy-alexa. This is not working for me. I founded in issues, that you have recomended to check micro by this mic-test project.
But when i'm using this mic-test code, I can only get this

or only zeroes at all. I tried to copy i2s and pins config areas from working code, swap pins between each other, change sample rate, sample bit and buffer size. I founded only one different between codes:
.communication_format = I2S_COMM_FORMAT_I2S_LSB, in working code
.communication_format = I2S_COMM_FORMAT_I2S, in borken code
I have replaced this line too.
But nothing could not help.
Have you any ideas?
This is my full testing code
#include <driver/i2s.h>
// you shouldn't need to change these settings
#define SAMPLE_BUFFER_SIZE 512
#define SAMPLE_RATE 32000
// most microphones will probably default to left channel but you may need to tie the L/R pin low
#define I2S_MIC_CHANNEL I2S_CHANNEL_FMT_ONLY_LEFT
// either wire your microphone to the same pins or change these to match your wiring
#define I2S_MIC_SERIAL_CLOCK GPIO_NUM_26
#define I2S_MIC_LEFT_RIGHT_CLOCK GPIO_NUM_32
#define I2S_MIC_SERIAL_DATA GPIO_NUM_33
// don't mess around with this
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = 32000,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S_LSB, //i2s_comm_format_t(I2S_COMM_FORMAT_I2S),
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 4,
.dma_buf_len = 1024,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0};
// and don't mess around with this
i2s_pin_config_t i2s_mic_pins = {
.bck_io_num = GPIO_NUM_26,
.ws_io_num = GPIO_NUM_32,
.data_out_num = I2S_PIN_NO_CHANGE,
.data_in_num = GPIO_NUM_33};
void setup()
{
// we need serial output for the plotter
Serial.begin(115200);
// start up the I2S peripheral
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
i2s_set_pin(I2S_NUM_0, &i2s_mic_pins);
}
int32_t raw_samples[SAMPLE_BUFFER_SIZE];
void loop()
{
// read from the I2S device
size_t bytes_read = 0;
i2s_read(I2S_NUM_0, raw_samples, sizeof(int32_t) * SAMPLE_BUFFER_SIZE, &bytes_read, portMAX_DELAY);
int samples_read = bytes_read / sizeof(int32_t);
// dump the samples out to the serial channel.
for (int i = 0; i < samples_read; i++)
{
Serial.printf("%ld\n", raw_samples[i]);
}
}
