The Amazon Echo let's you talk and ask questions to your computer. It adds 'Artificial Intelligence' to your machine. It' s a lot of fun!
But for the moment, the 'Echo' is only available in the USA and it has a certain pricetag....
Luckely! You can make one yourself, using a Raspberry Pi. It works outside the USA and it is much cheaper.
What's the difference between the Amazon Echo and your homemade Alexa?
- On the homemade version, you have to push a button before asking a question. It is not allowed to put your own Alexa in 'listining' mode.
- The design of your Alexa of course. You can dress it up the way you want :-)
I've built my Alexa for Raspberry Pi, using the Raspio Pro Hat add-on board. It makes wiring your project much more simple and save!
- Raspberry Pi 3
- Raspio Pro Hat
- USB microphone
- Speaker with 3.5mm audio jack
- Button (momentary switch)
- some male-to-male wires
Let' get started!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Installing Alexa on Your Pi
I'm starting with the assumption you have a Raspberry Pi up and running. I won't give you a detailed description on how to install an Alexa on your Pi! There are already some good tutorials on the web. I'll give the links of the 2 I used for this project.
I used the code of Novasprit Tech, wich you can download from Github: https://github.com/novaspirit/AlexaPi
I've used the tutorial of TheRaspberryPiGuy, which helps you through wonderfully through the steps of making an Amazon account and getting all the settings right:
The other tutorial i've used is the one of Novaspirit Tech. This one helps you with configuring a button (momentary switch) and leds:
Step 2: Raspio Pro Hat and Wiring Your Alexa
Why do I use a Raspio Pro Hat (http://rasp.io/prohat/)?
Well, it's makes your life, the wiring and your project design a lot easier!!!
- The Raspio Pro Hat puts the Raspberry Pi's GPIO ports in numerical order and clearly labelled. You don't have to count pins or wonder which port you're connecting to.
- LEDs need no current-limiting resistors because they are already built-in.
- The Raspio Pro Hat also has a protection circuit on each GPIO port, which means you won't damage your Pi's ports by wiring something up incorrectly.
Another advantage of the Raspio Pro Hat: it keeps your project very compact! The hat fits nicely on a raspberry and they are well connected together. That makes it easier to place it in a box or the make a custom fit enclosure!
Now to the wiring!
- The button (momentary switch) is connected to GPIO pin 18
- The RGB-led is connected to pins 24, 25 and 27. Make sure you orientate the RGB pin correctly!
- the first pin of the led goes to GPIO pin 24. This is the pin for the colour Red
- the second pin (the longest one) goes to GND
- The third pin goes to GPIO pin 25. This is the pin for the colour Green
- The fourth pin goes to GPIO pin 27. This one is for Blue
This hasn't got much to do with wiring, but don't forget to put your microphone in an usb port!
Step 3: Make Some Changes to the Alexa Code
In order to have the RGB-led working and to have a blue status light, you have to make some changes to the code.
While your doing that, I also recommend the following change to cleanup the GPIO-ports after interrupting the program with CTRL-C.
Look for the file 'main.py' in the 'AlexaPi' folder
1. Around line 56, you should find the Alexa function:
Change this into
GPIO.output(27, GPIO.LOW) #blue light out
2. Around line 106, i'v added a line of code:
GPIO.output(27, GPIO.HIGH) #blue light on
3. Around line 111, after
GPIO.output(27, GPIO.HIGH) #blue light
4. Around line 116, after ifval != last:
GPIO.output(27, GPIO.LOW) #blue light out
5. For adding the GPIO cleanup, go to the end of the file.
after line 143: if __name__ == "__main__":
ad this try:
and finally, after the last line: start()
print " clean program exit."
But I recommend to use the file you can download here. It is very important that all the indentations in the code are correct. Otherwise you will get problems with your LED!
Step 4: Status LED
The status led is an RGB-led which has 4 colours defined:
- Blue: Alexa is ready to take your question
- Green: Alexa is listing to your question
- Orange: Alexa is thinking
- Red: Alexa is answering your question
Remember: You have to push and keep pushing the button throughout asking your question!!
Step 5: Auto-start and Designing Your Alexa
You can program your raspberry to start the Alexa program on boot.
There is an exellent tutorial of my fellow countryman Frederick Vandenbosch, who has written a script not only to make Alexa start at boot, but to also check if the service is running and if not, to start it up again!
You can give your Alexa whatever desing you want! Built it in a box, in a desk, in a closet,..... or make your own enclosure! Frederick used a nice arcade button and a cardboard box with a magnetic lid.
Check it out here! http://frederickvandenbosch.be/?p=1701
Step 6: Speak Up, Alexa!
As you noticed in the video, my Alexa isn't speaking very loud.....
The reason for that could be the use of an old speaker with a 3.5mm audio jack. In order to get my speaker working, I had to force the sound to go to the audio jack. You can do this by running the command:
Then, go to the advances options and choose audio. There you can select the audio jack.
It is possible to use an usb speaker. Frederick Vandenbosch has made his Alexa with a usb speaker. Check it out! http://frederickvandenbosch.be/?p=1701
So, I hope you like this 'tutorial' and have a go at it yourself!