How To: Raspberry Pi – Configure audio output

The RaspberryPi can be equipped with a speaker in various ways. The easiest way is the connection via the 3.5mm jack plug. There is also the option of having the sound output via the HDMI connection.

Ultimately, the sound can also be output via a connected USB speaker.

This is particularly useful if you want to use your RaspberryPi as a Spotify or AirPlay loudspeaker, as described in the articles RaspberryPi – Use RaspberryPi with “Raspotify” as Spotify speaker or RaspberryPi – Install “Shairport” Airplay on the RaspberryPi.

The following article describes how you can set the standard speaker – through which the sound output normally takes place.

Safety instructions

I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance.

Affiliate links / advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support in being able to offer further useful projects in the future. 🙂


Helpful Articles:
Before you start with this article, you should have prepared the RaspberryPi so that it can be reached via the network and controlled via SSH.

The following three articles describe what needs to be done to prepare the RaspberryPi:
RaspberryPi – Setup for nerdiys!
RaspberryPi – The first configuration!
RaspberryPi – Control the RaspberryPi via SSH

Required tools:
– none –

Required material:

Log in via SSH on the RaspberryPi

To get started, you first need to log in to RasPi with SSH on Putty. How to do it is described in the article

After entering your username and password you can start to enter the first commands.

List available speakers

So that you can set the standard loudspeaker, you should first check which audio outputs are available. So you can easily find the associated ID of the corresponding audio output.

Simply enter the following command into the console of your RaspberryPi.

cat /proc/asound/modules

The available audio outputs and their ID (the number in front of them) will then be displayed. You will need this ID later to set the corresponding output.

Set the default speakers

The standard audio out – which is normally used for output – can be set via the ALSA configuration file.

To do this, open the configuration file with the following command.

sudo nano /usr/share/alsa/alsa.conf

In the opened file you can now navigate further down with the arrow keys in the file …

Until you have arrived at the following point.

defaults.ctl.card 0
defaults.pcm.card 0

There you change the part

defaults.ctl.card 0
defaults.pcm.card 0


defaults.ctl.card 1
defaults.pcm.card 1

to set another audio output as the standard output.

Instead of a “1” you can of course also set another ID here. It is only important that the ID can be assigned to an audio output (from the list previously called up).

Save the changes by pressing CTRL + X, Y and Enter.

To load the changed settings you should restart the RaspberryPi. Just enter the following command.

sudo reboot

Have fun with the project

I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂

P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂

Buy Me a Coffee at   


  1. Hallo,
    vielen Dank für den Artikel. Leider klappt es bei mir nicht ganz. Die USB Soundkarte wird als “2 snd_usb_audio” angezeigt; also ersetze ich in der Konfigurationsdatei die 0 durch eine 2. Nach einem Neustart steht dies zwar weiterhin auf 2 aber ich bekomme dennoch keinen Ton über die Soundkarte. Hast du eine Idee, woran es liegen kann?

    Vielen Dank schon mal 🙂

    1. Hey Tobias,
      hast du die “2” denn für beide Werte (also defaults.ctl.card und defaults.pcm.card) eingetragen? 🙂
      Beste Grüße

Leave a Reply

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