top of page

A Slice of Pi for Alexa

  • Writer: Brett Schenck
    Brett Schenck
  • Nov 15, 2016
  • 5 min read

I recently came into possession of a Raspberry Pi, a credit card-sized computer that can be controlled by ordinary desktop peripherals such as a keyboard and mouse. It's got all the features of a modern computer: Bluetooth, WiFi, HDMI, USB, Ethernet, etc. Its Linux-based OS can be manipulated via a GUI or by SSH'ing into a terminal. Did I mention it also has an array of GPIO pins? Making it the perfect pocket-sized device for any electronic project you can think of. You can read more about it here.

Now then, some of you have heard of Amazon's Echo? No? Then, see here and get out from under your rock. The Alexa Voice Service (AVS) that runs on the Echo is open source and an API is available for the forking. Some folks at Amazon actually encourage third party development using their AVS to further expand their Alexa Skills Kit. In fact, they have made a nice little write up on integrating Alexa with your next project, see here.

I want an Amazon Echo, but I don't want to pay $180+ for one. I also don't want to be tethered to a power outlet to use it. Further, I want more control and the Pi's GPIO pins, USB, and GUI prove to be the perfect candidate to make a budget Amazon Echo.

Step One: Bill of Materials

As with any project, you need to start thinking about what this thing will consist of. Fortunately for me, I had done a similar project in Academia and had some materials I could re-purpose.

Materials I Already Had:

  • Raspberry Pi 3 Model B

  • 6000mAh 12V LiPO Battery w/ Battery Management System (BMS)

  • 20 Watt, 4Ω Impedance, 4" Speaker

  • Surface Transducer - To turn any surface into a speaker

  • 20 Watt Class D Amplifier

Stay tuned as this BOM will be growing throughout this post.

Step Two: 3D Design

What does this look like? How are the components mounted? That's what drafting this will solve. First, I'd like to say that Autodesk's TinkerCad is a brilliant online 3D modeling tool that really saved me a lot of time for quick design changes. If you haven't heard of it, go check it out. I was able to use some inspiration from a project in Academia that some friends and I worked on as a general basis for this design. (Thanks guys!) Below is what I came up with:

You can see above that the pi is mounted inside the cylindrical enclosure. There's a top dome with a reverse cone where a speaker could be mounted for an omnidirectional sound. (Don't quote me on this...not an Acoustic Engineer). The surface transducer can be mounted to a bottom plate and the battery be mounted internally adjacent to the Pi. Looks cool, right? Let's make it!

Step Three: 3D Printing

Ah, 3D Printing. Arguably the greatest innovation of the 21st century, when it's actually working. 3D printing still has quite a way to come. Even some of the big industry names, like my Makerbot, still have their quirks and require a lot of patience and time. This particular build took over 37-hours for just one of the four parts required. Not to mention the countless failed prints I encountered. If it wasn't my printer malfunctioning, it was the temperature effects of cooling plastic. One particularly called: curl.

Curl can be your worst enemy. Some ways to counter it are enclosing your printer to isolate it from outside temperatures and to really build up the temperature inside the enclosure. Another solution is to add a raft that your model sits on. The raft is made to breakaway easily and help adhere your model to the build plate. Below is the tremendous curl I encountered during one of many prints of the cylinder:

Step Four: Sand, Primer, Repeat.

I think there is a common misconception about 3D printing and that it delivers polished, commercial-looking parts when the reality is actually quite the opposite. This is probably where I spent the most hours and I still am not finished with the aesthetics of the Pi Speaker yet. If there is interest in a detailed write up on polishing 3D prints, let me know. :-D

Step Five: Ode to Electronics.

This is probably the part you all came for. The part where I talk about the guts of this thing and setting it up. Or at least the part I enjoy talking about the most. Okay, so we know the Raspberry Pi 3 operates at a minimum supply voltage of 5 Volts DC and has a suggested current supply of 2.5 Amps (probably for USB and other power hungry peripherals). WARNING: ​This is where I decided that using a DC-DC Switching Buck Converter (steps down 12 V to 5 V) would be a good idea for an audio project. Now, I did extensive research on noise and was under the impression that I could design a filter for anything. ​​Wrong. Not only did I have to worry about noise from the DC-DC Switching Supply, but because the Class D Amplifier shared a main PSU as the Raspberry Pi, I also created what's called a ground loop. On top of that, the Digital to Analog Converter (DAC) for the Pi's audio analogue output is Pulse Width Modulated (PWM) at an equivalent of an 11-bit audio resolution, which will tend to give poor distortion. And any noise on the power supply of that 11-bit PWM will be pushed into the audio signal and then made audible through the 3.5mm Audio Jack. Having noise generated from three different locations was a lot to swallow. I could design a double pi filter for the noise switching supply, sure. I could have used a ground loop isolator between the analog audio out of the Pi and the amplifier. Then, put a variable resistor at the secondary winding of the ground loop isolator to drive down the impedance until I heard cleaner sound. (This is called a Rheostat). Admittedly, I did try a a ground loop isolator but the PWM audio was still very distorted. I was presented with an ultimatum, do I spend time and money on noise suppression or do I find an external DAC with a higher resolution. New DAC with 24 Bits resolution here we come!

Looking at the image to the right, you can see the HiFIBerry mounted right on top of the Raspberry Pi's GPIO pins. It takes solid 12 Volts and powers both the Pi and the Amp with a single source. It has all the filtering your heart desires for Audio Amplifiers and it packs punch!

You may also be wondering what the giant microphone and stand are next to it. Good question, the answer is that the far field microphone I had intended on embedding in the enclosure had broke so I could either buy another one or use this near field microphone. By the way, debugging that it is your microphone that's broken and not a software issue with Raspbian was a feat all by itself.

Step Six: Assemble

This part is pretty self explanatory. I mounted the components where they belong in the enclosure. I used double sided tape to fix the battery to flat side inside. I used a panel mount button with an LED for power. I also used a panel mount 2.1mm DC barrel jack for power termination. Next was mounting the speakers and surface transducer then closing everything up.

Screwing everything together and plugging in the battery charger and USB microphone:

Conclusion

After designing, printing, sanding, painting, wiring, and programming, this Pi Speaker is finally complete (with a caveat of finishing touches on paint). I ran into many problems and frustrations with this project. With printer malfunctions, inherent noise, software glitches, mic drops (teehee), and pretty much any problem that could have happened, I still persevered and tackled each one until I finally have a high fidelity sound and intuitive new friend, Alexa.

 
 
 

Comments


Featured Posts
Check back soon
Once posts are published, you’ll see them here.
Recent Posts
Archive
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square

ABOUT US

We are natives to Wilkes-Barre, PA on a mission to revolutionize the way you listen to music and improve your at home quality of life.

  • Grey Facebook Icon
  • Grey Twitter Icon
  • Grey YouTube Icon

© 2016 HOMEAUD.IO

NEW RELEASES

Stay Tuned

bottom of page