Adding Sound to Raspberry Pi

I had a Raspberry Pi 3 running an Asterisk phone server.  I wanted to make use of the “console” functionality of Asterisk.  By setting up an audio console, I would be able to make a phone call to the console from any extension, and have whatever audio I speak from the extension play over the console speakers (sort of a paging function).  In addition, by connecting a microphone, I would also be able listen to sounds in the room where the console is located from any extension.

On a regular Linux PC, the Asterisk console is automatically created using the sound card.  However, the Raspberry Pi does not have built in sound.  I considered a couple of different solutions to add sound.  Dedicated hardware is available to add sound to a Raspberry Pi.  However, since that solution is not a standard sound card, I figured it might be difficult to get working with Asterisk.  And the hardware involved costs more than the Raspberry Pi itself!  High-end sound would be overkill for my application.  I still had 3 of the 4 USB ports available on the Raspberry Pi, and USB sound cards are cheap, so I decided to go that route.  I needed to purchase a USB sound card that was compatible with Linux.  I went with the UGREEN USB Audio Adapter.  This particular USB audio card also has a short cable connected to the USB plug – thus ensuring that there is physical room left for existing and future USB hardware.

Using information mainly from the following tutorial, I was able to get sound (both speaker and microphone) working from the Linux command line.

Once this was done, I needed to get Asterisk to recognize this sound card.  I edited the modules.conf file for Asterisk to enable Alsa sound.  However, there was an issue with the load order of the modules.  The module that handles the console driver was getting loaded before the the sound modules were loaded.  Eventually, I figured out that what I needed to do was pre-load the Alsa module, using the following command in modules.conf:

preload =>

I found it was also necessary to use the “plughw:” Alsa device for the console, instead of the normal “hw:” device.  This is because Asterisk requires certain specific sampling rates.  My inexpensive usb sound card did not offer these specific rates, resulting in distorted and choppy audio.  Using the “plughw” device allows the Raspberry Pi itself to resample the audio going in and out of the sound card to match the sampling rates required by Asterisk.


I connected a standard set of amplified PC speakers and a standard PC microphone to the USB sound card.  In the Asterisk extensions.conf file, I programmed an extension to connect to the console device.

This results in a working setup.  I can dial the extension of the Asterisk console from any phone on my system, and make paging announcements over the connected speakers.  I am also able to hear sounds in the room where the console is located through the phone.

While the sound quality of the paging audio is fine, I was disappointed in the quality of sound picked up from the microphone.  There is a noticeable amount of hum present.  Not enough to make the setup unusable, but enough to be annoying.  I suspect that the hum is coming from the USB power supply that I am using to power the Raspberry Pi.  Even though I am using a high-current USB supply designed specifically to power a Raspberry Pi, I suspect it still does not have as good of filtering as the power supply in a regular PC.  Though too small to be noticeable in the strong signal associated with the speaker output, the ripple from this power supply is likely enough to be significant for the small audio signal associated with the microphone.  A possible solution would be to use a USB power supply with better filtering to power the Raspberry Pi.



Review of Qotom Mini PC j1900

Qotom Mini-PC (right), next to AT&T UVerse Router, Phones, and ATA.

Recently, I was running out of processing power on my Raspberry Pi 3.  I was running Asterisk PBX, OpenVPN Server, and several sensor monitoring and MQTT applications.  I wanted to add MySQL Server, but figured that might be pushing things.

My first thought was to run an old desktop PC.  However, I was a bit short on physical space, and didn’t really want a large desktop box.  So I started researching mini-PCs.  I wanted something as powerful as a low-end PC.  Something that didn’t take up much space, and with as few mechanical parts as possible.  After researching what was available, I decided to go with a model made by Qotom.  The model I purchased has an Intel quad-core processor, and 8GB of RAM.  Just like a desktop.  A big plus is that is has 4 Ethernet ports.  That could be useful if I decide to make my own router some day.

This mini-PC consumes a maximum of 10W of power.  This is significantly less than a classic desktop.  I had an old quad-core desktop with comparable specs.  I measured its power consumption – it varied from just over 40W when idle, to over 80W when running CPU-intensive tasks.  The Qotom has no moving parts.  There is a large heat sink in place of a fan, and the hard drive is solid state.  I wondered, though, if a heat sink and no fan would actually keep the device cool.  Turns out, it does.  Here is a thermal picture:

Thermal Image – Qotom Mini-PC (right), next to AT&T UVerse Router and phone.










As you can see, the temperature of the mini-PC (while running Asterisk, OpenVPN, MySQL Server, and several other applications) is around 86 degrees.  This is about 15 degrees warmer than the ambient room temperature, and is comparable to the temperatures of other electronics such as the router and phone.

I created installation media for Ubuntu Light Linux (Lubuntu) using a standard USB thumb drive.  The operating system installation process was almost identical to that of an ordinary PC.  I connected a monitor and Ethernet cable, plugged in the USB keyboard, mouse, and thumb drive, and proceeded with installation.  Because of the SSD hard drive, it actually went faster than on an ordinary desktop PC.  In under an hour, the software, as well as all live updates, was installed.  Initially, the machine booted up to the desktop GUI.  Once I installed OpenSSH to allow me to access the computer through secure shell, I disabled the GUI, and disconnected the keyboard, mouse and monitor.  I then proceeded to install the other software I needed using the command prompt on a remote terminal.

This machine has performed flawlessly for me over the past week and a half.  Not only does it save space over a desktop, but it also saves money on electricity.  If you assume (conservatively, based on my measurements above) that a desktop PC consumes an average of 50W, this setup saves 40W.  That adds up to about 30KWh saved in a month.  If electricity costs 10 cents per KWh, that is a savings of around $3 a month, or $36 a year.

A mini-PC such as this is too specialized to be just walk in and buy at retail stores like Walmart and Best Buy.  It is available on Amazon, for around $200.  If you are an Amazon Prime member, it probably makes the most sense to buy it there, so you can get it in two days.  Actually, in my part of the US there is free one-day delivery for this item.  In fact, I ordered this on Sunday evening and had it by noon on Monday.  If you don’t have Amazon Prime, then eBay may be your best bet for purchasing this.  Some computer specialty stores may also be able to custom-order it, but this would likely be the slowest option.

Disclosure: I am not associated with the manufacturer of this mini-PC, nor any of the retail outlets mentioned above.  I am not being paid by anyone for this blog post – I simply wanted to share my findings and recommendations.