Help with I2S Microphone Configuration (INMP441) on ESP32 using ESPHome

Hello ESPHome Community!

I’m trying to set up an INMP441 I2S microphone with my ESP32-WROVER-KIT to stream audio over MQTT. I’ve followed the ESPHome documentation, but I keep running into issues with the configuration. I’m looking for help with correctly setting up the I2S audio capture and sending the data to my MQTT broker.

Hardware Setup:

  • Microphone: INMP441 (I2S microphone)
  • ESP32 Board: ESP32-WROVER-KIT
  • I2S Pin Connections:
INMP441 Pin ESP32 Pin Description
VCC 3.3V Power supply (3.3V)
GND GND Ground
SCK GPIO14 Serial Clock (SCK)
WS GPIO15 Word Select (LRCLK)
SD GPIO32 Serial Data (SD)
L/R GND

ESP32-WROVER-KIT Pinout:

The ESP32-WROVER-KIT has multiple available pins for I2S functionality, and GPIO14, GPIO15, and GPIO32 are often used for I2S data. These should work well with the INMP441 microphone.

My ESPHome Configuration:

esphome:
  name: audio_streamer
  platform: ESP32
  board: esp32wrover-kit  # Board setup for ESP32-WROVER-KIT

wifi:
  ssid: "YOUR_SSID"
  password: "YOUR_PASSWORD"

logger:
api:
ota:

mqtt:
  broker: "YOUR_MQTT_BROKER_IP"  # IP of your MQTT broker
  username: "YOUR_MQTT_USERNAME"
  password: "YOUR_MQTT_PASSWORD"
  topic_prefix: "audio_streamer"

# I2S microphone configuration (e.g., INMP441)
i2s_audio:
  i2s_id: 0
  sck_pin: GPIO14    # Serial Clock (SCK) pin
  ws_pin: GPIO15     # Left-Right Clock (LRCLK or WS) pin
  sd_pin: GPIO32     # Serial Data (SD) pin
  i2s_lrclk_pin: GPIO15  # Explicitly specify the Left-Right Clock (LRCLK) pin
  sample_rate: 16000
  bits_per_sample: 16
  channel_format: I2S_CHANNEL_FMT_ONLY_LEFT  # Use mono audio (one channel)
  update_interval: 1s  # Update the sensor every second (adjust as needed)

sensor:
  - platform: i2s_audio
    name: "I2S Microphone"
    id: microphone_sensor
    on_value:
      then:
        - mqtt.publish:
            topic: "audio/data"
            payload: !lambda 'return id(microphone_sensor).state;'

api:
  services:
    - service: play_audio
      variables:
        audio_data: string
      then:
        - logger.log: 'Received audio data:'
        - logger.log: '  Audio: !audio_data'

Issue:

When I try to compile the configuration, I get the error:

`i2s_lrclk_pin` is a required option for [0]. Did you mean [i2s_lrclk_pin], [i2s_mclk_pin], [i2s_bclk_pin]?

I’ve checked the documentation and found that the i2s_lrclk_pin option should be required, but I’m unsure of how to properly configure it for my INMP441.

Questions:

  1. Correct Pin Configuration: Am I wiring the INMP441 correctly to the ESP32-WROVER-KIT? Should I use GPIO14, GPIO15, and GPIO32 for the SCK, LRCLK/WS, and SD pins respectively?
  2. Correct ESPHome Configuration: Is my ESPHome configuration missing any other necessary parameters? Specifically, I’m unsure about the i2s_lrclk_pin setting.

This is the doc for i2s

Your yaml looks very different. I am not sure it matters much which pins you use. Where are you getting this yaml configuration from?

is this some ChatGPT fantasy?

1 Like