Noob Question. INMP441. ESP32dev

I started a few days ago, with microelectronics, and esp´s.

I am able to program in vb.net, but Yaml is always a bit hard, especially with the intentions and so on ^^^

I try now already 2 days, to get the INMP441-Microphone to work, but I just get it kinda working as DB-Meter

with this config:

esphome:
  name: esp32-02
  friendly_name: esp32_02

esp32:
  board: esp32dev
  framework:
    type: arduino

external_components:
  - source: github://stas-sl/esphome-sound-level-meter

# Enable logging
logger:
  level: DEBUG
  logs:
    i2s: DEBUG
    microphone: DEBUG
    sound_level_meter: DEBUG

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxxxxxxxx"

ota:
  platform: esphome
  password: "xxxxxxxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
  ap:
    ssid: "Esp32-02 Fallback Hotspot"
    password: "eVv4rVmMxxfi"

captive_portal:





###########################################################
#  INMP441 I²S-MEMS-Mikrofon (Arduino-Framework)
#
#  SD  → GPIO32
#  WS  → GPIO15
#  SCK → GPIO14
#  VDD → 3V3
#  GND → GND
###########################################################
i2s:
  bck_pin: GPIO14         # Serial Clock (SCK)
  ws_pin: GPIO15        # Word Select (WS)
  din_pin: GPIO32        # Serial Data (SD)
  sample_rate: 48000     # 48 kHz
  bits_per_sample: 32    # 32 Bit (MIC liefert 24 Bit + 8 Bit Padding)
  bits_shift: 8          # Rechts‐Shift um 8 Bit für 24→32 Bit Alignment
  use_apll: true         # Optional: präziserer Takt

###########################################################
#  Sound Level Meter (External Component)
###########################################################
sound_level_meter:
  id: sound_level_meter1
  update_interval: 1s
  buffer_size: 1024
  warmup_interval: 500ms
  mic_sensitivity: -26dB
  mic_sensitivity_ref: 94dB
  offset: 0dB
  groups:
    - sensors:
        - type: eq
          name: "Leq_1s"

###########################################################
#  Schalter zum Ein/Abschalten des Sound-Meters
###########################################################
switch:
  - platform: template
    name: "Decibel Meter ON/OFF"
    lambda: |-
      return id(sound_level_meter1).is_on();
    turn_on_action:
      - sound_level_meter.turn_on: sound_level_meter1
    turn_off_action:
      - sound_level_meter.turn_off: sound_level_meter1
    restore_mode: RESTORE_DEFAULT_ON

  - platform: restart
    name: "Decibel Meter Reset"

###########################################################
#  System-Sensoren
###########################################################
sensor:
  - platform: wifi_signal
    name: "WiFi ESP32"
    update_interval: 60s

binary_sensor:
  - platform: status
    name: "ESP32 Status"

I tried now everthing i can imagine. I tried different GPT-Models for help, i googled like a maniac but i cant get this thing to work.

As soon as i want to use this mic, to stream audio to my HA, i always seem to have to change:

from, i2s to i2s_Audio, preferable in the esp-ide.

But i cant get any signal even no mention of i2S_audio even initializing or so…

My current theory is that i don’t set the values correct, the mic delivers 24 bit audio + 8 bit padding.

I think that every version of an i2S_Audio Microphone was doomed cause i dont find anything how to set this bitshift in I2S Audio.

Does someone has this mic running for them and can give me some hints or ideas ?

Edit:

this is my current try with i2s_audio:

esphome:
  name: esp32-02
  friendly_name: esp32_02

esp32:
  board: esp32dev
  framework:
    type: esp-idf
    version: recommended

external_components:
  - source: github://stas-sl/esphome-sound-level-meter

# Enable logging
logger:
  level: DEBUG
  logs:
    i2s_audio: DEBUG
    microphone: DEBUG

# Enable Home Assistant API
api:
  encryption:
    key: "2FaGoZVe8OwVAjwv3X4n0f9WXPgonBMN8qCCdFGbqSU="

ota:
  platform: esphome
  password: "b2dfc90bd3b3dba1075d977caf95d0c5"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
  ap:
    ssid: "Esp32-02 Fallback Hotspot"
    password: "eVv4rVmMxxfi"

captive_portal:




i2s_audio:
  - i2s_lrclk_pin: GPIO14
    i2s_bclk_pin: GPIO15
    id: i2s_Audio_1

microphone:
  - platform: i2s_audio
    i2s_audio_id: i2s_Audio_1
    id: microphone_in
    i2s_din_pin: GPIO32
    adc_type: external
    channel: left
    pdm: false
    bits_per_sample: 32bit
    bits_per_channel: 24bit
    sample_rate: 16000
    use_apll: True




