Installing an CM108 Audio Controller on the Raspberry Pi

Installing a CM108 Audio Controller on the Raspberry Pi

With the publication of the post on Raspberry Pi + Alexa Voice Service I wanted to try this out by myself.
Even though the hardware requirements besides the raspberry pi are pretty low, I was missing a reasonable microphone. As I’m a big fan of Aliexpress I had to wait a couple of weeks, till my CM108 based microphone arrived.

DSC09577-1

As with so many things you are excited about, if some time passes, you might not see this as of much importance as it was before you ordered. I also found some flaws in my project idea, as Alexa Voice Service is English only (right?). So I cannot use it for the kids.

Nevertheless I wanted to use the microphone and see what I can do with it. I plugged it in … and it did not work (which it the usual case in my projects). After some research I found out, that the CM108 Audio Controller might need some more setup and as I struggled a bit, I wrote the process down, and maybe it is helpfully for you as well.

For this I’m using a Raspberry Pi 2, but it should work similar with the Raspberry Pi B+. The microphone was this:
I’m implying, that we are using a fully installed Raspberry Pi with Jessie as operating system.
So plug-in the microphone in one of the USB ports, and start the Pi.

DSC09583-2
I accessed the Pi via SSH (I’m running a headless server), and this is where we start.
First we need to gather some information, for that we enter:

lsusb

Mic001

So the device is found, and it is a CM108, good. As I learned, you have to install a new firmware to make the microphone work. I stumbled upon Liam McLoughlins alias Hexxeh’s github page, where he offers a solution to update your firmware.

Firmware Update

To do this, there are 3 options:
He suggests doing (if you use Raspian (Jessie)):

sudo apt-get install rpi-update
sudo BRANCH=next rpi-update
sudo reboot

or using curl

sudo curl -L --output /usr/bin/rpi-update https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update && sudo chmod +x /usr/bin/rpi-update
sudo BRANCH=next rpi-update
sudo reboot

If you use another platform.

Another way using wget is described on the Adafruit page:

sudo apt-get install git-core
sudo wget https://raw.github.com/Hexxeh/rpi-update/master/rpi-update -O /usr/bin/rpi-update
sudo chmod +x /usr/bin/rpi-update
sudo BRANCH=next rpi-update
sudo reboot

Either way, the firmware should be installed after this.

ALSA configuration

The next step is to tell ALSA, where the microphone is.

The following actions will have an impact on your audio output as well and might break your setup. As I do not need an audio output (I pass the audio via my home server to a Sonos speaker). It is fine for me. But be warned.

Raspian is using Card #0 as default output, which is the build in solution. So we have to switch to another card.

With

cat /proc/asound/cards

you can check, which cards are available.

Mic002

As you now know, which card is the relevant one, create a file to set up your configuration.

sudo nano /etc/asound.conf

Here enter the following code

pcm.!default {
type hw card 1
}
ctl.!default {
type hw card 1
}

Now reboot and we are ready to test.

Test the microphone

I had to do some trial and error on this to find the right command parameters. For me it was:

arecord -f S16_LE -Dplug:default -d 10 test.wav

Mic003

This recorded a 10 second test file, which I was able to access the file via SAMBA and play on my PC.

If this does not work, play around with the parameters, using

arecord -help

One Comment Add yours

  1. Neil says:

    Cannot get this to work at all. Errors with Traceback (most recent call last):
    File “main.py”, line 588, in
    loop()
    File “main.py”, line 506, in loop
    inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NORMAL, config[‘sound’][‘input_device’])
    alsaaudio.ALSAAudioError: Device or resource busy [plughw:1]

Leave a Reply

Your email address will not be published. Required fields are marked *