Materials

For this project, you’ll need:

The Raspberry Pi 3 or Pi 2 Model B and Micro-USB power cable Micro SD Card (Minimum 8 GB) – If you don’t have an operating system installed, there’s an easy-to-use operating system called NOOBS (New Out of the Box Software). The simplest way to get NOOBS is to buy an SD card with NOOBS pre-loaded. USB 2.0 Mini Microphone External speaker and 3.5mm audio cable USB Keyboard and Mouse and external HDMI Monitor Internet connection (Ethernet or WiFi) For a Pi 2 to connect to the Internet wirelessly, you need a WiFi Wireless Adapter. The Pi 3 has built-in WiFi.

Complete your profile information.

Read and accept the App Distribution Agreement.

Select whether you are choosing to monetize your apps.

From the top menu, select “Alexa Voice Service.”

The “Welcome to Developer” screen will appear.

The first screen asks about the product you are building.

  1. First, name your device.

  2. Next, type a Product ID with no spaces or special characters. Note: You need this later. Record it somewhere.

  3. Select Alexa-Enabled Device for the product type.

  4. Alexa needs a companion app. Select yes for this question.

  5. Choose Wireless Speakers from the dropdown menu.

  6. Enter “Raspberry Pi Project on Github” into the description box. This is information for AVS and isn’t visible to others.

  7. Check both the “Touch-initiated” and “Hands-free” options.

  8. You can upload an image for your device, but let’s skip this step for now.

  9. Check “no” for commercial distribution and children’s product questions.

  10. Click “Next.”

Create your security profile

  1. Click “Create new profile.”

  2. Create a name for the profile. It could be something like, “Alexa Security Profile.”

  3. Type a description for the profile. You can choose “Alexa Security Profile Description.”

  4. Click “Next.”

  5. Enter your Allowed origins and Allowed return URLs. We’re setting up http and https routes for this project, so type the following into your “Allowed Origins” field — “http://localhost:3000.”

  6. Click “Add.”

  7. Type “https://localhost:3000” into the same box where you typed the first one.

  8. Click “Add” again.

  9. Do the same thing to the Allowed Return URLs, except enter the following two URLs:

  10. The page should look like this before you click Finish. Make sure none of your URLs are still in the field where you typed them. They are displayed on a grey background after you add them.

  11. Once you click “Finish,” this screen appears. Your project has been created and is ready to install.

Clone the Alexa sample app

  1. Open Terminal.

  2. Type the following:

Update the install script by adding your credentials

  1. Type the following in Terminal:
  2. When it runs, this screen appears. Use the arrows on your keyboard to navigate, and replace the fields for ProductID, ClientID, and ClientSecret with your values.

The changes should look like this: 3. Type Ctrl + X to exit the script. Type Y and then Enter to save your changes.

Run the install script

To run the script, open Terminal and run the following commands.

The installation is about thirty minutes, so go grab a snack. When installed correctly, your terminal window will look like the following image.

The Three Terminals

You must complete three steps to run the Alexa app. Each of them must run in a separate Terminal window, and you must do them in the correct order. There were some programs that I needed but didn’t have. I installed these programs as I went. In case you have the same problem, I included a side note about this in each step.

Terminal 1

This window runs the web service to authorize your app with AVS (Alexa Voice Service) Open Terminal and type in the following commands: Note: npm is a package manager for the JavaScript programming language. If it is not available when you run the command, you can get it here. When the scripts finish, the window looks like this, showing that Pi is listening on port 3000.

Don’t close this window. It needs to remain open while completing the next steps.

Terminal 2

This window communicates with AVS. Type the following into another Terminal window. Note: mvn is short for Apache Maven. If you don’t have it, click here to get started. When you run the client, a dialog box appears saying, “Please register your device by …” Click Yes.

With some browsers, you’ll get a warning that the connection is not safe. Dismiss this by clicking the “advanced” button. Then on the next screen, click on “Proceed to localhost (unsafe).” The next screen asks for permission to use the security profile you created earlier for the device you are registering. Click Okay.

You will be redirected to a URL beginning with “https://localhost:3000/authresponse” that looks like the following image.

Go back to the open dialog box and click the OK button. The client is now able to accept requests from your Alexa device. Keep the terminal open as well as the Voice Service Dialog box.

Terminal 3

This window installs the application that wakes up Alexa by using her wake word. Skip this if you don’t want to use voice to initiate Alexa. Open a new terminal window and use one of the following commands to bring up a wake word engine using Sensory or KITT.AI. To use the Sensory wake word engine, type: To use KITT.AI’s wake word engine, type:

Test it out

Talk to Alexa by saying the wake word, “Alexa.” Wait for the beep before giving your command. For example, try it by saying, “Alexa.” Wait for the beep, and then ask, “What’s the time?” If she responds correctly, you have a working Alexa device!