voice_assistant:
  microphone: microphone_in
  on_start:
    - logger.log: voice_start
  on_tts_start:
    - logger.log: tts_start
  on_tts_end:
    - logger.log: tts_end
  on_end:
    - logger.log: voice_end
    - delay: 1s
  on_error:
    - logger.log: voice_error




###########################################################
#  System-Sensoren
###########################################################
sensor:
  - platform: wifi_signal
    name: "WiFi ESP32"
    update_interval: 60s

binary_sensor:
  - platform: status
    name: "ESP32 Status"

Perhaps this can be of help.
EspHome - INMP441 microphone for voice control - pipeline error - Configuration / Voice Assistant - Home Assistant Community

Disclaimer, I am far from an expert in this stuff.

The esp-idf voice stuff is changing almost daily right now, and any configuration to do with that is very likely to have changed since any code you find on the net was written.

The latest yaml for a working voice assistant on esp32 s3 n16r8 is in the link. It may or may not help.

hm i tried every example i could find, but my log always looks like that:

[11:14:47][C][wifi:600]: WiFi:
[11:14:47][C][wifi:428]:   Local MAC: 78:1C:3C:A5:62:A0
[11:14:47][C][wifi:433]:   SSID: [redacted]
[11:14:47][C][wifi:436]:   IP Address: 10.11.12.18
[11:14:47][C][wifi:439]:   BSSID: [redacted]
[11:14:47][C][wifi:441]:   Hostname: 'esp32-02'
[11:14:47][C][wifi:443]:   Signal strength: -24 dB ▂▄▆█
[11:14:47][C][wifi:447]:   Channel: 8
[11:14:47][C][wifi:448]:   Subnet: 255.255.255.0
[11:14:47][C][wifi:449]:   Gateway: 10.11.12.254
[11:14:47][C][wifi:450]:   DNS1: 8.8.8.8
[11:14:47][C][wifi:451]:   DNS2: 8.8.4.4
[11:14:47][C][logger:224]: Logger:
[11:14:47][C][logger:225]:   Max Level: DEBUG
[11:14:47][C][logger:226]:   Initial Level: DEBUG
[11:14:47][C][logger:228]:   Log Baud Rate: 115200
[11:14:47][C][logger:229]:   Hardware UART: UART0
[11:14:47][C][logger:233]:   Task Log Buffer Size: 768
[11:14:47][C][logger:238]:   Level for 'i2s_audio': DEBUG
[11:14:47][C][logger:238]:   Level for 'microphone': DEBUG
[11:14:47][C][status:034]: Status Binary Sensor 'ESP32 Status'
[11:14:47][C][status:034]:   Device Class: 'connectivity'
[11:14:47][C][captive_portal:089]: Captive Portal:
[11:14:47][C][web_server:285]: Web Server:
[11:14:47][C][web_server:286]:   Address: esp32-02.local:80
[11:14:47][C][mdns:120]: mDNS:
[11:14:47][C][mdns:121]:   Hostname: esp32-02
[11:14:47][C][esphome.ota:073]: Over-The-Air updates:
[11:14:47][C][esphome.ota:074]:   Address: esp32-02.local:3232
[11:14:47][C][esphome.ota:075]:   Version: 2
[11:14:47][C][esphome.ota:078]:   Password configured
[11:14:47][C][safe_mode:018]: Safe Mode:
[11:14:47][C][safe_mode:019]:   Boot considered successful after 60 seconds
[11:14:47][C][safe_mode:021]:   Invoke after 10 boot attempts
[11:14:47][C][safe_mode:022]:   Remain in safe mode for 300 seconds
[11:14:47][C][api:170]: API Server:
[11:14:47][C][api:171]:   Address: esp32-02.local:6053
[11:14:47][C][api:173]:   Using noise encryption: YES
[11:14:47][C][wifi_signal.sensor:010]: WiFi Signal 'WiFi ESP32'
[11:14:47][C][wifi_signal.sensor:010]:   Device Class: 'signal_strength'
[11:14:47][C][wifi_signal.sensor:010]:   State Class: 'measurement'
[11:14:47][C][wifi_signal.sensor:010]:   Unit of Measurement: 'dBm'
[11:14:47][C][wifi_signal.sensor:010]:   Accuracy Decimals: 0

No mention of i2s_audio or the mic ore something…

current config:

esphome:
  name: esp32-02
  friendly_name: esp32_02

esp32:
  board: esp32dev
  framework:
    type: esp-idf
    version: recommended

