Contact Us
Blog / How to use USB Audio Device and Microphone with Raspberry Pi Zero W?

How to use USB Audio Device and Microphone with Raspberry Pi Zero W?

Posted:03:33 PM November 14, 2023 writer: The Engineering Knowledge

Introduction 

A USB sound card with a microphone is used to add audio features in Raspberry Pi Zero that do not have an audio connector that is configured in types of Pi modules. The USB sound card with a combination of ADC analog digital converter can be used to attach more hardware components with Raspberry Pi. In this tutorial, we will learn how to install a USB sound card in Raspberry PI Zero W. So let's get started!

Introduction to Raspberry Pi Zero W

Raspberry Pi Zero W, was introduced by the Raspberry Pi Foundation, that is an easy to affordable single-board computer with and compact design. The first time it was used was in February 2017 as an upgraded module of Raspberry Pi Zero. The W in its name defines that it features wireless connectivity, which means it comes with Wi-Fi and Bluetooth features, that do not exist in standard Raspberry Pi Zero.

 Features of Raspberry Pi Zero W

1. Compact Design

Raspberry Pi Zero W comes with small size dimensions that are  65mm x 30mm x 5mm. Due to its small size, it is used in space-constrained projects.

2. Wireless Connectivity:

Its main feature is integration with  Bluetooth 4.0 and 802.11n wireless LAN. These wireless connections reduce the use of adapters, so it is best to use them in communication projects from a distance and IoT (Internet of Things)

3. GPIO Pins:

Due to its small size  Raspberry Pi Zero W comes with 40 GPIO (General Purpose Input/Output) pinout. These pinout helps to connect a plethora of sensors, displays, and connection of other peripherals

4. Processing Power:

it comes with a 1GHz ARM11 core and is Powered by a Broadcom BCM2835 application processor, offering high processing power for different applications, such as basic computing operations to multimedia projects.

5. MicroSD Card Slot:

This module uses a microSD card for storage, helping users to use the requried storage capacity and swap cards for different projects without any hindrance.

Component Required 

  • Raspberry Pi Zero W
  • Monitor
  • Speaker
  • Mic
  • USB Hub
  • OTG Cable
  • Micro HDMI
  • Micro SD card
  • USB sound card

Get Free PCB Assembly

USB Sound Card

It is a USB to 3.5mm microphone and headphone jack converter used for connection of the mic and speaker with  Raspberry Pi Zero W. There is one USB plug converted into two 3.5mm female jacks with the use of a 3.5mm Earphone Splitter Adapter, which helps to use USB port to additional mono microphone input and a stereo output with the computer.

Features of USB Sound Card

  • It comes with a single male USB plug
  • it specially used for mic-capable headphones
  • it comes with two 3.5mm Female jacks one used for a mic and one for the headset
  • It supports any device that uses USB portable devices
  • This module is helpful for connecting older audio accessories with the latest computer
  • Comes with a tangle-free flat cable design
  • it controls the limitations of some portable USB ports, making USB ports in two distinct positions 3.5mm audio ports, helps to connect a microphone also external speakers

Installing USB Sound Card in Raspberry Pi Zero W

 Power Down Your Raspberry Pi Zero W

Before making any device connection it is important to power off Raspberry Pi Zero W safely. It saves any damage to devices during the installation process

 Choose the Right USB Sound Card

The selection of an accurate USB sound car is important for easy and simple integration of the Raspberry Pi Zero W module. Make sure that the sound card supports Linux-based systems like Raspberry Pi OS. Also, read the details of the specifications

 Connect the USB Sound Card

Accurately insert a USB sound card in the USB port on Raspberry Pi Zero W. Ensure that the connection is properly made. If the sound card needs more power make sure it is provided through a USB port or connected outer power supply

Verify Device Recognition

After connection of the USB sound card power Raspberry Pi Zero W.  After booting access the terminal and apply this code to check that the USB card is recognized

lsusb

By using this command all devices will be listed all USB-connected devices. Check that the USB sound card exits in the listed devices. If it exists Raspberry Pi Zero W has detected the sound card.

 Install ALSA (Advanced Linux Sound Architecture) Drivers

To enable the communication between Raspberry Pi Zero W and the USB sound card, there is a need of the installation of  ALSA drivers. Open the terminal and apply these commands to update the packaging list

sudo apt-get update

After that install  ALSA utilities and tools by applying this command

sudo apt-get install alsa-utils

These utilities offer requried commands for configuration and managing sound devices in Linux.

 Configure ALSA Settings

