Interface speaker with Raspberry pi and Fixed the error!! - Black keyhole

welcome to our keyhole, we provide you various knowledge from various sources such as Electric&Electronic, Health, Arduino, IOT, Diy projects, A/l past paper and model paper, Even though you can keep in touch with current technology

Interface speaker with Raspberry pi and Fixed the error!!

Share This


After long time..I am back with another tutorial with Raspberry Pi. Here we have collaborated 3 YouTube channels to make a project called CHAT with COVID. In this collaborative project we have divided our content through the three different formats V2 Techies are covering the basic pyhton libraries for this project then Scibot will cover the essential work flow for this project and Black keyhole will follow the Hardware part of this project.

So as of my part, Today I am going to cover the basic of how to connect the speaker with the Raspbery pi and how to solve the errors that you may have face.

hardware connection

    Here you have to connect the Raspberry pi with your speaker. I have connected my speaker with 3.5mm audio jack and powered it on with the USB port of my Raspberry pi. as well as I have used 12v DC fan for cool up my Raspberry pi. also I have used my Microphone with the Raspberry pi by attaching with USB soundcard. because Raspberry pi still not has the interface for a microphone . So now let we move into the command line for some credentil works.

First type the command following

           arecord -l  

  Thereafter you can see the card name and device name of your Microphone. Note it out.

then give the following command

                   aplay -l

thereafter you can get hardware devices connected with your Raspberry pi.

Here my playback device(speaker) has been connected Card number 2 and device number 0. I have connected my Raspberry pi in the 3.5 mm jack so that I have figured it out as headphone is my speaker's port.

then give the following command to edit the file

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


In that file change the parameters of the following dependencies by scrolling down at the bottom

   defaults.ctl.card 1

defaults.pcm.card 1

defaults.pcm.device 0

defaults.pcm.subdevice 0

 Then now, You have to assign the value for your MIC and speaker which you have figured above. Here my Mic(capture ) device value is "hw:3,0" and speaker(playback) value is "hw:2,0". You change  the values based on your dependencies.

for that first give the following command

  sudo nano ~/.asoundrc 

then copy and paste the following code but don't forget to change the values based on your machine

    pcm.!default {

         type asym

         playback.pcm {

                 type plug

                 slave.pcm "hw:2,0"


         capture.pcm {

                 type plug

                 slave.pcm "hw:3,0"



 ctl.!default {

        type hw

        card 0



And again paste the above code into the following file for configuration. You can get the file by giving the following command in the terminal

sudo nano /etc/asound.conf


Then again back to your main command terminal and give the following command to change your speaker and mic volume.


By pressing your keyboards F6 button you can select your mic and speaker terminal then use the UP and Down keys to control the volume of your speaker and mic.

Finally, we have to make some changes in the raspi-config. So to do that give the following command in your terminal 

      sudo raspi-config

then enter into the system option. There you can select the \audio file and choose the option where you have connected your speaker. Here I have connected my speaker with the 3.5mm audio jack of raspberry pi. So that I have selected the audio device  my bcm2835 headphone. Then go to YouTube or other videos to test the Audio output from your speaker.

If you are facing furthermore errors please drop them in the comment box. I am glad to reply to you again.  


1 comment:

  1. For what reason would it be a good idea for you to think about purchasing these speakers?


business queries