andreaswatch / rpi-i2s-audio

Stereo configuration on Pi Zero 2W

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I2S Microphone Overlay

Testing Paul's rpi-i2s-audio device tree overlay on Pi Zero2W (Bookworm OS - 6.6.21) 03/17/24

rpi-i2s-mic.dts

This is the overlay for a MEMs microphone, specifically the SPH0645 I2C MIC.

Clone and Compile

Clone repo without history

cd ~
git clone --depth=1 https://github.com/JayIke/rpi-i2s-audio.git

Compile device tree into device tree blob overlay

git clone --depth=1 https://github.com/JayIke/rpi-i2s-audio.git
dtc  -I dts -O dtb -o rpi-i2s-mic.dtbo  rpi-i2s-mic.dts 
sudo cp rpi-i2s-mic.dtbo /boot/firmware/overlays/.
# just to be safe:
sudo cp rpi-i2s-mic.dtbo /boot/overlays/.

Enable overlay in config.txt

echo "dtoverlay=rpi-i2s-mic" | sudo tee -a /boot/firmware/config.txt
sudo reboot

Install Hardware and Test

Check if sound card is available in alsa

arecord -l && arecord -L

Try recording a file and saving it as .wav

arecord -D mic -c 2 -r 48000 -f S32_LE -V stereo -v -t wav test.wav

ADAFRUIT SPH0645 - Stereo Hardware Configuration

LEFT MIC

  • 3.3V Connector Pin 1
  • GND Connector Pin 39
  • LRCL Connector Pin 35 GPIO 19
  • DOUT Connector Pin 37 GPIO 20
  • BCLK Connector Pin 12 GPIO 18
  • SEL Connector Pin 3.3V

RIGHT MIC

  • 3.3V Connector Pin 1
  • GND Connector Pin 5?
  • LRCL Connector Pin 35 GPIO 19
  • DOUT Connector Pin 37 GPIO 20
  • BCLK Connector Pin 12 GPIO 18
  • SEL Connector Pin GND

i2s_audio_read_test.py

Simple demo application for recording audio from I2S mems mic

Warning

After looking at the raw data via python using the sounddevice module, it seems there is a dc offset in the output data. Subtracting the mean or high pass filtering can be used to remove this offset. During playback you will hear a pop or click when audio playback starts or finishes.

About

Stereo configuration on Pi Zero 2W


Languages

Language:C 73.6%Language:Python 25.8%Language:Makefile 0.6%