Projet

Général

Profil

Document 1

Documentation utilisateur
21/03/2023

#include <driver/i2s.h>

// Connections to INMP441 I2S microphone
#define I2S_WS 26
#define I2S_SD 33
#define I2S_SCK 32

#define SAMPLE_RATE 44100 // Taux d'échantillonnage du microphone

void setup() {
// Configuration du microphone INMP441
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = 44100,
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = 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};
const i2s_pin_config_t pin_config = {
.bck_io_num = I2S_SCK,
.ws_io_num = I2S_WS,
.data_out_num = -1,
.data_in_num = I2S_SD
};

i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
i2s_set_pin(I2S_NUM_0, &pin_config);
Serial.begin(115200);
}

void loop() {
// Lecture de données audio depuis le microphone INMP441
uint32_t samples8;
size_t bytes_read;
i2s_read(I2S_NUM_0, samples, sizeof(samples), &bytes_read, 100);
Serial.println(samples0); // Affiche la valeur du premier échantillon

}

Fichiers