Codey OnlineArduino- & ESP32-Komponentenbibliothek › INMP441 microphone
INMP441 microphone
Sensoren

INMP441 microphone

Der INMP441 ist ein digitaler MEMS-Mikrofon, der Audiodaten über eine I2S-Schnittstelle bereitstellt. Verbinde SCK als I2S-Takt, WS als Word-Select- bzw. Links/Rechts-Signal und SD als serielle Audio-Datenleitung, und versorge ihn mit 1,8–3,3 V bei gemeinsamer GND.

Breite: 14 mm

Pinbelegung — INMP441 microphone

Pin Signal Beschreibung
SCK SCK top-left through-hole pin
WS data top-center through-hole pin
L/R digital top-right through-hole pin
SD data bottom-left through-hole pin
VDD power 1.8v - 3.3v bottom-center through-hole pin
GND ground bottom-right through-hole pin

Beispielschaltplan — INMP441 microphone

Von Nach Kabel
board:5V x1:VDD red
board:GND x1:GND black
board:D3 x1:WS green
board:D2 x1:SCK blue
board:D4 x1:SD yellow
board:GND.1 x1:L/R black

Arduino-Beispielcode — INMP441 microphone

Dieses Beispiel wurde für das arduino-uno geschrieben und kompiliergeprüft. Codey Online passt es für jedes andere unterstützte Board an.

// INMP441 microphone example for Arduino Uno
//
// Note: The Arduino Uno (AVR) does not have a built-in I2S peripheral or
// a standard preinstalled I2S library, so this sketch demonstrates a simple
// software-based read of the microphone clock/data lines using direct pin reads.
// This is not a full audio recorder, but it is a beginner-friendly example that
// compiles on Uno and shows how to detect microphone activity.

#include <Arduino.h>

const byte PIN_BCLK = 2;   // SCK on the INMP441
const byte PIN_LRCLK = 3;  // WS on the INMP441
const byte PIN_DATA = 4;   // SD on the INMP441

volatile bool lastBclk = LOW;

uint32_t readOneI2SSample() {
  // Wait for a rising edge on BCLK, then sample DATA.
  bool current = digitalRead(PIN_BCLK);
  while (current == lastBclk) {
    current = digitalRead(PIN_BCLK);
  }
  lastBclk = current;

  uint32_t sample = 0;
  for (int i = 0; i < 24; i++) {
    // Wait for next clock edge
    bool clk = digitalRead(PIN_BCLK);
    while (clk == lastBclk) {
      clk = digitalRead(PIN_BCLK);
    }
    lastBclk = clk;

    sample <<= 1;
    if (digitalRead(PIN_DATA)) {
      sample |= 1;
    }
  }
  return sample;
}

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

  pinMode(PIN_BCLK, INPUT);
  pinMode(PIN_LRCLK, INPUT);
  pinMode(PIN_DATA, INPUT);

  Serial.println("INMP441 microphone demo started");
  Serial.println("L/R connected to GND selects the left channel.");
  Serial.println("Speak near the microphone and watch the values change.");
}

void loop() {
  // The INMP441 sends 24-bit audio data synchronized to BCLK/WS.
  // On an Uno this software example is only suitable for basic learning.
  uint32_t raw = readOneI2SSample();

  // Convert to signed-ish 24-bit range for display.
  int32_t sample = (int32_t)(raw & 0x00FFFFFF);
  if (sample & 0x00800000) {
    sample |= 0xFF000000;
  }

  long magnitude = labs(sample);

  Serial.print("Raw: ");
  Serial.print(sample);
  Serial.print("  Magnitude: ");
  Serial.println(magnitude);

  delay(20);
}

Ähnliche Komponenten

18650 Battery Shield with USB-C Charger and 5V Boost Converter

18650 Battery Shield with USB-C Charger and 5V Boost Converter

2.4 inch OLED Display I2C 3.3V

2.4 inch OLED Display I2C 3.3V

3.5 inch TFT LCD Shield

3.5 inch TFT LCD Shield

50kg Load Cell Weight Sensor

50kg Load Cell Weight Sensor

Bau dein Arduino- oder ESP32-Projekt mit AI

Beschreib einfach, was du bauen willst. Codey Online schreibt den Code, zeichnet den Schaltplan, kompiliert alles und flasht dein Board direkt aus dem Browser.

Kostenlos starten