Stufin
Home Quick Cart Profile

USB Microphone for Raspberry Pi (Color may Vary)

Buy Now

Microphone Type

Electret condenser microphone

Frequency Response

50 Hz to 15 kHz

Sensitivity

4.5mV/Pa

Impedance

2.2k

Signal-to-Noise Ratio (SNR)60 dB

Operating System

Compatible with Raspberry Pi OS and other Linux-based operating systems

Dimensions

30mm x 10mm x 10mm (L x W x H)

Weight

approximately 10 grams

Package Includes

1 x USB Microphone for Raspberry Pi

1 x USB cable (1.5m)

Color Variation

Please note that the color of the microphone may vary, but the functionality and features remain the same.

Pin Configuration

  • USB Microphone for Raspberry Pi (Color may Vary) Pinout Guide
  • The USB Microphone for Raspberry Pi is a compact, plug-and-play audio input device designed specifically for Raspberry Pi boards. This microphone module features a standard USB connector and is compatible with Raspberry Pi models A, B, A+, B+, 2, 3, 3 A+, and 4.
  • Pinout Structure:
  • The USB Microphone module has a standard Type-A USB connector with 4 pins. Here's a breakdown of each pin's function:
  • 1. VBUS (Pin 1) - Power
  • Function: Provides power to the microphone module from the Raspberry Pi's USB port.
  • Voltage: 5V
  • Current: Up to 500mA (depending on the Raspberry Pi model and power supply)
  • 2. D- (Pin 2) - Data Negative
  • Function: Carries the negative data signal from the microphone to the Raspberry Pi.
  • Signal: Differential data signal (negative leg)
  • 3. D+ (Pin 3) - Data Positive
  • Function: Carries the positive data signal from the microphone to the Raspberry Pi.
  • Signal: Differential data signal (positive leg)
  • 4. GND (Pin 4) - Ground
  • Function: Provides a common ground connection between the microphone module and the Raspberry Pi.
  • Voltage: 0V
  • Connection Structure:
  • To connect the USB Microphone to your Raspberry Pi, follow these steps:
  • Step 1: Locate the USB ports on your Raspberry Pi
  • Identify the USB ports on your Raspberry Pi board. Typically, there are 2-4 USB ports available.
  • Step 2: Connect the microphone module
  • Gently insert the USB Microphone module into an available USB port on your Raspberry Pi.
  • Ensure the module is securely seated and the pins are fully engaged.
  • Step 3: Verify the connection
  • Check that the microphone module is recognized by your Raspberry Pi. You can do this by:
  • + Opening a terminal on your Raspberry Pi and typing `lsusb` to list connected USB devices.
  • + Verifying that the microphone is listed as an available audio input device in your Raspberry Pi's audio settings.
  • Tips and Precautions:
  • Ensure the Raspberry Pi is powered off before connecting or disconnecting the microphone module.
  • Handle the microphone module with care to avoid damaging the pins or the USB connector.
  • Use a high-quality USB cable to connect the microphone module to your Raspberry Pi (if you're using an extension cable).
  • Consult the Raspberry Pi documentation and the microphone module's datasheet for more information on troubleshooting and configuring the audio input settings.
  • By following these steps, you should be able to successfully connect the USB Microphone to your Raspberry Pi and start capturing high-quality audio input.

Code Examples

USB Microphone for Raspberry Pi (Color may Vary)
Overview
The USB Microphone for Raspberry Pi is a plug-and-play audio input device designed specifically for use with Raspberry Pi boards. This compact microphone connects directly to the Raspberry Pi's USB port, providing a convenient and easy-to-use solution for a wide range of audio applications.
Technical Specifications
Interface: USB 2.0
 Sampling Rate: 44.1 kHz, 48 kHz, 96 kHz
 Bit Depth: 16-bit
 Frequency Response: 20 Hz - 20 kHz
 Sensitivity: -40 dB  3 dB
 Connector: USB-A
Hardware Requirements
Raspberry Pi (any model)
 USB port
Software Requirements
Raspbian (recommended)
 Python 3.x (for code examples)
Code Examples
### Example 1: Basic Audio Recording using Python
This example demonstrates how to use the USB Microphone to record audio using Python and the `pyaudio` library.
Hardware
Raspberry Pi (any model)
 USB Microphone for Raspberry Pi
 USB port
Software
Raspbian (recommended)
 Python 3.x
 `pyaudio` library (install using `pip install pyaudio`)
Code
```python
import pyaudio
import wave
# Initialize PyAudio
p = pyaudio.PyAudio()
# Open the microphone stream
stream = p.open(format=pyaudio.paInt16,
                channels=1,
                rate=44100,
                input=True,
                frames_per_buffer=1024)
print("Recording...")
# Record audio for 5 seconds
frames = []
for i in range(0, int(44100 / 1024  5)):
    data = stream.read(1024)
    frames.append(data)
# Close the stream
stream.stop_stream()
stream.close()
p.terminate()
# Save the recorded audio to a WAV file
wf = wave.open("recorded_audio.wav", "wb")
wf.setnchannels(1)
wf.setsampwidth(2)
wf.setframerate(44100)
wf.writeframes(b"".join(frames))
wf.close()
print("Recording saved to recorded_audio.wav")
```
### Example 2: Real-time Audio Processing using OpenCV and Python
This example demonstrates how to use the USB Microphone to capture audio in real-time and process it using OpenCV and Python.
Hardware
Raspberry Pi (any model)
 USB Microphone for Raspberry Pi
 USB port
 Webcam (optional)
Software
Raspbian (recommended)
 Python 3.x
 OpenCV (install using `pip install opencv-python`)
 `pyaudio` library (install using `pip install pyaudio`)
Code
```python
import cv2
import pyaudio
import numpy as np
# Initialize OpenCV
cv2.namedWindow("Audio Waveform")
# Initialize PyAudio
p = pyaudio.PyAudio()
# Open the microphone stream
stream = p.open(format=pyaudio.paInt16,
                channels=1,
                rate=44100,
                input=True,
                frames_per_buffer=1024)
while True:
    # Read audio data from the microphone
    data = stream.read(1024)
# Convert audio data to a NumPy array
    audio_array = np.frombuffer(data, dtype=np.int16)
# Create a waveform image using OpenCV
    img = np.zeros((200, 400, 3), dtype=np.uint8)
    for i in range(len(audio_array)):
        x = int(i  400 / len(audio_array))
        y = int(100 + audio_array[i] / 32768  100)
        cv2.line(img, (x, 100), (x, y), (0, 255, 0), 1)
# Display the waveform image
    cv2.imshow("Audio Waveform", img)
# Exit on key press
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
# Close the stream and PyAudio
stream.stop_stream()
stream.close()
p.terminate()
cv2.destroyAllWindows()
```
Note: This example assumes a webcam is connected and available. If no webcam is present, the code will still run, but the waveform will not be displayed.