#include <driver/i2s_std.h>
i2s_chan_handle_t rx_chan;
void setup() {
Serial.begin(115200);
i2s_chan_config_t chan_cfg =
I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_MASTER);
i2s_new_channel(&chan_cfg, NULL, &rx_chan);
i2s_std_config_t cfg = {
.clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(16000),
.slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(
I2S_DATA_BIT_WIDTH_32BIT,
I2S_SLOT_MODE_MONO),
.gpio_cfg = {
.mclk = I2S_GPIO_UNUSED,
.bclk = GPIO_NUM_4,
.ws = GPIO_NUM_5,
.dout = I2S_GPIO_UNUSED,
.din = GPIO_NUM_3,
.invert_flags = {
.mclk_inv = false,
.bclk_inv = false,
.ws_inv = false,
}
}
};
i2s_channel_init_std_mode(rx_chan, &cfg);
i2s_channel_enable(rx_chan);
}
void loop() {
int32_t sample;
size_t bytes_read;
if (i2s_channel_read(rx_chan, &sample, sizeof(sample),
&bytes_read, 1000) == ESP_OK) {
Serial.println(sample);
}
}