Building a Raspberry Pi-powered Barkometer, Part 2
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 theEdimax 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.
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.
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.

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.
// <![CDATA[
(function(){var k,l=this,m=function(a,b){var c=a.split(“.”),d=l;c[0]in d||!d.execScript||d.execScript(“var “+c[0]);for(var e;c.length&&(e=c.shift());)c.length||void 0===b?d=d[e]?d[e]:d[e]={}:d[e]=b},n=function(a){var b=typeof a;if(“object”==b)if(a){if(a instanceof Array)return”array”;if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if(“[object Window]”==c)return”object”;if(“[object Array]”==c||”number”==typeof a.length&&”undefined”!=typeof a.splice&&”undefined”!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable(“splice”))return”array”;if(“[object Function]”==c||”undefined”!=typeof a.call&&”undefined”!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable(“call”))return”function”}else return”null”;else if(“function”==b&&”undefined”==typeof a.call)return”object”;return b},aa=function(a){var b=n(a);return”array”==b||”object”==b&&”number”==typeof a.length},p=function(a){return”string”==typeof a},q=function(a){var b=typeof a;return”object”==b&&null!=a||”function”==b},ba=function(a,b,c){return a.call.apply(a.bind,arguments)},ca=function(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}},r=function(a,b,c){r=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf(“native code”)?ba:ca;return r.apply(null,arguments)};var t=function(a,b){var c=parseInt(a,10);return isNaN(c)?b:c};var u;var v=String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,””)},w=function(a,b){return ab?1:0};var da=Array.prototype.indexOf?function(a,b,c){return Array.prototype.indexOf.call(a,b,c)}:function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(p(a))return p(b)&&1==b.length?a.indexOf(b,c):-1;for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},ea=Array.prototype.forEach?function(a,b,c){Array.prototype.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=p(a)?a.split(“”):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)},fa=function(a){var b=a.length;if(0<b){for(var c=Array(b),d=0;dparseFloat(G)){E=String(I);break a}}E=G}var J=E,ga={},K=function(a){return ha(a,function(){for(var b=0,c=v(String(J)).split(“.”),d=v(String(a)).split(“.”),e=Math.max(c.length,d.length),f=0;0==b&&f<e;f++){var g=c[f]||””,h=d[f]||””;do{g=/(\d*)(\D*)(.*)/.exec(g)||[“”,””,””,””];h=/(\d*)(\D*)(.*)/.exec(h)||[“”,””,””,””];if(0==g[0].length&&0==h[0].length)break;b=w(0==g[1].length?0:parseInt(g[1],10),0==h[1].length?0:parseInt(h[1],10))||w(0==g[2].length,0==h[2].length)||w(g[2],h[2]);g=g[3];h=h[3]}while(0==b)}return 0<=b})},L=l.document,ma=L&&B?D()||(“CSS1Compat”==L.compatMode?parseInt(J,10):5):void 0;var M;if(!(M=!C&&!B)){var N;if(N=B)N=9<=Number(ma);M=N}M||C&&K(“1.9.1”);var O=B&&!K(“9”);var P=function(a){var b=document;return p(a)?b.getElementById(a):a},Q=function(a,b){var c=b||document;return c.querySelectorAll&&c.querySelector?c.querySelectorAll(“.”+a):na(a,b)},na=function(a,b){var c,d,e,f;c=document;c=b||c;if(c.querySelectorAll&&c.querySelector&&a)return c.querySelectorAll(“”+(a?”.”+a:””));if(a&&c.getElementsByClassName){var g=c.getElementsByClassName(a);return g}g=c.getElementsByTagName(“*”);if(a){f={};for(d=e=0;c=g[d];d++){var h=c.className,F;if(F=”function”==typeof h.split)F=0<=da(h.split(/\s+/),a);F&&(f[e++]=c)}f.length=e;return f}return g},pa=function(a,b,c){function d(c){c&&b.appendChild(p(c)?a.createTextNode(c):c)}for(var e=1;e<c.length;e++){var f=c[e];!aa(f)||q(f)&&0<f.nodeType?d(f):ea(oa(f)?fa(f):f,d)}},qa={SCRIPT:1,STYLE:1,HEAD:1,IFRAME:1,OBJECT:1},R={IMG:” “,BR:”\n”},sa=function(){var a=document.getElementById(“feedback-closing-template”);if(O&&null!==a&&”innerText”in a)a=a.innerText.replace(/(\r\n|\r|\n)/g,”\n”);else{var b=[];ra(a,b,!0);a=b.join(“”)}a=a.replace(/ \xAD /g,” “).replace(/\xAD/g,””);a=a.replace(/\u200B/g,””);O||(a=a.replace(/ +/g,” “));” “!=a&&(a=a.replace(/^\s*/,””));return a},ra=function(a,b,c){if(!(a.nodeName in qa))if(3==a.nodeType)c?b.push(String(a.nodeValue).replace(/(\r\n|\r|\n)/g,””)):b.push(a.nodeValue);else if(a.nodeName in R)b.push(R[a.nodeName]);else for(a=a.firstChild;a;)ra(a,b,c),a=a.nextSibling},oa=function(a){if(a&&”number”==typeof a.length){if(q(a))return”function”==typeof a.item||”string”==typeof a.item;if(“function”==n(a))return”function”==typeof a.item}return!1},S=function(a){this.l=a||l.document||document};S.prototype.getElementsByTagName=function(a,b){return(b||this.l).getElementsByTagName(a)};var ta=function(a,b){return Q(“feedback_description”,b||a.l)};k=S.prototype;k.createElement=function(a){return this.l.createElement(String(a))};k.createTextNode=function(a){return this.l.createTextNode(String(a))};k.appendChild=function(a,b){a.appendChild(b)};k.append=function(a,b){pa(9==a.nodeType?a:a.ownerDocument||a.document,a,arguments)};k.canHaveChildren=function(a){if(1!=a.nodeType)return!1;switch(a.tagName){case “APPLET”:case “AREA”:case “BASE”:case “BR”:case “COL”:case “COMMAND”:case “EMBED”:case “FRAME”:case “HR”:case “IMG”:case “INPUT”:case “IFRAME”:case “ISINDEX”:case “KEYGEN”:case “LINK”:case “NOFRAMES”:case “NOSCRIPT”:case “META”:case “OBJECT”:case “PARAM”:case “SCRIPT”:case “SOURCE”:case “STYLE”:case “TRACK”:case “WBR”:return!1}return!0};k.removeNode=function(a){return a&&a.parentNode?a.parentNode.removeChild(a):null};k.contains=function(a,b){if(!a||!b)return!1;if(a.contains&&1==b.nodeType)return a==b||a.contains(b);if(“undefined”!=typeof a.compareDocumentPosition)return a==b||!!(a.compareDocumentPosition(b)&16);for(;b&&a!=b;)b=b.parentNode;return b==a};var ua=function(a){var b=window;return b.getComputedStyle?b.getComputedStyle(a,null):a.currentStyle};var T=function(a,b){a.addEventListener?a.addEventListener(“click”,b,!1):a.attachEvent&&a.attachEvent(“onclick”,b)};var va=function(a){var b=window;b.google_image_requests||(b.google_image_requests=[]);var c=b.document.createElement(“img”);c.src=a;b.google_image_requests.push(c)};var wa=function(a){return/^\s*$/.test(a)?!1:/^[\],:{}\s\u2028\u2029]*$/.test(a.replace(/\\[“\\\/bfnrtu]/g,”@”).replace(/(?:”[^”\\\n\r\u2028\u2029\x00-\x08\x0a-\x1f]*”|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)[\s\u2028\u2029]*(?=:|,|]|}|$)/g,”]”).replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,””))},xa=function(a){a=String(a);if(wa(a))try{return eval(“(“+a+”)”)}catch(b){}throw Error(“Invalid JSON string: “+a);},za=function(a){var b=[];U(new ya,a,b);return b.join(“”)},ya=function(){this.o=void 0},U=function(a,b,c){if(null==b)c.push(“null”);else{if(“object”==typeof b){if(“array”==n(b)){var d=b;b=d.length;c.push(“[“);for(var e=””,f=0;f<b;f++)c.push(e),e=d[f],U(a,a.o?a.o.call(d,String(f),e):e,c),e=”,”;c.push(“]”);return}if(b instanceof String||b instanceof Number||b instanceof Boolean)b=b.valueOf();else{c.push(“{“);f=””;for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&(e=b[d],”function”!=typeof e&&(c.push(f),Aa(d,c),c.push(“:”),U(a,a.o?a.o.call(b,d,e):e,c),f=”,”));c.push(“}”);return}}switch(typeof b){case “string”:Aa(b,c);break;case “number”:c.push(isFinite(b)&&!isNaN(b)?String(b):”null”);break;case “boolean”:c.push(String(b));break;case “function”:c.push(“null”);break;default:throw Error(“Unknown type: “+typeof b);}}},Ba={‘”‘:’\\”‘,”\\”:”\\\\”,”/”:”\\/”,”\b”:”\\b”,”\f”:”\\f”,”\n”:”\\n”,”\r”:”\\r”,”\t”:”\\t”,”\x0B”:”\\u000b”},Ca=/\uffff/.test(“\uffff”)?/[\\\”\x00-\x1f\x7f-\uffff]/g:/[\\\”\x00-\x1f\x7f-\xff]/g,Aa=function(a,b){b.push(‘”‘,a.replace(Ca,function(a){var b=Ba[a];b||(b=”\\u”+(a.charCodeAt(0)|65536).toString(16).substr(1),Ba[a]=b);return b}),'”‘)};var Da=function(a){var b={};if(a&&a.key_value){a=a.key_value;for(var c=0;c=this.boundingClientRect.bottom&&this.boundingClientRect.left>=this.boundingClientRect.right)},Fa=function(){var a=new Ea;return a.N&&(!a.Y||a.O>=a.X)};var V=function(a,b){this.F=a;this.m=0;this.j=document.getElementById(“mtadmas”);this.L=document.getElementById(“mtadmaundo”);this.B=document.getElementById(“mtadmac”);this.C=document.getElementById(“mtadmback”);this.I=document.getElementById(“mtadmpc”);this.M=document.getElementById(“mtadmpundo”);this.w=document.getElementById(“mtadmpunclose”);this.K=this.u=this.G=this.D=null;this.v=0;this.h=null;this.i=!1;this.s=null;this.T=b?b.getAdsLength():1;(this.g=b)&&this.g.registerWidget(this,0);this.H=0},Ga=function(a,b){for(var c=[],d=b;d&&”BODY”!=d.tagName;d=d.parentNode)d.style&&”block”!=d.style.display&&(c.push({el:d,val:d.style.display}),d.style.display=”block”);for(var d=a(b),e;e=c.pop();)void 0!==e.W&&(e.Z.style.display=e.W);return d},Ha=function(a){for(var b=document.getElementsByName(“surveyOptions”),c=0;c<b.length;c++)T(b[c],r(a.U,a,b[c].value));a.L&&T(a.L,r(a.A,a,”1″));a.M&&T(a.M,r(a.A,a,”3″));a.w&&T(a.w,r(a.V,a));a.C&&T(a.C,r(a.back,a));a.g&&(a.g.listenOnObject(“mute_option_selected”,r(a.J,a)),a.g.forEachAd(r(function(a){a.listenOnObject(“multislot_mute_collapse”,r(this.S,this));a.listenOnObject(“multislot_mute_collapse_undo”,r(this.R,this))},a)))};V.prototype.J=function(a){this.D=a.close_button_token;this.G=a.creative_conversion_url;this.u=a.ablation_config;this.K=a.undo_callback;this.v=a.creative_index||0;this.g&&(this.s=this.g.getAd(this.v));if(1===a.type){a=Q(“survey”);for(var b=”survey_”+this.v,c=0;c<a.length;c++)a[c].style.display=a[c].id==b?”block”:”none”;a=document.getElementsByName(“surveyOptions”);for(b=0;b<a.length;b++)a[b].checked=!1;this.j.style.display=”block”;W(this);X(this)}else 0===a.type&&(this.I.style.display=”block”,this.j.style.display=”none”,W(this),Ia(this,document.getElementById(“pub-feedback-closing”),this.u))};var Y=function(a){a.h&&(window.clearInterval(a.h),a.h=null,a.i=!1);P(“pub-feedback-closing”).style.display=”none”;P(“ad-feedback-closing”).style.display=”none”};V.prototype.A=function(a){this.i||(Y(this),va(Z(this,”user_feedback_undo”,a)),this.K())};V.prototype.V=function(){var a={msg_type:”resize-me”};a.key_value=[{key:”r_nh”,value:String(this.H)},{key:”r_str”,value:”animate”}];a=za(a);window.top.postMessage(a,”*”);this.i=!1;this.A(“3″)};V.prototype.back=function(){this.i||(Y(this),this.j.style.display=”block”,W(this),X(this))};V.prototype.U=function(a){this.B.style.display=”block”;this.j.style.display=”none”;X(this);va(Z(this,”mute_survey_option”,a));a=document.getElementById(“ad-feedback-closing”);this.me||e>g||a.h)){var h=sa();c=r(function(){var a=””;g<=d&&0=g&&Y(this);g–},a);c();0<=g&&(a.h=window.setInterval(c,1E3))}},Ia=function(a,b,c){if(c&&window.top&&window.top.postMessage){var d=xa(c),e=Da(d),f=”resize-me”==d.msg_type&&”animate”==e.r_str;if(“ablate-me”==d.msg_type&&e[“collapse-after-close”]||f&&!Fa())a.w&&(a.H=window.innerHeight,f=document.getElementById(“cbtf”),f=ta(u||(u=new S),f)[1],f=Ga(a.P,f),c=La(d,f)),Ka(a,b,t(e[“secs-to-countdown”],1),t(e.countdown,0),t(e[“message-tick”],1),function(){window.top.postMessage(c,”*”)})}},La=function(a,b){if(!isNaN(b)&&isFinite(b)){var c=!1;if(a.key_value){for(var d=a.key_value,e=0;e<d.length;e++){var f=d[e];if(“key”in f&&”value”in f&&”r_nh”==f.key){c=!0;f.value=b.toString();break}}c||d.push({key:”r_nh”,value:b.toString()})}}return za(a)};V.prototype.P=function(a){var b=ua(a);a=ua(a.parentNode.parentNode);return parseInt(b.height,10)+parseInt(b.marginTop,10)+parseInt(a.marginTop,10)};var Ja=function(a,b){Ka(a,b,1,0,0,r(function(){var a={creative_index:this.s.getIndex(),undo_pingback_url:Z(this,”user_feedback_undo”,”1″)};this.s.fireOnObject(“multislot_mute_collapse”,a)},a))};k=V.prototype;k.S=function(){this.m++;this.g.resetAll()};k.R=function(){0
// https://tpc.googlesyndication.com/pagead/js/r20160830/r20110914/abg.js