ESP32 with INMP441 only microphone yaml needed

Hello, I kindly need a functional YAML configuration for ESP32 with INMP441, which I want to use only as an I2S microphone for monitoring noise levels in a room. I don’t need a YAML for a complete voice assistant. Thank you.

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: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

ota:
  platform: esphome
  password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

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  → GPIO21
#  WS  → GPIO15
#  SCK → GPIO14
#  VDD → 3V3
#  GND → GND
###########################################################
i2s:
  bck_pin: GPIO18        # Serial Clock (SCK)
  ws_pin: GPIO22        # Word Select (WS)
  din_pin: GPIO21        # 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"

This works as DB Meter.

1 Like

Hi,

You made my day … was able with your code to implement 2 soundmeters !!!

many many thanks !

Fred.