Hi everyone,
I'm trying to connect an ICS-43434 I²S microphone to an Arduino MKRZero, but I'm not getting any meaningful data.
Here’s how I’ve wired it:
- VCC → 3.3V
- GND → GND
- WS → D3
- CLK → D2
- DATA → A6
I also tried swapping WS and CLK (as some forums suggested), but that didn’t help.
My code attempts to read and print I²S samples to the Serial Monitor, but I either get “Error reading from I2S” or all-zero samples, no matter the sound input.
Could anyone help me troubleshoot this?
Here is my code:
#include <I2S.h>
unsigned long timestamp = 0;
int sample = 0;
int hangLimit = 10000;
int hangCount = hangLimit;
void setup() {
// Start the serial communication
Serial.begin(115200);
while (!Serial) {;}
// Initialize I2S communication with proper sample rate (48kHz) and 32-bit data width
Serial.println("Initializing I2S...");
if (!I2S.begin(I2S_PHILIPS_MODE, 48000, 32)) {
Serial.println("Failed to initialize I2S!");
while (1) {;}
}
Serial.println("I2S initialized.");
}
void loop() {
// Read a sample from the I2S microphone
sample = I2S.read();
// Debugging I2S read errors
if (sample == -1) {
Serial.println("Error reading from I2S.");
} else if (sample == 0) {
Serial.println("I2S returned zero.");
} else {
timestamp = micros();
// Print timestamp and sample to Serial
Serial.print(timestamp);
Serial.print(",");
Serial.println(sample);
// Reset hang count
hangCount = hangLimit;
}
// If no data is being received, decrement hangCount
if (sample == -1) {
hangCount--;
}
// If the system stops reading samples, notify via Serial
if (hangCount == 0) {
Serial.println("Arduino has stopped reading I2S!");
while (1) {;}
}
}