Close

Running Amazon Echo (Alexa) on Raspberry Pi Zero


Amazon Echo or Alexa is a device and service by Amazon, which allows you to request news, weather information or even automate your home using voice control. People have succeeded in running the Echo software on the Raspberry Pi, making it a low cost and easy to install voice control solution.

Components

The components you’ll need for this build are:

  • Raspberry Pi Zero (works with Pi 2 and 3 as well)
  • USB soundcard with microphone input
  • microphone
  • speaker with amplifier
  • momentary switch
  • USB hub (if using Pi Zero)
  • wifi dongle
  • enclosure or box to store everything in

Software

Amazon Echo

To install Amazon Echo on the Pi, I followed the instructions from Novaspirit Tech:

The instructions in the video are clear and straightforward. Everything was installed in less than 10 minutes.

I did run into issues with Python reaching 100% CPU and some glitches in the audio, so I made modifications to the main script.

 

Default Sound

To have the Pi use the USB sound card by default, some minor changes are required. Edit or create the asound.conf file as follows:

Once the file has been edited or created, restart the process to apply the changes.

Start / Restart

To have the application automatically start at boot and restart whenever it crashes, I created a helper script that check if the process is running, and if it is not, starts it.

Using cron, the script is executed every minute to start/restart the process if needed. You can change the cron expression to check more or less frequently.

Hardware

Connections

The connections are rather straightforward, and can even be configured to be different, in the main.py script of AlexaPi.

In my case, the following connections were made:

  • 5V / GND: power audio amplifier
  • GPIO 25 / GND: arcade button LED
  • GPIO 21 / GND: arcade button switch

Or as illustrated below:

Screen Shot 2016-04-07 at 21.55.20

Enclosure

For the enclosure, I reused an old box with magnetic lid, which I covered in duct tape to make it silver. I then cut a hole in the top lid for the arcade button to fit in, and a smaller hole at the back for the power cord. A Raspberry Pi sticker is used for decoration.

On the inside of the box are the components, with the speaker and microphone glued to the lid. The result may be messy on the inside, but it is clean on the outside 🙂

IMG_1247 IMG_1248

What can it do ?

Well, pretty much anything! You can ask Alexa about the weather, the news, or even to turn the lights on or off.

Alexa can also be linked to IFTTT, giving access to a bunch of channels using voice control, simply by saying “Alexa, trigger …”.

Try it, you’ll be surprised how easy it is!

© Frederick Vandenbosch, 2014-2019. Unauthorised use and/or duplication of this material without express and written permission from this blog’s author and owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Frederick Vandenbosch with appropriate and specific direction to the original content.