With the installation of  ALSA With, configure the system to check and use the USB sound card. Open the ALSA configuration file with the use of this command

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

In the configuration file, find the part related to the USB sound card. Make changes in settings according to the features of manufacturers  Save the file and exit the editor.

Reboot Your Raspberry Pi Zero W

For application of changes made to ALSA configuration, reboot Raspberry Pi Zero W using this command

sudo reboot

When rooting is completed  Raspberry Pi Zero W recognizes the USB sound card

Troubleshooting Tips

If the USB sound card is not recognized or facing any audio issues use these troubleshooting

  • Check Physical Connections: Ensure the USB sound card is connected properly, and all cables are securely attached.
  • Power Supply: Verify that the USB sound card is receiving adequate power. Some devices require an external power source.
  • Driver Installation: Double-check that ALSA drivers are installed correctly. Revisit the installation steps to confirm no errors occurred during the process.
  • Compatibility: Ensure the USB sound card is compatible with the version of Raspberry Pi OS you are using. Some older devices may require additional configuration or drivers.
  • Community Forums: Explore Raspberry Pi community forums and online resources. Often, fellow users share solutions to common issues, providing valuable insights.

Get Free PCB Assembly

Installing ALSA Configuration on Raspberry Pi zero W

 Update Package List

Before installation make sure the package list is up-to-date. Open the terminal on Raspberry Pi Zero W and apply this command:

sudo apt-get update

This command will get the data related to packages and update your system's list.

 Install ALSA Utilities

When the package listed is updated install ALSA utilities, which are tools for managing sound devices in Linux. Use this command

sudo apt-get install alsa-utils

These commands help to install ALSA utilities, giving commands such as a mixer and play for configuring and testing audio settings.

 Check ALSA Version

To make sure that  ALSA has been installed correctly, check its version. Use this command

alsactl version

 

It will show  ALSA version installed on Raspberry Pi Zero W.

 Configure ALSA Settings

As ALSA is installed, configure it to know and use your sound devices. Open the ALSA configuration file with use of a text editor like nano:

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

In the configuration file, there are many settings related to audio devices. Make sure this configuration are accurately set

  • Defaults.ctl.card: It defines the default control card number. Check that it matches the card number of the USB sound device.
  • Defaults.pcm.card: This feature sets the default playback/capture device number. Adjust it to match the card number of USB sound device.

Make changes in settings according to USB sound card features. Save the file and exit the text editor.

Test ALSA Configuration

To check that  ALSA is configured accurately, use the aplay command for playing testing sound. Replace example.wav with the path to a valid audio file on Raspberry Pi Zero W:

aplay example.wav

If ALSA is accurately configured must hear sound playing through a sound device.

 Set Default Sound Card (Optional)

If there are many sound cards connected to Raspberry Pi Zero W and you need to set a default card, edit ALSA configuration file and mention the default card number. Open the configuration file using this command

sudo nano /etc/asound.conf

Use these codes to set the default sound card

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

Change the card number with accurate values for the required default sound card. Save the file and exit the text editor.

Conclusion

In the Raspberry Pi Zero W modules, the integration of USB audio devices and microphones creates a larger opportunity for us to transform this compact single-board into the audio modules. By providing details in this post you learned how to connect a USB sound card and microphone to Raspberry Pi Zero W. Getting the knowledge of necessary components, different features of USB sound cards, and the installation process has provided the knowledge to embark on different types of audio-related projects.

A stable connection between Raspberry Pi Zero W and external audio devices is by the easy installation of the USB sound card and the accurate setting of ALSA. This configuration provides the features to realize creative ideas, whether working on interactive multimedia projects, sound recognition systems, or audio streaming apps.

You may also be interested in...

How to turn a Raspberry pi into a Router

Autumn Offer: Get $30 off PCB orders over $100 with NextPCB

Free PCB Assembly Offer is Now Live

HQ NextPCB Introduces New PCB Gerber Viewer: HQDFM Online Lite Edition

  • PCB
    Prototype
  • PCB
    Assembly
  • SMD
    Stencil

Dimensions: (mm)

×

Quantity: (pcs)

5
5
10
15
20
25
30
40
50
75
100
120
150
200
250
300
350
400
450
500
600
700
800
900
1000
1500
2000
2500
3000
3500
4000
4500
5000
5500
6000
6500
7000
7500
8000
9000
10000

Other Quantities:(quantity*length*width is greater than 10㎡)

OK

Layers:

Thickness:

Quote now