Setting Up I2S Soundcard on Raspberry Pi: INMP441 Microphone

Protonest IoT
4 min readSep 22, 2024

--

Introduction

If you’ve ever wanted to add high-quality audio input to your Raspberry Pi, then using I2S microphones is the way to go!

Whether you’re working on a voice recognition project, making a cool sound-based gadget, or just curious about what the Pi can do with sound, this guide will walk you through the setup process step-by-step.

Components Needed

  1. INMP441 Omnidirectional Microphone Module I2S Interface MEMS -2
  2. Raspberry Pi 4 — 4GB (Kit)
  3. Jumper Wires — (F-F, F-M, M-M)
  4. Breadboard

Step 01: Connecting the I2S Microphones

First things first, you’ll need to connect two I2S microphones to your Raspberry Pi. Follow the circuit diagram to get the connections right, making sure all the wires go where they’re supposed to.

Once that’s done, you’re ready to move on to the software setup!

Step 02: Adding I2S Sound Card Details to the Raspberry Pi

  • First, you need to power on and enter the Raspberry Pi home window.
  • Open the terminal on your Raspberry Pi
  • To edit the config.txt file, you’ll typically need root privileges. Use a text editor like nano or vim. The config.txt file is located in the /boot/firmware directory. To open it with nano, run:
sudo nano /boot/firmware/config.txt
  • Once the file is open in nano, uncomment “dtparam=i2s=on” and add “dtoverlay=googlevoicehat-souncard”.
  • After making your changes, press CTRL + X to exit, then press Y to confirm saving the changes, and hit Enter to write the changes to the file.
  • After editing, reboot the Raspberry Pi for the changes to take effect by enter following command on terminal,
sudo reboot

Step 03: Test the I2S Soundcard

  • Power on the Raspberry Pi, enter the home window, and open the terminal.
  • Enter arecord -l to confirm that the I2S sound card is activated.
  • Note the card number that appears from the above command. You can record a mono .wavfile by entering the following command in the terminal.
    (Note 1: Change the "3" in plughw:3 to match the card number from the previous step.)
    (Note 2: You can change the .wav file name by replacing "file" in file.wav with your desired name.)
arecord -D plughw:3 -c1 -r 48000 -f S32_LE -t wav -V mono -v file.wav

Note: Press Ctrl+C to end the end the recording.

  • You can record stereo sound using two microphones by entering the following command.
arecord -D plughw:3 -c2 -r 48000 -f S32_LE -t wav -V stereo -v file_stereo.wav

Note: Press Ctrl+C to end the end the recording.

  • If you have connected speakers to the Raspberry Pi, you can play the recorded file using the following command. (Replace the file name with the name of the file you recorded previously.)
aplay file.wav

You’ve successfully set up and tested I2S microphones on your Raspberry Pi.

Now you’re ready to record high-quality audio for whatever project you’re working on.

From voice commands to ambient sound collection, the possibilities are endless.

Have fun experimenting, and don’t hesitate to explore new ways to enhance your Pi’s audio capabilities!

Hope you enjoyed the article. Please comment below or send us an email to info@protonest.co, if you face any issues when implementing.

Contact us for any consultations or projects related to IoT and embedded systems.

Email: info@protonest.co

Protonest for more details.

Protonest specializes in transforming IoT ideas into reality. We offer prototyping services from concept to completion. Our commitment ensures that your visionary IoT concepts become tangible, innovative, and advanced prototypes.

Our Website: https://www.protonest.co/

Cheers!

--

--

Protonest IoT
Protonest IoT

Written by Protonest IoT

We make your IoT ideas a reality

No responses yet