Reading INMP441 mic with ESP32


Im experimenting with ESP32 and integration as sound detection

I have INMP441 mic and ESP32 dev board.

I connected HA esphome the the dev board successfully.

At first i want to create something simple with the mic - detect any sound on mic and report it in HA dashboard as binary switch/sensor (i.e. sound/no-sound) - can anyone share an example?

Tried to look in web didn’t find such simple example, all are focused on HA voice assistance activation which im not interested for now

Laster on my end project would need to detect a specific beep sound frequency, using some kind of FIR filter, i have seen standalone ESP32 projects but w/o HA integration on this - I wonder if anyone have done something like that

Not sure if this base would help you. I have used this to data-log noise levels around my home.

1 Like

im trying first the minimal config mentioned there:
but after it flushes, the esp32 web server is not responding (my guess stuck in something but dont knoe how to debug this)

here is my esphome yaml

  name: esphome-web-16ae04
  friendly_name: ESPHome Web 16ae04

  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: false
    name: esphome.web
    version: '1.0'

  board: esp32dev
    type: arduino

# Enable logging
  # level: DEBUG

# Enable Home Assistant API

# Allow Over-The-Air updates

# Allow provisioning Wi-Fi via serial

  # Set up a wifi access point
  ap: {}

# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.

  package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
  import_full_config: true

# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
  authorizer: none

# To have a "next url" for improv serial

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

  bck_pin: 25
  ws_pin: 26
  din_pin: 33
  sample_rate: 48000            # default: 48000
  bits_per_sample: 32           # default: 32

  # right shift samples.
  # for example if mic has 24 bit resolution, and i2s configured as 32 bits,
  # then audio data will be aligned left (MSB) and LSB will be padded with
  # zeros, so you might want to shift them right by 8 bits
  bits_shift: 8                 # default: 0

  # update_interval specifies over which interval to aggregate audio data
  # you can specify default update_interval on top level, but you can also
  # override it further by specifying it on sensor level
  update_interval: 1s           # default: 60s

  # buffer_size is in samples (not bytes), so for float data type
  # number of bytes will be buffer_size * 4
  buffer_size: 1024             # default: 1024

  # see your mic datasheet to find sensitivity and reference SPL.
  # those are used to convert dB FS to db SPL
  mic_sensitivity: -26dB        # default: empty
  mic_sensitivity_ref: 94dB     # default: empty

  # for flexibility sensors are organized hierarchically into groups.
  # each group can have any number of filters, sensors and nested groups.
  # for examples if there is a top level group A with filter A and nested
  # group B with filter B, then for sensors inside group B filters A
  # and then B will be applied:
  # groups:
  #   # group A
  #   - filters:
  #       - filter A
  #     groups:
  #       # group B
  #       - filters:
  #           - filter B
  #         sensors:
  #           - sensor X
    - sensors:
        - type: eq
          name: Leq_1s