Werktags vor 14:00 Uhr bestellt = am selben Tag versendet 30 Tage Widerrufsrecht 1 Jahr Garantie
← Zurück zur Übersicht

Schaltplan und Codebeispiel

So schließt du den Omnidirektionales Mikrofon INMP441 MEMS 3.3V an einen Arduino UNO oder ESP32 an, mit einem Beispiel-Sketch, den du direkt hochladen kannst.

INMP441 I2S-Mikrofon mit Arduino Uno

Dieses Projekt verbindet ein digitales, omnidirektionales INMP441 I2S-Mikrofon mit einem Arduino Uno. Der Uno erzeugt die I2S-Bitclock (SCK) und das Word-Select-Signal (WS) per Software, um 24-bit-Audio-Samples von der SD-Leitung auszulesen. Öffnen Sie den Seriellen Monitor oder den Serial Plotter mit 115200 baud, um die schwankenden Schallpegel in Echtzeit zu sehen.

Anschlussplan: Omnidirektionales Mikrofon INMP441 MEMS 3.3V an einem Arduino UNO
Anschlussplan · Zum Vergrößern klicken
Anschlusstabelle: Omnidirektionales Mikrofon INMP441 MEMS 3.3V an einem Arduino UNO
Anschlusstabelle · Zum Vergrößern klicken
INMP441_I2S_Microphone_with_Arduino_Uno.ino · kompiliert und getestet
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : INMP441 I2S Microphone with Arduino Uno
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : INMP441 microphone
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

// INMP441 I2S Microphone demonstration on Arduino Uno

const int PIN_SCK = 2; // Serial Clock (SCK)
const int PIN_WS  = 3; // Word Select / LRCLK (WS)
const int PIN_SD  = 4; // Serial Data (SD)

void setup() {
  Serial.begin(115200);

  pinMode(PIN_SCK, OUTPUT);
  pinMode(PIN_WS, OUTPUT);
  pinMode(PIN_SD, INPUT);

  digitalWrite(PIN_SCK, LOW);
  digitalWrite(PIN_WS, LOW);

  Serial.println(F("INMP441 Microphone Demo Initialized."));
  Serial.println(F("Speak or make noise near the microphone."));
}

// Bit-bang 32 clock pulses per channel and sample 24-bit audio
int32_t readI2SSample() {
  int32_t sample = 0;

  // Select Left Channel
  digitalWrite(PIN_WS, LOW);

  // I2S standard has 1-bit delay before MSB
  for (int bit = 0; bit < 32; bit++) {
    digitalWrite(PIN_SCK, HIGH);
    digitalWrite(PIN_SCK, LOW);

    if (bit > 0 && bit <= 24) {
      sample = (sample << 1) | digitalRead(PIN_SD);
    }
  }

  // Select Right Channel to complete stereo frame
  digitalWrite(PIN_WS, HIGH);
  for (int bit = 0; bit < 32; bit++) {
    digitalWrite(PIN_SCK, HIGH);
    digitalWrite(PIN_SCK, LOW);
  }

  // Sign-extend 24-bit to 32-bit signed integer
  if (sample & 0x00800000) {
    sample |= 0xFF000000;
  }

  return sample;
}

