Turn Your Pringles Can into an Amazon Echo with C.H.I.P.!

pringlesalexa

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_amazon_alexa_powered_by_chip

Parts

  • C.H.I.P.
  • 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)

Tools

  • Soldering iron, solder, and protective eyewear
  • Needle nose pliers
  • Tweezers
  • Hot glue gun and glue

Part 1: Alexa Setup

1. Create an Amazon Developer Account

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.


2. Add a New Device

voiceservice

Create a device using the dashboard wizard. Click on the Alexa tab, select Add Device and click on the Alexa Voice Service icon.


3. Name Your C.H.I.P.

dogeinfo

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.


4. Create a Security Profile

dogesec
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.


5. Configure the Security profile and Credentials

dogeauthsec

Select Web Settings and then click on the [edit] 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:
http://localhost:5000

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.
http://10.0.0.100:5000

In Return URL type:
http://localhost:5000/code
http://10.0.0.100:5000/code

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.


PART 2: C.H.I.P. Setup

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.

1. Install the Required Software

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


2. Clone the Git Repository

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


3. Install More Required Software

Change directories to AlexaCHIP.
cd AlexaCHIP

Run pip to install some more required software that is not available in the Debian repositories.
sudo pip install -r requirements.txt


4. Configure Device Security

creds

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.
nano creds.py


5. Authorization Token

authtoken
Run python 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.


5. Change the Button’s GPIO Number

412

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.
nano ~/AlexaCHIP/setup_gpio.sh

main412

You also need to edit main.py and change filename = ‘/sys/class/gpio/gpio409/value’ to read filename = ‘/sys/class/gpio/gpio412/value’.
nano ~/AlexaCHIP/main.py

Once you’ve made the edit, save and quit Nano.


6. ALSA Sound Configuration

alsa

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
sudo reboot


7. Modify main.py

Edit your main.py script based on jitto’s modifications to main.py.

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’)[1].


8. Install Python3

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.
sudo reboot


9. Run setup_gpio script by typing

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.
sudo setup_gpio.sh


10. Tweaking the Volume

alsa
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.
alsamixer

Note: Press the ESC key to quit the mixer.


11. Run the Client Software

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.


Part 3: Custom Microphone and Speaker Circuit

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.

Schematic

schematic

Bill of Materials

Qty Value Device Package Parts Description
1 LED5MM LED5MM LED1 LED
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 ALCO-1571294-3 ALCO-1571294-3 ALCO-1571294-3 U3
1 ELECTRET-MIC ELECTRET-MIC AOM-4454P-4 MIC1
1 PAM8403 PAM8403 PAM8403 U2
1 R100 R-US_R0805 R0805 R3 RESISTOR, American symbol
1 SPEAKER SPEAKER SPEAKER-CDS-25148-L100 U5

chipLogo64x64

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!

About the Author

Posted by

I'm busy writing and editing content at Next Thing Co.

Categories:

C.H.I.P., Project