I wanted to write this article because I found it really difficult to connect and set an Edison's USB microphone. I haven't found on the Internet a guide explaining this well, so I decided to write one.
Step 1 - Boot and Wiring:Power up your Edison and ensure the SW1 switch (between USB and OTG adapter) is positioned towards the USB. In this way, you will set your Edison as USB host mode and it will be able to communicate to whatever USB device such as microphones, webcams, and USB keys. Maybe this picture will help you.
Then connect the USB OTG cable to the first port to the right so you will be able to connect Edison to the computer as a serial device. If you want, you can also connect to the Edison with SSH, but I don't recommend you to do this because it became very slow after 2 or 3 minutes. Connect your USB microphone (USB port at the right of the photo), in my case it's a webcam with built-in mic, but it's the same.
Step 2 - Serial or SSH Communication:Open your SSH or Serial terminal, I'll use Serial. Follow this guide to connect: https://software.intel.com/en-us/setting-up-serial-terminal-on-system-with-windows
For SSH, follow this tutorial link.
Once you're connected, type "lsusb
". If you get any error like lsusb not initialized
, it means you haven't switched the SW1 switch.
If you see something like this it means your webcam/microphone was set up right.
Step 3 - Alsamixer:Alsa is the audio I/O driver for Linux and with this you can find your mic.
Type "alsamixer
" and you will see a GUI; by default the device will be "default - loopback" or something similar. Now press F6 and you will see a list of devices. If your device appears here, it should mean it is supported by the system.
My device is number is #2, or USB Device 0x46d:0x9a5. Note these two numbers that are surely different from mine. Now press Esc or hit Ctrl+C and you will exit from the Alsamixer GUI.
Now type "arecord -l
". Arecord is the Alsa utility for recording sounds. You will see a list of devices for recording and find the one that matches with your USB device number (0x46d:0x9a5 in my case).
Take care of these two numbers and note them.
Step 4 - Edit Alsa Configuration:Now execute this command: "nano /usr/share/alsa/alsa.conf
". You will enter the Alsa configuration file for device mapping. Now navigate to the lines, declaring:
defaults.ctl.card 0
defaults.pcm.card 0
defaults.pcm.device 0
If you never edited this file, you should have these numbers above. With this configuration, the default device 0 at card 0 and control device is also 0. We need to change these lines with the numbers we obtained before, in this case, Card 2, device 0.
defaults.ctl.card 2
defaults.pcm.card 2
defaults.pcm.device 0
We put ctl
and pcm
card as 2 because, in my case, it was my webcam mic card number. You will set this card as default control and recording device.
Then put 0 as pcm.device, as we obtained it from "arecord -l
" as device number 0 of card 2. If you edited the file with nano - if you followed me you used nano :-) - hit Ctrl+X to exit and then press the Y-key to save changes. Then press the Enter-key to apply them. You will return to the Serial (or SSH) Edison terminal.
For the last time, open Alsamixer with the command used before (type "alsamixer
") and you will see your device as default. But you will also see:
"This sound device does not have any playback controls."
This is because your mic, like mine, can't play sounds. To see if it can, press the Tab-key and you will access it. If you want to set the mic volume, press Tab and you will gain access to the "Capture" section. Here you can setup the mic volume with the Up-key and Down-key on your keyboard. Then exit with ESC-key. You have configured your mic as default and now everything will be easier if you will use "arecord
" for recording wav, mp3, etc. files; this is also useful if you need to use your mic in Python for recording sounds or speech recognition. If you want, you can reboot to check everything is fine and your USB mic is still default. Remember to power up your Edison with SW1 key as declared before (towards USB port) and naturally with your USB mic connected.
It should work now for now and forever. If you have any questions, suggestions or error reporting logs, please write them in the comment box.
I'm working with speech recognition in Python and this tip was essential to work with it. I will soon write the project on speech recognition with Google Speech API, which supports plenty of languages.
Leave a respect if you find this useful.
Comments
Please log in or sign up to comment.