Infineon Technologies KIT_IM69D127V11_FLEX Microphone Flex Eval Kit

how to record audio from a Infineon Technologies KIT_IM69D127V11_FLEX Microphone Flex Eval Kit
Datasheet
Datasheet

What's your question?

I have IM69D127V11 this microphone and its flex adapter and the datasheet of both is in above question
i need to record audio from microphone using Arduino uno
and the output of IM69D127V11 microphone is PDM
i had write the code to read data from it and send the data through serial port in which python code should record the audio and save it

pin connection: from Flex kit to arduino

  1. V = 3.3v
    2)S=GND
    3)D=SDA
    4)C=SCA
    as shown in pinout diagram of arduino uno r3

the audio is recording but there is no human voice its just beeping

find the below attachments code

const int microphonePin = SDA; 
const int sampleRate = 44100; // Sample rate in Hz
const int sampleBits = 12;    // 12-bit resolution
const int numChannels = 1;    // Number of audio channels

void setup() {
  Serial.begin(115200); // Start serial communication
 
}

void loop() {
  // Capture audio data from the microphone
  int audioValue = analogRead(microphonePin); // Read audio data
  
  // Send the audio value to the PC over the serial connection
  Serial.println(audioValue);
  
  // Adjust the delay to control the sample rate
  delayMicroseconds(1000 / sampleRate); // Delay to achieve the desired sample rate
}

Python code is : -

import serial
import wave
import struct

# Define the COM port and baud rate (adjust as needed)
port = 'COM14'  # Replace with your Arduino's COM port
baud_rate = 115200  # Make sure it matches your Arduino's baud rate

# Define audio file settings
output_file = 'recorded_audio.wav'
sample_width = 2  # 16-bit audio
sample_rate = 44100
channels = 1

# Open a serial connection to the Arduino
ser = serial.Serial(port, baud_rate)

# Create a WAV file for recording
wf = wave.open(output_file, 'wb')
wf.setnchannels(channels)
wf.setsampwidth(sample_width)
wf.setframerate(sample_rate)

try:
    print("Recording audio...")

    while True:
        # Read data from the Arduino
        data = ser.read(2)  # Assuming 16-bit audio, so read 2 bytes at a time

        if len(data) == 2:
            # Convert the received bytes to a signed integer
            audio_value = struct.unpack('<h', data)[0]

            # Write the audio value to the WAV file
            wf.writeframes(struct.pack('<h', audio_value))

except KeyboardInterrupt:
    print("Recording stopped by user.")

finally:
    wf.close()  # Close the WAV file
    ser.close()  # Close the serial connection
    print("Finished recording.")

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.