Building a Raspberry Pi-powered Barkometer, Part 2

But wait, there's more to the Barkometer hardware!

harvey2a
Credit: Mark Gibbs

In the first part of this project I discussed the goal, to wit, to document and quantify how often my dog barks, and discussed the hardware I planned to use. One component I neglected to mention was the Edimax N150 Wi-Fi Nano USB Adapter which, after some experimentation, I discovered was a problem when the USB sound card was in an adjacent USB port because every sound sample I captured started with a burst of noise lasting 30 to 75 seconds.

n150 wi fi nano usb adapter Edimax

After much messing around I realized that when the application that transfers the sound samples to my network attached storage ran (we will get to that app eventually), it connected via Wi-Fi for as long it took to transfer the previous sample and as the sound card was so close, I was hearing radio frequency interference. The answer was simple; connect the sound card to the Raspberry Pi USB port by an extension cable and voila! RF noise minimized. If I had used a Raspberry Pi 3 Model B board which has 802.11n built in I wouldn’t need the Wi-Fi adapter but I doubt whether the interference would be less of a problem.

The next issue was a low-level hum on the audio which was obviously 60-cycle noise from the AC power adapter. This is a tricky problem to solve because most AC power adapters, including the official RPi PSUs, don’t provide a completely “clean” DC voltage and the USB sound card I’m using, a Sabrent USB 2.0 External 2.1 Surround Sound Adapter, apparently doesn’t have great noise immunity. That said, some power adapters are better than others and I’ve seen a number of adapters cited as noticeably cleaner than most (notably the Sony Xperia mobile charger). On the other hand, because so few really clean adapters are available, some people, such as the chaps over at RaspiFy, have resorted to building their own stabilized power supplies.

Allow me to digress for a moment and note that RaspiFy has been revamped as Volumio and it’s a really cool project:

Volumio is a free and Open Source Linux Distribution, designed and fine-tuned exclusively for music playback. It runs on a variety of devices, typically small and cheap computers like the Raspberry PI, but also on low power PCs, notebooks or thin clients. By flashing (installing) Volumio on any of [these] platforms, it will then become an headless Audiophile Music Player. Headless means that the only  way to control it will be with another Mobile phone, computer or tablet. / This is made possible by Volumio’s UI: a web applications that runs on any device with a browser, and that allows an easy and intuitive control of your playback sessions. All communications [between] the webapp and Volumio will happen [through] your home network.

While I’m digressing, it’s worth noting that you ideally want the AC power adapter you’re using to be capable of supplying 5.5V at 2A; ModMyPi explains:

At ModMyPi, our standard power supply for the Raspberry Pi is 5.25V @ 2A. The reason for increasing the voltage slightly is to negate any voltage drop caused by excessive current draw. This is well within tolerance for Micro-USB, and from experience, we have found that this give the best stability for most applications …The Raspberry Pi can function on lower current power supplies e.g. 5V @ 1A. However, any excessive use of the USB ports or even heavy CPU/GPU loading can cause the voltage to drop, and instability during use. The latest versions of the Raspberry Pi B+/A+/2 [and model 3] have a “low voltage indicator icon” to notify the user if there is a problem with the power. 

If you’ve ever wondered what that little colored square at the top right of the screen might be, that’s the low voltage indicator icon they’re referring to; it appears when the 5V line has dropped to under 4.65V and means that you need a better power supply. It looks like this:

 

rpi voltage warning

Now, back to our main theme … it may be possible to eliminate or at least reduce the 60Hz hum by filtering in software but for our purpose, dog bark detection, this isn’t strictly necessary as long as the hum doesn’t drown out the barking.

I did try using a big LiPo battery hoping to get a cleaner power source but that was even worse as it constantly sent gigantic spikes to the RPi causing worse interference than the power adapters.

The final mod I had to make was to put a wind shield around the microphone because even an extremely light breeze caused noise.  I was going to use a piece of sponge but in the end realized I could use the wind shield from an old lavaliere mic. 

bark setup Mark Gibbs

 

So there we have it folks … we’re all set up with our hardware (though I'm going to swap out the USB extension cable for one that's shielded when I get a chance to dig through my extensive cable collection). In the next installment, we’ll look at how to record sound using this setup.

Comments? Thoughts? Connect to me or comment below then follow me on Twitter and Facebook.

Join the Network World communities on Facebook and LinkedIn to comment on topics that are top of mind.
Must read: Hidden Cause of Slow Internet and how to fix it
Notice to our Readers
We're now using social media to take your comments and feedback. Learn more about this here.