Suddenly, everyone is talking to their technology. Smartphones, TVs, even light bulbs can all be controlled with the help of a home assistant. As the Internet of Things takes over your home, you’ll find more and more devices responding unexpectedly to your voice thanks to virtual assistants like Amazon Alexa.

Unlock «Mega List of 100+ Useful Amazon Alexa Commands» now!

This will subscribe you to our newsletter

Enter your email address
Read our privacy policy

If you have a spare Raspberry Pi, you don’t need to buy an Amazon Alexa device like the Echo or Echo Dot because you can build your own. This tutorial will show you how to set up Alexa Home Assistant on your Raspberry Pi.

You will need equipment

Before you start building your DIY Raspberry Pi Alexa, you will need:

  • Raspberry Pi with Raspbian installed on a micro-SD card
  • Suitable power supply (recommended 5V @ 2.5A)
  • USB microphone
  • Speaker
  • PC to set up Amazon Developer account and SSH client

Before you begin, and if you haven’t already, you need to enable SSH connections with your Raspberry Pi. . If you prefer, you can set up your Raspberry Pi with a keyboard, mouse, and monitor. You’ll need a microphone, but if you don’t have one, a USB webcam with microphone will do the same.

Under normal circumstances, I would recommend installing Raspbian Lite to reduce resource usage. However, the script you need to install cannot be installed with a standard Raspbian Lite installation. To get around this, install GStreamer, a Linux media environment, to allow it to be installed by running the following via SSH or on a terminal screen:

sudo apt update && sudo apt upgrade sudo apt install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-pulseaudio 

Step 1: Create an Amazon Developer Account and Security Profile

Before you can install the Alexa software, you need to create an Amazon developer account. If you have an existing Amazon account, you can sign in and register an Amazon developer account this way.

Once you are logged in, go to Alexa on the navigation bar, then to Alexa Voice Service. Click » To begin» then » Products»> « Create a product.

Amazon Developer Account Registration Process Screen

Give your device a name and a product ID. Select » Device with built-in Alexa» and select » Not» for a question about the companion app. Select » Other» in the dropdown menu Product Category» and type Raspberry Pi in the corresponding box below. Give it a brief description, such as «Raspberry Pi Alexa Build Example».

Select touch-init- and hands-free to interact with the end user. You don’t have to worry about choosing an image. Select » Not» for the last four questions, then click » Further».

On the next screen, you will need to create an Amazon security profile in order to link your security data to your Raspberry Pi Alexa. Click Create a new profile . Choose a name and description similar to mine below.

Registering an Amazon Developer Account Security Profile

In the next step select » Other devices and platforms» then paste the client ID name (can be anything), agree to the terms and click » Create ID. You will then see a popup informing you that your product has been created.

Next, enable your profile. Go to the Amazon Developer Login page and select your profile from the drop down menu, then click » Confirm».

Insert a domain, for example raspberrypi.local, in the appropriate field and click » Save».

Step 2Download the Amazon Assistants Pi Script

To easily install Amazon Alexa on your Raspberry Pi, you will use a script called Assistants Pi. This provides an easy way to install Alexa without having to manually build the SDK.

First you need to install Git to get the files you need from the script developer. Connect to your Raspberry Pi using an SSH client, or if you’re not using a headless Pi, open a terminal and type:

 sudo apt install git 

Once Git is installed, clone the desired files by typing:

 git clone 

You need to make the script files executable. Do this by typing:

 cd /home/pi/Assistants-Pi/scripts/ sudo chmod +x 

Step 3: Pre-configuration before installation

Before you can run the initial Assistants Pi scripts, before you can install Alexa, you need to install PIP for Python on your Raspberry Pi. Check if it is installed with the following:

 pip --version 

You should receive a response confirming your version. If you don’t, reinstall PIP with apt.

PIP Python version check terminal command
If PIP is installed correctly, the next step is to run the Assistants Pi provisioning script Run the following:

 sudo /home/pi/Assistants-Pi/scripts/ 

This will begin installing any packages you need, and will also check if Raspbian is up to date.

Pi Assistant Preparing Terminal Script

Once everything is installed, you will be presented with six options for audio and microphone settings. Most people will need to choose USB-MIC-ON-BOARD-JACK so click 3 and press enter. Select this option if you are using a USB microphone with a speaker connected to the audio port.

Reboot your Raspberry Pi at this point by typing:

 sudo reboot 

After the reboot, verify that your audio settings are correct by doing the following:

 sudo /home/pi/Assistants-Pi/scripts/ 

This will test your speaker and microphone to make sure your Raspberry Pi works with both.

Step 4: Run the install script

Assuming you had no problems with either the microphone or the speaker during the audio test, run the following command to install Alexa on your Raspberry Pi:

 sudo /home/pi/Assistants-Pi/scripts/ 

You will be given the option to choose to install Alexa, Google Home Assistant, or both. The script requires additional steps to install Google Assistant, so it’s best to skip it. Choose an option 2, to install only Alexa.

Helpers Pi Terminal Script Assistant Installer Menu

You will need to enter your client ID. Go back to the Alexa developer portal to find this by clicking on your «product» name. Write down your product ID.

Click on your product name, click security profile, then Other devices and platforms. Use the customer ID found here, then enter your product ID before agreeing to the terms. Enter I agree and press Enter.

Raspberry Pi Alexa SDK Terms Agreement

The script will run during installation, installing any other packages it needs. This may take some time to complete. You may have to accept one or two licenses; just read and click Y for any confirmation menu.

Step 5: Final Setup and Testing

After the script has completed the installation, you need to execute one last script:

 sudo /home/pi/Assistants-Pi/scripts/ 

Run the following to make sure the service is started and enabled:

 sudo systemctl enable alexa.service sudo systemctl start alexa.service 

You will then need to register and authorize your Pi. Enter the following:

 sudo /home/pi/Assistants-Pi/Alexa/ 

You will need to enter the code shown on the terminal screen on the page on the Amazon Developers site. Enter the code, click » Proceed», then » Allow».

Authorization page for accessing an Amazon Developer product

Assuming your Pi authorization went well, you should see an example Alexa script. Check out the DIY Raspberry Pi Alexa device by saying that Alexa accompanied by a team. For example, Alexa, tell me the time.

Restart your computer for the last time and test the device again by entering another command to make sure everything works.

DIY Amazon Alexa for your home

You don’t have to buy an expensive new device for your home to enjoy the benefits of a smart speaker. A spare Raspberry Pi is a great helper for the home, whether you’re building a DIY Alexa or if you want to build your own DIY Google Home.

If a smart speaker for your home is not to your liking, maybe head outside and build some solid Raspberry Pi projects. instead of this.

Похожие записи