A while back, Sam Machin built a $10 Amazon Echo using C.H.I.P.! To celebrate the occasion, we all sat around and ate some Pringles chips. Then it hit us! Sam’s project needed an enclosure, and that now empty Pringles can was perfect.
Wasting no time at all, we bundled up all the electronics, Dave got creative with building a nifty cardboard support structure, and we shoved everything inside. The result, Pringles Alexa! Here’s how to build one.
- Pringles can
- Scraps of cardboard
- 3.7V LiPo battery
- Pringles Alexa DIP (see the end of the write-up for the schematic and full BOM)
- Soldering iron, solder, and protective eyewear
- Needle nose pliers
- Hot glue gun and glue
You’ll need to create an Amazon developer account for this project. Pringles Alexa uses the Amazon Alexa services to interpret voice commands and retrieve answers. Use your laptop and create an account here.
TIP: About half the project steps use the dashboard, so you might want to bookmark it for convenience.
Create a device using the dashboard wizard. Click on the Alexa tab, select Add Device and click on the Alexa Voice Service icon.
Fill in the Device Type ID and Display Name, with the name of your C.H.I.P., then click the [Next] button.
Each field is case and space sensitive, so pick something you will remember, and that’s easy to type multiple times. We used sandcastle, but you can use whatever name you want.
Click on the drop-down menu Select Security Profile and select Create a new profile.
Fill out the Security Profile Name with the same name you used on the previous step for Device Name. Enter in whatever you want in the Security Profile Description, then click the [Next] button.
Select Web Settings and then click on the  button near the top right of the page. You need to add the IP address of your C.H.i.P. in the Allowed Origins and the Allowed Return URLs, so click on [Add Another].
In the Allowed Origins enter the following:
Add a second line to this section with your C.H.I.P.’s IP address. You’ll likely have to boot up your C.H.I.P., determine the IP address by typing ip addr show wlan0.
In Return URL type:
Note: Remember again to swap out the 10.0.0.100 for your C.H.I.P.’s IP address.
Save the settings, but keep your browser window open to the security configuration tab. You’ll need to set up some code on C.H.I.P. before you can fill out the Authorization Token field.
Note: That’s all the dashboard setup you need to do right now, but keep this page open. During the setup on C.H.I.P., you’ll need to enter in the long ID and secret strings from the webpage into a C.H.I.P. config file.
This project was created on a C.H.I.P. running the 4.3 GUI image. Our newer, 4.4 image implements some changes that are not compatible with this code. As such, you’ll need to flash your C.H.I.P. with the 4.3 GUI. For more information on the differences between 4.3 and 4.4, please see the online C.H.I.P. docs.
From the Terminal program, update C.H.I.P.’s list of packages by typing the following command, then press enter.
sudo apt update
Install the prerequisite software:
sudo apt install git libasound2-dev memcached python-pip python-alsaaudio mpg321
Sam Machin created this project and hosts his code on Github. To get a copy of his code, you’ll need to use git to clone his repository.
git clone https://github.com/sammachin/AlexaCHIP
Change directories to AlexaCHIP.
Run pip to install some more required software that is not available in the Debian repositories.
sudo pip install -r requirements.txt
Refer to the Amazon Developer Dashboard page from Step 4 of the previous section and select Security Profile, then General. This will display all of the fields necessary for your C.H.I.P.’s credentials, except for one. Input all the fields available into your creds.py file.
mv example_creds.py creds.py
Then open then file for editing and copy in the strings.
python ./auth_web.py, which starts a webserver on C.H.I.P. used to finalize the security credentials with Amazon.
On your laptop, use a web browser to visit C.H.I.P.’s IP address at port 5000. For example, I directed my web browser to 10.0.0.100:5000. Then enter in your Amazon username and password for your AWS account and
Note: You can determine your IP add by typing ip addr show wlan0 from the command line.
Open setup_gpio.sh with Nano and replace the number 409 with 412. When Sam wrote this project, he chose to use C.H.I.P.’s 409, but the version we built uses 412.
You also need to edit main.py and change filename = ‘/sys/class/gpio/gpio409/value’ to read filename = ‘/sys/class/gpio/gpio412/value’.
Once you’ve made the edit, save and quit Nano.
Use Nano to open the ALSA configuration file at /usr/share/alsa/alsa.conf. Find the line that says, pcm.front cards.pcm.front and change it to read pcm.front cards.pcm.default. Save your work, exit Nano, and reboot your C.H.I.P..
sudo nano /usr/share/alsa/alsa.conf
Edit your main.py script based on jitto’s modifications to main.py.
- with open('recording.wav') as inf:
+ with open('recording.wav', 'rb') as inf:
- data = r.content.split(boundary)
+ data = r.content.split(boundary.encode('utf-8'))
- audio = d.split('\r\n\r\n').rstrip('--')
+ audio = d.split(b'\r\n\r\n')
Note: It’s really easy to incorrectly edit this line! Not only do you need to remove .rstrip(‘–‘), but you also need to add the letter b to d.split(b’\r\n\r\n’).
- with open('recording.wav', 'w') as rf:
+ with open('recording.wav', 'wb') as rf:
- audio = ""
+ audio = b""
Install Python 3 to take advantage of the code changes jitto implemented.
sudo apt install python3-pip
Use pip3, the Python package manager, to install a few required libraries.
sudo pip3 install python3-memcached pyalsaaudio
Reboot your system.
Run setup_gpio.sh as root to configure the button’s GPIO pin. You’ll need to run this script each time you start PringlesAlexa.
You may need to play around with the volume output of C.H.I.P.’s mixer to obtain clear playback. There are a few ways to do this, but the easiest is to type the following amixer command in at the command prompt.
amixer set ‘Power Amplifier’ 55%
A second option — and one that’s more visual — is to run alsamixer, which is a ncurses based front-end for controlling the onboard mixer.
Note: Press the ESC key to quit the mixer.
To start the Pringles Alexa, simply run the command below.
sudo python3 main.py
After a moment you’ll hear a voice say, “Hello!” At this point, the system is ready to rock. Simply hold down the button and start your question off by saying, “Alexa” and pose your question.
We built a custom DIP that integrates the microphone, amp, speaker, and button into a single board that fits snugly inside a Pringles tube. You’ll find the schematic and bill of materials below. But if you’re looking for a less DIY option, you can use a USB sound card with audio in and out. You’ll still need to wire a button to GPIO 412.
|1||.47uF||C-USC0805||C0805||C9||CAPACITOR, American symbol|
|1||0.1uF||C-USC0805||C0805||C10||CAPACITOR, American symbol|
|1||100nF||C-USC0805||C0805||C3||CAPACITOR, American symbol|
|2||1uF||C-USC0805||C0805||C6, C8||CAPACITOR, American symbol|
|1||2K||R-US_R0805||R0805||R2||RESISTOR, American symbol|
|1||2X20-CHIP-HEADERS2X20-PTH-CHIP||2X20-CHIP-HEADERS||2X20CHIP-TH||J1||Through hole layout with chip reference|
|1||3300pF||C-USC0805||C0805||C4||CAPACITOR, American symbol|
|1||4.3K||R-US_R0805||R0805||R1||RESISTOR, American symbol|
|3||4.7uF||C-USC0805||C0805||C1, C2, C5||CAPACITOR, American symbol|
|1||470uF||C-USC0805||C0805||C7||CAPACITOR, American symbol|
|1||R100||R-US_R0805||R0805||R3||RESISTOR, American symbol|
Whether you’re ordering socks or checking the weather, make sure to share how you’re using Pringles Alexa. Leave a comment below, Tweet a photo, or describe your full build on the forums. We can’t wait to hear from you!