1

I am following the instruction to setup a microphone with an esp32 with arduino cli.

Here is the tutorial

As pointed out in the video (timestamp 14:30 to 15:05), it seems that some functions of the I2S library were downgraded. And, indeed, when I compile the code, I get the following error message:

/Users/me/Documents/cs/microcontrollers/ESP32/microphone/microphone.ino: In function 'void i2s_install()':
/Users/me/Documents/cs/microcontrollers/ESP32/microphone/microphone.ino:33:47: error: 'I2S_COMM_FORMAT_STAND_I2S' was not declared in this scope
     .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S),
                                               ^
Used platform Version Path                                           
esp32:esp32   1.0.6   /Users/me/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6

Error during build: exit status 1

Here is the code:

/*
  ESP32 I2S Microphone Sample
  esp32-i2s-mic-sample.ino
  Sample sound from I2S microphone, display on Serial Plotter
  Requires INMP441 I2S microphone

DroneBot Workshop 2022 https://dronebotworkshop.com */

// Include I2S driver #include <driver/i2s.h>

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

// Use I2S Processor 0 #define I2S_PORT I2S_NUM_0

// Define input buffer length #define bufferLen 64 int16_t sBuffer[bufferLen];

void i2s_install() { // Set up I2S Processor configuration const 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_t(16), .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT, .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S), .intr_alloc_flags = 0, .dma_buf_count = 8, .dma_buf_len = bufferLen, .use_apll = false };

i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL); }

void i2s_setpin() { // Set I2S pin configuration 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_set_pin(I2S_PORT, &pin_config); }

void setup() {

// Set up Serial Monitor Serial.begin(115200); Serial.println(" ");

delay(1000);

// Set up I2S i2s_install(); i2s_setpin(); i2s_start(I2S_PORT);

delay(500); }

void loop() {

// False print statements to "lock range" on serial plotter display // Change rangelimit value to adjust "sensitivity" int rangelimit = 3000; Serial.print(rangelimit * -1); Serial.print(" "); Serial.print(rangelimit); Serial.print(" ");

// Get I2S data and place in data buffer size_t bytesIn = 0; esp_err_t result = i2s_read(I2S_PORT, &sBuffer, bufferLen, &bytesIn, portMAX_DELAY);

if (result == ESP_OK) { // Read I2S data buffer int16_t samples_read = bytesIn / 8; if (samples_read > 0) { float mean = 0; for (int16_t i = 0; i < samples_read; ++i) { mean += (sBuffer[i]); }

  // Average the data reading
  mean /= samples_read;

  // Print to serial plotter
  Serial.println(mean);
}

} }

I also tried to install the I2S library with:

arduino-cli lib install I2S

but got the following error message:

Error installing I2S: Library 'I2S' not found

How can I solve the problem?

EDIT 1

After the comments I tried to Upgrade the ESP32 package. For this I went to Tools -> Boards -> Board Manager, typed ESP32 and got the following window:

enter image description here

It seems to me that I cannot upgrade beyond version 1.0.6 (under Arduino IDE 1.8.19)

What am I doing wrong?

EDIT 2 Ok I followed the installation instruction on the espressif website and it worked

https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html

ecjb
  • 165
  • 6

0 Answers0