void loop() {
  int32_t rawSample = readI2SSample();
  int32_t magnitude = abs(rawSample);

  Serial.print(F("Raw: "));
  Serial.print(rawSample);
  Serial.print(F("\tMagnitude: "));
  Serial.println(magnitude);

  delay(20);
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online

INMP441 I2S Schallpegelmesser

Liest digitale Audiodaten vom omnidirektionalen I2S-Mikrofon INMP441 und berechnet Lautstärkewerte in Echtzeit. Öffne den Serial Monitor oder Serial Plotter mit 115200 baud, um Umgebungsgeräusche und Sprachamplitude zu visualisieren.

Anschlussplan: Omnidirektionales Mikrofon INMP441 MEMS 3.3V an einem ESP32 DevKit V1
Anschlussplan · Zum Vergrößern klicken
Anschlusstabelle: Omnidirektionales Mikrofon INMP441 MEMS 3.3V an einem ESP32 DevKit V1
Anschlusstabelle · Zum Vergrößern klicken
INMP441_I2S_Sound_Level_Meter.ino · kompiliert und getestet
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : INMP441 I2S Sound Level Meter
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : INMP441 microphone
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#include <driver/i2s.h>

#define I2S_WS   15
#define I2S_SD   32
#define I2S_SCK  14
#define I2S_PORT I2S_NUM_0
#define BUFFER_LEN 64

int32_t samples[BUFFER_LEN];

void setup() {
  Serial.begin(115200);

  const i2s_config_t i2s_config = {
    .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
    .sample_rate = 16000,
    .bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,
    .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
    .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S),
    .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
    .dma_buf_count = 4,
    .dma_buf_len = BUFFER_LEN,
    .use_apll = false
  };

  const i2s_pin_config_t pin_config = {
    .bck_io_num = I2S_SCK,
    .ws_io_num = I2S_WS,
    .data_out_num = I2S_PIN_NO_CHANGE,
    .data_in_num = I2S_SD
  };

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

void loop() {
  size_t bytes_read = 0;
  i2s_read(I2S_PORT, &samples, sizeof(samples), &bytes_read, portMAX_DELAY);

  int samples_read = bytes_read / sizeof(int32_t);
  int64_t sum = 0;

  for (int i = 0; i < samples_read; i++) {
    int32_t sample = samples[i] >> 14;
    sum += abs(sample);
  }

  if (samples_read > 0) {
    int32_t sound_level = sum / samples_read;
    Serial.print("SoundLevel:");
    Serial.println(sound_level);
  }

  delay(20);
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Zuletzt angesehen

2.4Ghz WiFi-Antenne mit SMA- auf uFL Ipex-Stecker

2.4Ghz WiFi-Antenne mit SMA- auf uFL Ipex-Stecker

€ 2,30
Mini-Testclip mit Federhaken für PCB SMD IC 43mm - Rot

Mini-Testclip mit Federhaken für PCB SMD IC 43mm - Rot

€ 0,80
8-bit RGB LEDs WS2812b Kreis rund (Neopixel)

8-bit RGB LEDs WS2812b Kreis rund (Neopixel)

€ 1,90
Velleman Labornetzteil, regelbar, 0-15 VDC/0-3 A. LABPS1503

Velleman Labornetzteil, regelbar, 0-15 VDC/0-3 A. LABPS1503

€ 89,00
Ansehen
620-teiliges Dupont Connector Set 2.54mm

620-teiliges Dupont Connector Set 2.54mm

€ 11,40
Peltier-Modul 12V 36W 40x40mm TEC1-12704

Peltier-Modul 12V 36W 40x40mm TEC1-12704

€ 6,65
USB-C Male zu Micro-USB Female Adapter  - schwarz

USB-C Male zu Micro-USB Female Adapter - schwarz

€ 2,10
USB-Lademodul: DC-DC Step-Down-Wandler - 6V ~ 24V 12V auf 5V 3A

USB-Lademodul: DC-DC Step-Down-Wandler - 6V ~ 24V 12V auf 5V 3A

€ 2,50
10x Widerstand 220 Ohm 1/4 Watt 5% (LED Vorwiderstand)

10x Widerstand 220 Ohm 1/4 Watt 5% (LED Vorwiderstand)

€ 1,25
40-adrig 2.54mm 28AWG Dupont pro Meter

40-adrig 2.54mm 28AWG Dupont pro Meter

€ 3,90
Marble Spiral Lift für Marblelous Kugelbahn

Marble Spiral Lift für Marblelous Kugelbahn

€ 79,00
Ansehen
farbige Kappe für Druckknopf ot3321 SCHWARZ

farbige Kappe für Druckknopf ot3321 SCHWARZ

€ 0,65
Integral 32GB V10 High Speed microSDHC-Karte Class 10 - 100MB/s mit SD-Adapter

Integral 32GB V10 High Speed microSDHC-Karte Class 10 - 100MB/s mit SD-Adapter

€ 11,49
Ansehen
1-Kanal-Relaismodul, Trigger-Zeitverzögerung, Einstellbar 6-30V

1-Kanal-Relaismodul, Trigger-Zeitverzögerung, Einstellbar 6-30V

€ 7,95