Use USB Microphone with Raspberry PI OS Lite

4.5
(4)

Last Updated on 6th February 2022 by peppe8o

Some advanced projects with Raspberry Pi can foresee also the use of voice controls. While these projects are not simple to setup (I’m scheduling some tests in the very next future), giving a microphone to your RPI can be a very simple operation. A very interesting project, in this sense, is the Google home assistant project.

USB microphone

Remember that Raspberry Pi doesn’t come with a built-in audio device. A very cheap solution is the use of some USB microphones which can be found on-line, costing a few dollars.

Installing USB microphone from a terminal is simple and is the only way if you don’t have a desktop environment installed.

In this tutorial I’m going to show you how to setup an USB microphone with a Raspberry Pi 3 A+, but the procedure is the same for all recent Raspberry PI models.

What We Need

We’ll use an SSH session to connect our Raspberry Pi, so no USB keyboards or video cables are needed.

As usual, I suggest adding from now to your favourite e-commerce shopping cart all the needed hardware, so that at the end you will be able to evaluate overall costs and decide if continue with the project or remove them from the shopping cart. So, hardware will be only:

Check hardware prices with following links:

Amazon raspberry pi boards box
Amazon Micro SD box
Amazon Raspberry PI Power Supply box

Step-By-Step Procedure

We’ll start from a fresh operating system installation. So, start installing Raspberry PI OS Lite. You can use this also with Raspberry PI OS desktop, working from its internal terminal console.

Once OS is installed and the USB Microphone is plugged in, check the USB device connection:

lsusb

this will show the following output:

USB microphone lsusb cmd

Bus 001 Device 001 is the phisical hub inside RPI board, while Bus 001 Device 002 is my USB microphone. With RPI model B this could show 5 devices, being Raspberry PI model B equipped with 4 USB ports (+ internal hub).

Let’s check the list of audio input devices with the following:

arecord -l

this output should be shown:

USB microphone arecord cmd

So, my microphone matches with card 1 / device 0. This will be mapped in the following with plughw:1,0.

Now, we can test a simple recording by typing:

arecord -D plughw:1,0 -d 3 test.wav

The following output will appear:

USB microphone arecord rec cmd

Now you can simple check this file by connecting and downloading it with your favourite FTP software (for example Filezilla) to your RPI with ad SFTP connection (using your RPI user and password, pi and raspberry if you left the factory ones).

Bonus

Recording volume can be very low in some cases. Alsamixer helps us with a simple interface to manage audio devices volumes. Type in your terminal:

alsamixer

You’ll see the default console:

alsamixer default

Now,  you have to switch to the correct audio device by pressing F6:

alsamixer switch device

In my case, the correct sound card is the one marked as bcm2835 ALSA:

alsamixer bcm

Use up / down arrow keys to regulate at your choice. Press ESC to save and exit. Test againg.

Enjoy!

How useful was this post?

Click on a star to rate it anonymously!

Average rating 4.5 / 5. Vote count: 4

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?