HowTo: Raspberry Pi – Configure default speakers

The RaspberryPi can be equipped with a speaker in various ways. The easiest way is to connect it via the 3.5mm jack plug. It is also possible to output the sound via the HDMI connection.

Finally, 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 speakers, as described in the articles RaspberryPi - Use RaspberryPi with "Raspotify" as a Spotify speaker or RaspberryPi - Install "Shairport" Airplay on the RaspberryPi is described. .

The following article describes how you can set the standard loudspeaker - which is normally used for sound output.

Safety instructions

I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.

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 make a purchase via this link, will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support in being able to offer other useful projects in the future. 🙂 


Helpful articles:
Before you start with this article you should have prepared the RaspberryPi so that it is accessible via the network and controllable 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 tool:

Required material:

In the following list you will find all the parts you need to implement this article.

Log in to the RaspberryPi via SSH

To start, you must first log in to the Rasp Pi with Putty via SSH. How to do this is in the article RaspberryPi - Control the RaspberryPi via SSH described.

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

List available speakers

So that you can set the default speaker, you should first check which audio outputs are available. You can also easily find out the ID of the corresponding audio output.

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

cat /proc/asound/modules

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

Setting the standard speaker

The default loudspeaker - 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.

sudonano /usr/share/alsa/alsa.conf

In the open file, use the arrow keys to navigate further down in the file...

Until you reach 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 a different audio output as the standard output.

Instead of a "1", you can of course also set a different ID here. It is only important that the ID can be assigned to an audio output (from the previously retrieved list).

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

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

sudo reboot

Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS 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 think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at       


  1. Hello,
    Thank you for the article. Unfortunately, it doesn't quite work for me. The USB sound card is displayed as "2 snd_usb_audio", so I replace the 0 with a 2 in the configuration file. After a restart, this is still set to 2, but I still get no sound via the sound card. Do you have any idea what the problem could be?

    Thank you very much 🙂

    1. Hey Tobias,
      have you entered the "2" for both values (i.e. defaults.ctl.card and defaults.pcm.card)? 🙂
      Best regards

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

This site uses Akismet to reduce spam. Learn how your comment data is processed.