Introduction: Build an Amazon Echo With C.H.I.P!
By now, most of us have heard about the Amazon Echo. It's a hands-off speaker that can do a wide variety of cool functions, such as telling us the weather, finding out when our favorite sports teams are playing, or even setting timers for when we cook! Unfortunately, the Amazon Echo costs $180, and its miniature counterpart, the Amazon Echo Dot costs $50. Surely, there has to be a way to make a device that accomplishes the same functions, but for cheaper, right?
And you're right! The Amazon Echo is powered by the Alexa Voice Service, and since Amazon has made this code open source, people have found ways to modify it for use with mini-computers like the Raspberry Pi. While I don't have a Raspberry Pi myself, I do have a C.H.I.P., a small, tiny, $9 computer board. Hence, through the help of several documentation guides (which I have linked to at the end of this Instructable), I set out to transform my C.H.I.P. into my own personal Amazon Echo.
Note, however, that since this is a DIY alternative to the Amazon Echo, it won't possess the full capabilities that the actual Amazon Echo has (such as setting timers, for example). Nevertheless, the final DIY result is still really cool!
And with that, if you have a CHIP yourself, or if you have a Raspberry Pi, follow along to make your own Amazon Echo-like device! (Of course, if you have a Raspberry Pi, the instructions won't perfectly match, but the documentation at the end was designed with the Raspberry Pi in mind.) If you like my Instructable, please consider voting for me in the Microcontroller Contest!
Step 1: What You Need
You'll need several things for this project. (Some of the things are pictured above.)
- C.H.I.P. (You can find C.H.I.P. and its other related products here.)
- HDMI DIP for C.H.I.P. (This is will allow you to connect C.H.I.P to a HDMI-compliant monitor. You can also use the VGA DIP if you prefer. Both are found at the same link as above.)
- USB or Bluetooth mouse
- USB or Bluetooth keyboard
- USB powered hub. The CHIP only has 1 USB port, and if you have a USB mouse/keyboard/microphone, you'll need a hub to connect them all. Additionally, make sure to get an independently powered hub: the CHIP can't power all of your USB devices at once.
- USB microphone. I used a PlayStation Eye for this and had to do some additional tweaking to get it to work. Documentation is included at the end to explain how I did this.
- MicroUSB charging cable
- Paperclip or jumper cable (explained later).
Once you've acquired all these materials, get ready! It's a long journey from here.
Step 2: Registering an Amazon Developer Account
This is perhaps the easiest process.
- Start by going to https://developer.amazon.com/ and signing into your Amazon account. Go through the process of registering for a Developer Account until you reach a screen as shown in Picture 2.
- From here, click on the Alexa tab, and then click on Get Started for Alexa Voice Service.
- Click on "Register a Product", and then "Device".
- Choose a Device ID and a Display Name. It doesn't matter what you pick here.
- Click Next to edit your Security Profile. Click Create New Profile, and then name your profile. Then add a "Security Profile Description". The Security Profile ID, Client ID, and Client Secret are unique values for your device, and you'll want to keep these somewhere safe. You'll need them again later.
- Click on the "Web Settings" tab, and then Edit next to the profile dropdown.
- Next to Allowed Origins, click on Add Another, and then type in
Click “Add Another” again and then type in
We can leave the your.device.ip.address alone for now; we'll edit it later once we determine the IP address of our CHIP.
8. Next to Allowed Return URLs, click on Add Another, and then type in
Click “Add Another” again and then type in
Once again, we'll leave this for now, and we'll edit it later.
9. Finally, move on to the Device Details tab. You can put whatever you want in these entry fields, but put No for the last question.
Alright, we've successfully set up an Amazon Developer Account and created a unique profile for your CHIP. It's time to move on to getting Alexa downloaded and installed.
Step 3: Flashing CHIP, Connecting HDMI, Initial Set-Up
In order to connect an HDMI cable to the CHIP, we must use the HDMI DIP. However, using the new HDMI DIP requires the Linux 4.4 kernel. Most likely, your CHIP shipped with the 4.3 kernel, and we need to update it by flashing the new 4.4 kernel onto the CHIP. Follow these steps below to get your HDMI connection set up properly.
- Go to flash.getchip.com
- The instructions will tell you to connect the GND pin to the FEL pin on your chip. Ideally, you would use a jumper cable, but I didn't have one, and a paperclip worked fine. Just be careful when inserting it into the pin sockets! Follow the directions as given, and then choose the Desktop with DIP support Kernel 4.4 option (Picture 1). You'll see a screen like Picture 2, and then you'll wait for the flashing procedure to finish. Once it's completed, remove the microUSB cable from the CHIP.
- Now, very carefully align the pins on the HDMI DIP onto the CHIP. This will require a fair bit of force to push the 2 parts together, so apply constant pressure and be very gentle while doing so, as to avoid damaging the pins. Your setup should look similar to Picture 3.
- Then, connect your HDMI cable to the DIP and your monitor.
- Power up your CHIP using an actual microUSB cable and charger (preferable one that can output 2.0 A). If all goes well, you'll see a screen like in Picture 4.
After CHIP boots, attach your USB mouse/keyboard/microphone. If you have a Bluetooth device, click on the Bluetooth icon on the top right of the screen, and "Add Device". It'll walk you through a process to add your Bluetooth devices. After you have functional mouse/keyboard support, connect to a WiFi network by clicking the Network icon on the top right of the screen.
After you've set all this up, you can move on to the next step!
Step 4: Updating CHIP, Installing Git, and Downloading Alexa Services
The second thing to do when your CHIP boots is make sure it's up-to-date.
- Click on the "Computer Things" icon on the top left of the screen, and then click on "Terminal Emulator" (Picture 1).
- Now, type in the following command in the terminal, and then press Enter:
sudo apt-get install update
The terminal will then ask you for a password, and since we didn't modify anything, the default password will still be "chip" (Picture 2). Type this in (without the quotes) and then hit Enter. Don't be alarmed if you don't see the password; it's not supposed to show.
3. Here is where you might run into problems. You will need to install Git, which is the repository database that contains the files for the Alexa service. To do this, type in the following and press Enter:
sudo apt-get install git
However, when I tried this, I got an error saying "unable to access server, certificate validation failed". Bewildered, I tried Googling my error code, and the solution that I ended up using involves changing the system clock time and date. The solution certainly isn't elegant; CHIP doesn't seem to provide an intuitive way to update the system time/date, and the other solutions that involve messing around with the "ntp" (Network Time Protocol) was definitely not easy. In the end, I ended up brute forcing the time/date setting by typing the following in the terminal bottom line of Picture 3):
date -s "18 APR 2017 11:14:00"
Make sure you set the time/date to the current time/date. After this, your "install git" command should work fine with no errors. You'll see a lot of lines of text while it's installing (Picture 4).
4. Once git is installed, we can then download the Alexa service files. Type in the following command to change the currently working directory to opt.
Then, type in this command to download the files.
sudo git clone https://github.com/alexa-pi/AlexaPi.git
Once this is done, we can move on to the next step.
Step 5: Installing Alexa Services
Here we'll start installing the Alexa service. First, however, we'll need to get the IP address of your CHIP.
1. Type in the following command:
ip addr show wlan0
You'll get a bunch of text, and what you're looking for is a series of numbers after the word "inet". For security reasons, I did not include a picture of my output terminal text. Your IP address will be 4 numbers, separated by a period (for mine, it was in the format xx.xxx.xx.xx). If you recall from the step where you set up the Amazon Developer Account, we had left the your.device.ip.address unedited. Now, replace this with the IP address that you just determined.
2. Next, to start installing Alexa, type in the following command in the CHIP terminal and press Enter:
This will walk you through an installation script where you'll answer some questions. The OS is Debian, and type in "chip" when it asks for it later on (Picture 1).
3. Eventually, you'll be asked for your Amazon credentials. This is where you'll type in your Device ID, Security Profile Description, Profile ID, Client ID, and Client Secret that you saved from earlier on. After this, the script will finish, and then it will ask you to authorize your device.
4. Using your other computer, navigate to
Remember to replace your.device.ip.address with your IP address. You'll see a login page for Amazon, and after you've logged in, you'll get a message saying that your device was successfully authorized.
You're almost done! Since we used the Desktop OS version for CHIP, there's another step we have to go through to fix the audio for our CHIP.
Step 6: Setting Up System-Wide PulseAudio
Here, we need to set up system-wide PulseAudio in order to get our audio working correctly. PulseAudio is a sound server, and redirects captured sound (from a microphone, for example) to a soundcard. To do this, we'll be entering a lot of commands into the terminal:
This installs PulseAudio and removes degenerate components (Picture 1).
sudo apt install pulseaudio pavucontrol
sudo apt remove pavumeter paman padevchooser
This creates a new directory in the the /var/lib/ path, and copies a
client configuration file from the /etc/pulse directory into the newly created directory.
mkdir -p /var/lib/AlexaPi/.config/pulse
sudo cp /etc/pulse/client.conf /var/lib/AlexaPi/.config/pulse/
This will open up a text-editor interface to edit the client.conf file. In this file, change "autospawn=yes" to "autospawn=no" (Picture 2).
sudo nano /var/lib/AlexaPi/.config/pulse/client.conf
This creates and sets a home directory for a user named "alexapi".
chown -R alexapi:alexapi /var/lib/AlexaPi/
# usermod --home /var/lib/AlexaPi alexapi
Now we need to add several users to several groups: pulse user to the audio group, our chip user to the pulse-access group, the new alexapi user to pulse-access, and the root user to pulse-access.
sudo adduser pulse audio sudo adduser chip pulse-access sudo adduser alexapi pulse-access sudo adduser root pulse-access
Now we need to create the service that will start PulseAudio on boot. This will open the text-editor interface again, but this time, we are creating a new file so the screen will be blank.
sudo nano /etc/systemd/system/pulseaudio.service
Add this text to the blank file:
Description=PulseAudio Daemon [Install] WantedBy=multi-user.target [Service] Type=simple PrivateTmp=true ExecStart=/usr/bin/pulseaudio --system --realtime --disallow-exit --no-cpu-limit
Save and exit the file by pressing CTRL+x, 'y' and then Enter.
To make this service start automatically, enter this:
sudo systemctl enable pulseaudio.service
Now, we need to edit a config file to allow Alexa to use PulseAudio. Type this command:
sudo nano /etc/opt/AlexaPi/config.yaml
Within the text editor that opens, edit the following values so that they read:
output: "pulse" output_device: ""
Whew! That was a lot of code. Onward to the next step!
Step 7: Adding PlayStation Eye As Input Device
This step is potentially optional, if you didn't use a PlayStation Eye as your microphone device. If so, move on to the next step to test out your new Amazon Echo!
We need PulseAudio to recognize and load the PlayStation Eye when it starts. To do that, type these commands:
sudo nano /etc/pulse/default.pa
This opens up another text editor. Scroll to the very bottom of the file, and add this line of text (Picture 1):
load-module module-alsa-source device=hw:1,0
Step 8: Starting Your Amazon Echo!
Alright, here's the exciting stuff! Make sure your microphone is still plugged into your CHIP, and also connect your speakers to the input jack on the CHIP. Then click on the Computer Things icon at the top left of your screen again. Click on Log Off, and then in the pop-up box that appears, choose Reboot.
Once your CHIP reboots, you should hear "Hello" from your speakers! From here, to activate your CHIP-Amazon Echo, say "Alexa". Your CHIP should respond with "Yes?", after which you can ask it whatever you wish!
That's all! Have fun with your new, DIY, Amazon ECHO!
Big thanks to these following documentation guides for making this project possible. I've adapted my Instructable to work specifically for the CHIP and PlayStation Eye configuration.
https://github.com/alexa-pi/AlexaPi/wiki/Installation (This is the source documentation that makes this entire project possible. Refer to this if you have any other problems!)
We have a be nice policy.
Please be positive and constructive.