I am deploying a Pi 4 on a wheelchair and require audio output to prompt the user. The Pi is headless (i.e. no monitor). On the bench, with a monitor, my code correctly sends the audio out the 3.5 jack to a powered amplifier. When I unplug the HDMI cable and reboot, the audio stops working. Any suggestions will be much appreciated.

I set the output to analog via the sound icon on the monitor. Could it bed that the Pi forgets the setting when no monitor is connected? Or, does the Pi look for HDMI before analog and hang? Or, do I need to set the sound level manually since the desktop is not working without the monitor? Any help will be greatly appreciated.

Thanks in advance. Rick


Try adding the following into config.txt and reboot the Pi.


The first line tells the Pi to ignore whatever HDMI thinks it's capability is and use the on-board audio.

The second line tries to take out some hiss and noise - it may not work for your audio but worth trying.

Make sure that these are in a section that gets read as config.txt can have sections depending on model, serial number etc.


This answer may come too late for Mr. Foulds, but let me disgorge my research here.

It seems the canonical way to choose the audio output on the RPi is to use the raspi-config, which is an interactive menuing system. Like Mr. Foulds, I have a project where I would like the analog audio to be the default. You cannot use raspi-config at boot (unless you want to use something like expect, but please do not).

A look at the source code for raspi-config provides the answer:


All it does is configure the .asoundrc file for the current user (usually pi for RPis). Notice that what really changes is the 'card' property in the pcm.output and ctl.!default blocks. But how do we know which "card" is the analog output?

Use 'aplay -l | grep bcm2835'. That shows you all available cards.

Use your favorite unix pattern matching tool to extract the card number. Here's my example:

   aplay -l | grep bcm2835 | grep "Headphones" | perl -lane 'print substr($F[1],0,1)'

This will emit the card number of the "headphones" card.

Simply create the .asoundrc file with this card number at boot time. There is already a template for this file in the raspi-config source linked above. I would use that.

You can change this RC file at any time. When the linux sound system needs to route audio output, it appears to consult this file. No rebooting is needed. If you would like to read more about the linux sound architecture, here is the wiki:


I did a lot of web searches, but could not find this answer stated clearly. I hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.