I wanted to use a Raspberry Pi 3B (rev a02082) to record noise pollution in my neighborhood. This requires multiple microphones, but each one needs only 800 kbps while recording. So I thought that one of the Pi's 480 Mb/s USB 2.0 ports (it has four) could suffice. I reasoned that even if the USB controller had to go into USB 1.1 mode for some reason, at 12 Mb/s there should still be more than enough bandwidth for two microphones.
So I ran a 20 ft USB extension cable to a new USB 3.0 hub. The hub has two microphones attached.
When I try to read from one microphone or the other, it works fine. However if I try to read from both at once, then they start producing fewer samples than requested. For example, if I ask for 48000 samples/second they might produce only 40000 or 30000. I guess this means that polling doesn't happen fast enough, and some samples stored on the device are being dropped. As I understand it, normally USB audio devices are polled at 1000 Hz.
I tried the following to troubleshoot the problem:
- Replace USB extension cable
- Replace the USB 3.0 hub at the microphone end
- Use a powered USB 3.0 hub between the Pi and the extension cable
None of these worked. (Using a powered hub was something that I had needed to do in the past to reliably connect an external hard drive, but it didn't help in this case)
However, if I connect one microphone directly to the Pi, then I can read from both. And if I connect one microphone to the powered hub, and leave the other mic at the end of the extension cable, then I can read from both.
So in summary, we have:
DOESN'T WORK: Pi 3B ----------20ft--------- hub -- mic1 |- mic2 Pi 3B --- hub ----------20ft--------- hub -- mic1 |- mic2 WORKS: Pi 3B --- hub ----------20ft--------- hub -- mic1 |- mic2 Pi 3B --- hub ----------20ft--------- mic1 |- mic2 Pi 3B ----------20ft--------- mic1 |- mic2
Finally, even in the first two configurations, when I replace the Pi 3B with either a Pi 4 (using either USB port), or my laptop, then I can read from both devices simultaneously with no problems.
So what exactly is the Pi 3 doing that makes this experiment fail? At first I thought it was a power issue, but using the powered hub didn't fix it. Then I thought it was a bandwidth issue, but the problem went away when I moved one of the microphones closer to the Pi 3. Apparently the presence of a long cable must have something to do with the problem, but my laptop and the Pi 4 didn't care about the cable length.
I recall coming across acounts of other users encountering a similar problem, but while writing this question I couldn't find anything except this thread from 2013.