Build A Raspberry Pi Amazon Echo in 7 Steps

Are you a fan of Amazon Echo but can’t afford it? Or perhaps there’s no room for that expense in this month’s or maybe year’s budget. It’s a great tool to have at home. It can help you play your favorite podcasts, set up reminders, and even control many other appliances in the house. However, if you are not sure if you’d be using it much, you could just be wasting money. So for this tutorial, we have compiled a simple procedure to build your very own Raspberry Pi Amazon Echo so you can enjoy all those amazing features without spending much!

Source and original idea from Lifehacker.

About this project

Okay so maybe it won’t be the biggest money saver since Amazon’s Echo Dot is only around $50. But an Echo could only be an Echo, your Raspberry Pi can be turned into a multifunctional device so you can run multiple applications using a single Raspberry Pi that is slightly cheaper. So that makes it worthwhile.

With this project, you will get a fully functional (almost) Amazon Echo with all the bells and whistles. The only shortcoming would be that it won’t access music services like Spotify, Pandora, or Amazon Prime. Apart from that, it will read you ebooks, check game scores, play radio, and pretty much every other thing that Amazon’s Alexa does. At the end of this project, you’ll use the Alexa companion app to change your Alexa settings. This will allow you to install all the features of a real Echo. Also, you would be able to integrate it with other third-party apps like Any.do and Todoist.

What’s more? It will also connect with other devices including the Nest Thermostat, smart light bulb, and much more so you can control these devices with your voice commands. If everything goes right, your DIY Raspberry Amazon Echo will easily connect to If-This-Then-That to add additional features like getting notifications on your smartphone, and adding to-do-notes to Evernote.

It’s important to mention here that this project will not affect your Raspberry Pi’s other projects. It will still work for the other projects without a hindrance.

So if you are ready, let’s get into it.

Step 1: Gather the parts

You’ll need:

  • A Raspberry Pi 3 with Raspbian. With Model 2, you will also require a USB Wi-Fi adapter.
  • MicroSD card (8GB)
  • Micro USB power cable
  • Speakers and a USB microphone
  • A mouse and a keyboard for setup. Or access to the PC with VNC.

If you have an older version of Raspberry Pi, you will need to install the latest version of Java. In terms of software, you’ll need Amazon Echo Skills Kit (you’ll install it onto your Pi). For this project, we used Amazon’s official code. You’ll have to manually power up Alexa service every time you boot your Raspberry Pi.

Step 2: Register your Amazon developer account

Follow the following steps to register your free Amazon Developer Account:

  • Log in to your Developer account. And click on the Alexa tab.
  • Register your product type: choose the device.
  • Choose device type and display name (in this project we choose Raspberry Pi as both).
  • Click Next and select “Create New Profile” on the next screen.
  • Name your profile and description, then click Next.
  • Open notepad on your phone and record Product ID, Client Secret, and Client ID. You will need them later.
  • Go to the Web Settings tab and click on the Edit button right next to the profile dropdown menu.
  • Next to “Allowed Origins” click “Add Another and type the following line: ⦁ https://localhost:3000
  • Next to “Allowed Return URLs” click Add Another and type the following line: https://localhost:3000/authresponse. Then click Next.
  • Go to the Device Details tab and add a description, pick the expected timeline, and enter “o” next to how many devices you’ll be using. Click Next.
  • In the final step, You could choose Amazon Music in this step, but since it won’t work on the Pi, you can leave it as “No”.

That’s it! Now you have an Amazon Developer Account and you have the profile for the Pi-powered Echo. Let’s get into the process of building a Raspberry Pi Amazon Echo.

Step 3: Start the cloning and install Alexa

Boot your Pi to get started. You will eventually need a web browser to authenticate your device so make sure that you are in the PIXEL or graphic user interface.

Now follow the following steps:

  • Start the terminal application and type in the following command: cd Desktop. Press enter.
  • Type in the following URL: git clone https://github.com/alexa/alexa-avs-sample-app.git
  • Press enter to move to the next step.
  • Type in the following: cd ~/Desktop/alexa-avs-sample-app
  • Next, type in the following:
    nano automated_install.sh and press enter.
  • The last command will open the text editor. This is where you’ll enter the Product ID, Client Secret, and Client ID. Enter the data into each field and then press CTRL X to save.
  • After you hit enter, you will be back at the main command line. Here you will run the script for installation. Type in:cd ~/Desktop/alexa-avs-sample-app. And press enter.
  • Next, type this line. automated_install.sh and hit enter.

When the system prompts, type in “Y” or answer as you see best.

These steps will configure your Pi. It may take around 30 minutes, so be patient.

Step 4: Initiate the Alexa Service

In this step, you have to run 3 different commands at the same time in 3 different terminals. Do not turn off any windows. And remember that you’ll need to do step 4, 5, and 6 every time you reboot your Raspberry Pi.

The first command will start in the Alexa web service:

  1. Type Cd ~/Desktop/alexa-avs-sample-app/samples and press enter.
  2. Type cd companionService && npm start and press enter.

These commands would start communication with Amazon through the companion service. You need to leave this window open.

Step 5: Initiate a sample app and confirm your developer’s account

In this step, open the second terminal window by clicking on File and then New Window. This step will run a Java app and open a web browser where you can register your Pi with Alexa service.

Follow the following steps:

  1. Type in your terminal window: cd ~/Desktop/alexa-avs-sample-app/samples and press enter.
  2. Type cd javaclient && mvn exec:exec and hit enter.

After the last command, you’ll see a window that will ask for authentication. Click “Yes” and you will be directed to another browser window. There will be a second pop-up in the Java app prompting you to click ok. But do not click ok just yet.

  1. Log into your developer’s account. An authentication screen will be waiting for you. Click okay here and you will see this message: “device tokens ready”.
  2. Now you can go back to the Java app pop up and click ok.

Now, your Raspberry Pi is ready to communicate with the server.

Step 6: Set up the wake word

Don’t close this terminal window yet and open the third terminal window. In this step, you’ll prepare your Echo to listen to your commands. There are two options to setup wake word (Alexa) software: KITT.AI and Sensory. The latter expires in 90 days so we recommend KITT. Here are the steps you need to follow:

  1. Type Cd ~/Desktop/alexa-avs-sample-app/samples in and hit enter.
  2. Next, type cd wakeWordAgent/src && ./wakeWordAgent -e kitt_ai

And you are done! Your DIY Raspberry Echo is now running. Use the wake word “Alexa” and you should hear the beep that indicates it’s listening. Upon hearing the beep, ask Alexa a question.

Step 7: Improve the microphone

Now for the final step, let’s go to the command line one more time to make sure that your Amazon Echo can hear you just right.

  1. Type alsamixer and hit enter.
  2. Press F6 and choose a different USB device., then select your microphone. Using the arrows.
  3. Again use the arrow keys to adjust the volume. When you are happy with the intensity of the volume, press ESC.
  4. Type sudo alsactl store and hit enter to save the changes.
    Now, your Alexa should be listening and you don’t have to yell to help her understand. Go ahead and give it a try!

Before we go, there’s one more thing you can add to your Raspberry Pi Amazon Echo: The ability to work as a Bluetooth speaker. You can add that functionality with AirPlay. With this functionality, your Echo will act as a receiver too so you can send music from other devices like your phone or computer. To make this happen, let’s go back to the command line:

  1. Type:
    Sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils limodule-build-perl
    And press enter. This will install a different software.
  2. Press y and wait for the software to download and install.
  3. Then type:
    Git clone https://github.com/njh/perl-net-sdp.git
    And press enter. This is important for AirPlay’s new version. The next lines of commands will install this software.
  4. Type: cd perl-net-sdp and press enter.
  5. Type: perl build.PL and press enter.
  6. Type: sudo ./build and press enter.
  7. Type: sudo ./Build test and press enter.
  8. Type: sudo ./Build install and press enter.
  9. Type: CD .. and press enter.
  10. Type: git clone https://github.com/hendrikw82/shairport.git and press enter.
  11. Type: cd shairport and press enter.
  12. Type: make and press enter.
  13. Type: ./shairport.pl -a AlexaPi and press enter.

If all the commands are entered right, you can now stream music on your DIY Amazon Echo.

Get your Raspberry Pi 3 here and get started.

We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: