Raspberry Pi Amazon Echo

Introduction: Raspberry Pi Amazon Echo

The Amazon Echo is a brilliant piece of technology. It's a fantastic AI that not only can it do the basics such as answering questions, scheduling events, and playing music, but it can also control your home’s smart electronics such as TV’s, phones, computers, and even refrigerators. However, you can't really expand the device itself much.

The Raspberry Pi is the most suitable piece of hardware for this project, because it is one of the most versatile components on the consumer market, considering it’s $35 price tag. Using the Pi instead of the Amazon hardware gives users the advantage of customizing their hardware. With the Echo Dot, users can plug in their own speaker, and that’s about it. They cannot tweak the hardware, software, or peripherals. What you see, is essentially what you get. With a Pi, you can install your own far-field microphone or speaker.

If you wish, you can switch the Raspberry Pi to something else at any time, the Alexa software does not permanently turn the Pi into an Echo. If I get bored of Alexa, I can switch my Pi into a retro game emulation machine, personal VPN, music server etc. All of this is as easy as buying a Raspberry Pi, downloading, and running the Alexa software.

Step 2: Setting Up Your Pi

Since this is a project about setting up Alexa, and not the Raspberry Pi itself. I'm going to assume you've already booted your Pi with NOOBS and installed an operating system and connected it to the internet.

Step 3: Registering Your Raspberry Pi With Amazon

Go back to your normal computer, and create an Amazon developer's account.

Now I know what you're thinking, creating accounts is super annoying. Don't worry, if you already have an Amazon account then you have a developer's account. Just go to developer.amazon.com and register!

Steps for Registering Your Raspberry Pi with Amazon as an Alexa Device

Log into your developer account

Click on the "Alexa" tab

Click on "Alexa Voice Service"

Under the "Register a Product Type" dropdown, select device.

Under "Device Type ID" and "Display Name", choose a name for your Raspberry Pi device. Use this name for both your Device ID and Display Name

Step 4: Clone/Install the Echo Service

In this step, we're going to be cloning/installing the Alexa program from Amazon's official GitHub page.

Steps for Cloning/Installing Alexa

On your Pi desktop, open up the terminal by pressing:

ctrl+alt+t

Navigate to your desktop (or whichever directory you want to install Alexa in) using the command:

cd desktop

Clone Alexa by typing in the command:

git clone https://github.com/alexa/alexa-avs-sample-app.git

Once the cloning sequence is complete, navigate to your Alexa directory by typing in the command:

cd ~/Desktop/alexa-avs-sample-app

Before beginning the install sequence, we're going to have to edit some install parameters using the nano text editor in terminal. Open up the document in which you recorded all of your device's information.

You can edit the install file by typing in the command:

nano automated_install.sh

Since this is in the terminal, you can use your mouse to navigate. Don't be scared, the arrow keys work just fine! You're going to need to type in your ProductID, ClientID, and Client Secret into the appropriate fields.

You need to make sure these values are entered right after the "=", and make sure these values are EXACT.

Save and close nano by typing:

ctrl+x

Navigate back to your Alexa directory, and start the install sequence by typing:

. automated_install.sh

This is going to take a while, but we're almost done!

Step 5: Running the Alexa Companion App

The next step is to run the Alexa companion service. We're going to have to make sure she is listening to port 3000, which is the port we assigned Alexa when registering our Pi with our developer's account

Steps for Running the Companion App

Navigate to Alexa's companion service directory by typing in the command:

cd ~/Desktop/alexa-avs-sample-app/samples/companionService

In order to open up communications for Alexa, we're gonna have to use a program called Node. Node is installed by default with the Alexa app. We're going to start Node by typing the command:

npm start

*IF THERE IS SOME SORT OF ERROR WITH NODE YOU MIGHT NOT HAVE IT INSTALLED CORRECTLY. IF THIS HAPPENS TYPE IN THE COMMAND:*

sudo apt-get npm

You should see a "Listening on port 3000" message in your terminal, that means Node is doing its job! Next, we're going to "build" the Alexa app with a program called Maven (another default Alexa app). This just means we're going to be starting it up.