external_components:
  - source: github://stas-sl/esphome-sound-level-meter

# Enable logging
logger:
  level: DEBUG
  logs:
    i2s_audio: DEBUG
    microphone: DEBUG

# Enable Home Assistant API
api:
  encryption:
    key: "2FaGoZVe8OwVAjwv3X4n0f9WXPgonBMN8qCCdFGbqSU="

ota:
  platform: esphome
  password: "b2dfc90bd3b3dba1075d977caf95d0c5"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
  ap:
    ssid: "Esp32-02 Fallback Hotspot"
    password: "eVv4rVmMxxfi"

captive_portal:




i2s_audio:
  - i2s_lrclk_pin: GPIO15 ##INMP441-WS
    i2s_bclk_pin: GPIO14 ##INMP441-SCK
    id: i2s_Audio_1

microphone:
  - platform: i2s_audio
    i2s_audio_id: i2s_Audio_1
    id: microphone_in
    i2s_din_pin: GPIO32 ##INMP441-SD
    adc_type: external
    channel: left
    pdm: false
    bits_per_sample: 32bit
    correct_dc_offset: true




voice_assistant:
  microphone: microphone_in
  id: va_mic
  noise_suppression_level: 2
  auto_gain: 31dBFS
  volume_multiplier: 2.0
  use_wake_word: true



###########################################################
#  System-Sensoren
###########################################################
sensor:
  - platform: wifi_signal
    name: "WiFi ESP32"
    update_interval: 60s

binary_sensor:
  - platform: status
    name: "ESP32 Status"

This is the schematic of my esp:

maybe it is the problem ? i have 10 of these, and tried 3, same behavior on all of them…

Or can i use i2s instead of this i2s_audio crap ? For Homeassistant use

I think right now, that i2s_audio is broken in EspHome. the old i2s in arduino framework delivers values. but the i2s_audio in ESPHome just delivers no signal.

No matter what. Wasted now 3 whole days for nothing.

Couldn’t you switch the framework to arduino and see if you would get a different result?

1 Like

I am sadly not sure about that.

At least i think that ChatGPT mentioned that i will need the esp-IDE to use that mic then in HomeAssistrant ?

i2s_audio in ESPHome is working fine using esp idf. I use it every day. The only difference is the board I use. I use esp32 s3 n16r8.

I have no idea about using the mic as a DB meter though.

You could look here. It’s a bit out of date and may not work.

Ok, sounds interesting, do you maybe can provide your working i2s_audio config ?

I tried really everything. 32bit sample size bit 24 bit channel size.
Legacy-Drivers, apll, correct dc offset, various id´s, nearly every combination from gpio pins.

This got so far I was really convinced that all 6 mics that I ordered are broken.
Until I tried an old sample I found online, that uses this mic, as an DB-Meter-Input.

And it is working, I get a DB-Reading that raises if I make loud noise.

I think it could be, because this mic, sends 24-Bit Data + 8 bit of Padding.
I can set the Bitshift in the old i2s.

I2s_audio claims, as far as I read the right thing, that the equivalent in i2s_audio would be Sample Size of 32 Bit, and channel size of 24 bits. But then I still see nothing in the logs.

I dont even see anything in the log, if i2s_audio even initializes or anything.

Im kinda cluelees right now. Cause i cant even find the reason.

And yes i tried nearly every other bit combination, i checked also in every try for both channels one time left one time right.

There is not even a clue, why it is not working. NOTHING…

I kinda started with esphome, cause everywhere It’s said that it just works.
Mostly this seems to be true IF you find a working example online. But in this case… no change, not a single clue why its not working.

I linked to the Code in post 3 that I use. I use the code by steriku in post 2 of that thread. As I said I am no expert, I just use code that i found in that post. Over the last year or so i have used many versions of code, many of which no longer work.

Oh ok, yeah i tried every sample piece of code from this link.
Does nothing sadly.

What bothers me the most is, that it can’t be the Pins, I guess right ? Otherwise, it would not work on the OLD i2s right ?

If it helps I do use different pins to the code I linked to.

I use these

MIC

LRC GPIO5 WS
BLC GPIO6 SCK
Din GPIO4 SD
L/R GND

Speaker

LRC GPIO11
BLC GPIO9
Dout GPIO7

LED

GPIO14

But we are also using different boards to you which may be the real issue.

I ordered now 2 x : Freenove ESP32-WROOM Wireless Board, Dual-Core 32-Bit 240 MHz Mikrocontroller, Python C Code, Beispielprojekte-Tutorial

in the hope that this will work, at least they provide a complete pdf. to this thing, and not only a small picture