Setup for ICS-43434 MEMS i2S microphone on a Raspberry Pi
MIT License
9
stars
4
forks
source link
readme
Setting up the Pesky Products ICS-43434 MEMS microphone breakout on the Raspberry Pi
Hardware Setup
The following documentation used the ICS43434 MEMs microphone with a breakout board on an RPi 2. Microphone documentation can be found here. Header pins were soldered to the breakout board. The connection uses Pulse Code Modulation which requires four GPIO pins from the RPi. The PCM setup can be found here. The connection is as follows:
Mic - RPi
---------
VCC - 3.3v
Gnd - Gnd
L/R - Gnd (this is used for channel selection. Connect to 3.3 or GND)
SCK - BCM 18 (pin 12)
WS - BCM 19 (pin 35)
SD - BCM 20 (pin 38)
Before rebooting do:
sudo nano /boot/config.txt
and uncomment this line by removing the # in front of it.
#dtparam=i2s=on
or add it if it ain't there.
Next do a reboot.
sudo reboot
Next, while the upstream ics43432 codec is not currently supported by current Pi kernel builds, we must it build manually.
Get the source & create a simple Makefile:
mkdir ics43432
cd ics43432
wget https://raw.githubusercontent.com/raspberrypi/linux/rpi-4.4.y/sound/soc/codecs/ics43432.c
nano Makefile
Makefile contents:
obj-m := ics43432.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
install:
sudo cp ics43432.ko /lib/modules/$(shell uname -r)
sudo depmod -a
Those indentations are a single tab character - use spaces & it won't work.
Build:
make all install
Next, we create a new device tree overlay. Create a file i2s-soundcard-overlay.dts with this content:
The volume level is low, and with just one module attached is in one channnel only, silence in the other. Both those issues can be addressed by modifying .asoundrc, see below.
The overlay is flexible enough to use other codecs by way of the compatible= override. If your preferred codec, a simple ADC or DAC, has a .compatible string defined, use that "manufacturer,chipset" string in the override. There's a switch "master" too if your codec is capable of working as clock master instead of the default slave (untested).
To create the soft mixer for volume control I used plugh's work, extending it so that we produce true mono/single channel output. Note that I've configured my mic as left - if yours is right you'll have to edit the mic_mono multi section. If you have a stereo pair, you may omit the last section where mic_mono is defined. Edit the alsa config:
cd ~
nano .asoundrc
And replace the content of the file with:
pcm.mic_hw{
type hw
card memsmic
channels 2
format S32_LE
}
pcm.mic_sv{
type softvol
slave.pcm mic_hw
control {
name "Boost Capture Volume"
card memsmic
}
min_dB -3.0
max_dB 50.0
}
To activate the mixer, we must first make a recording using the newly configured mic_sv pcm:
Now we can tinker with the boost control. In a terminal, run alsamixer, press F6, select device "mems-mic", then F4 for capture controls. A useful boost is 20-30dB.
A mixer is also in the desktop's Audio Device Settings.
Now you can record again, but with the new volume settings: