An Echo Device Using the C.H.I.P. $9 Computer





Introduction: An Echo Device Using the C.H.I.P. $9 Computer

These are instructions for building a box enclosure from a set of old USB speakers that will implement an Amazon Alexa Echo device using the C.H.I.P. $9 computer from Next Thing Co. (

So what's an "Echo" device? An Amazon Echo is a wireless voice command product sold by An Echo device can be a device built by you that uses Amazon's Alexa service. The device would be capable of voice interaction, and providing news, weather, and other real time information. Using the service your device would be limited compared to Amazon's product.

Limited by the software you create to interface with the service and also limited by the licensing restrictions set by Amazon to use the service. For example this type of device does not support setting a timer, or playing music like the Amazon Echo product. Another license restriction is not allowing the use of keyword detection. This means that your device would need a button to submit a question for example. The Amazon Echo product costs $179.99 and the Amazon Dot, a similar product, costs $89.99 at

NOTE: this DIY device can also be developed using a Raspberry Pi as well but is not the focus of these instructions. For more info on how to do this with a Raspberry Pi see:,

I am a big fan of C.H.I.P. because it packs a lot of functionality in a small footprint, and since I just got mine in February I decided to use it on this project. I have also developed a home control application on Raspberry Pi using an iPhone, so the Raspberry Pi is a very similar platform.

Anyway..... I was tinkering around and got this working from Sam Machin’s “The $10 Echo” site ( I got it working with a USB thumb microphone and I had a set of old USB speakers lying around that I could not get rid of, so I decided to use them to create a box to contain “Alexa”.

I like reusing old equipment and gutting things like this rather than creating a new enclosure. My "Making" and handcrafting skills are not the best... In these instructions I will not go into too much detail on the specifics of the hardware modifications to the speakers I used, since you may choose to use other speakers or a completely different enclosure. I will just document my steps as an example and hopefully that will motivate you to create an even better enclosure and/or device. I will provide the configuration information, adding to Sam Machin's efforts, and recommendations from those on the C.H.I.P. forum site that were helpful to me.

Difficulty: Easy to medium software build, and medium hardware build effort with some soldering and disassembly & assembly

Limitations / Options / Alternative Approaches:

  • Amazon does not support using their service with keyword detection: This means implementing it on your own device with keyword detection is against Amazon’s service agreement. Therefore a push button is used to send commands and invoke the Alexa service. (Turns out I like this approach better anyway).
  • Microphone: I used the USB thumb mic because it was the simplest for me. Its low power and self contained requiring no amplification circuit or wiring or other additions.
  • Enclosure: I used the chosen USB speakers because I had them lying around, no extra costs for me. But also because they have built in audio amplification, power and volume adjust that I did not have to come up with. Alternatives: a more fancy box, your own amplification or fixed volume control or other enhancements.
  • Board modifications for C.H.I.P. not required: In the original article, Sam used a USB audio and mic combination device that also required him to cut a trace on the back of the C.H.I.P. board to enable audio input through the TRRS 3.5mm jack. I preferred not to do this and therefore, for my prototype, I used the TRRS 3.5mm jack for output only and a USB mic numb for voice input. For details on board modifications see README.MD on Sam’s github: I wanted to be able to re-use my C.H.I.P. at a later time and did not want to modify it. NOTE: later on you will see that for my final build I used the C.H.I.P. header connections U14 pins 4,6 & 8 for audio out rather than the TRRS jack because of space constraints in the enclosure.
  • Python code: ...and of course further optimization of the code and my steps for implementing the code could be developed and I welcome any comments.

Potential issues: software latency and wireless communications issues with the Alexa services and finding the right enclosure can be issues for you. There are frequent errors that can occur from communications with the Amazon service for multiple reasons. I tried to compensate for it by adding error checking that forces a restart of the code but they did not resolve these much. I am sure there may be further software optimization that can be done to improve on these issues. I think these happened when I got too impatient with it and was looking for faster responses... It can take 3 seconds or more for a response to a question. Be patient. Your mileage may vary on the 3 seconds depending on how fast your wireless & internet connections are.

NOTE: I suggest that you prototype (Steps 1 through Step 5) before investing a lot of time on a making or modifying a final enclosure, to better understand these issues and reconcile them with your expectations.

Materials list:

  • C.H.I.P $9 computer from Next Thing Co. @ ($9 + shipping = $15.47. They are not readily available as of this writing. You can preorder on the website for June 2016 delivery. )
  • Old set of USB speakers that will provide room for mounting C.H.I.P. and wiring, (~$10 or so on ebay)
  • USB Thumb Microphone: @Amazon: (~$2.55)
  • Momentary SPST Push Button Switch: @Amazon: (~$2.34)

Step 1: Setup & Pre-configure C.H.I.P.:

NOTE: depending on your C.H.I.P. build and any work you may have already done on it, there may be items on the list below, that you DO NOT need to include. For example: if you have already installed one of the software components such as "git".

    For an Initial setup of C.H.I.P.: See a great post on “Setting up C.H.I.P. as a headless server with minimal tools”: Once that is done...

    I suggest you always upgrade C.H.I.P. as the first step:

    sudo apt-get update

    Install git:

    sudo apt-get install git

    Install some other software...:

    sudo apt-get install libasound2-dev memcached python-pip
    sudo apt-get install mpg321

    Get Sam's python code and set it up:

    sudo git clone

    cd AlexaCHIP

    sudo pip install -r requirements.txt

    And in case these are not installed yet:

    apt-get install --upgrade python
    apt-get install python-alsaaudio
    apt-get install python-pyalsa

    Step 2: Setup Alexa Service

    Use the following video: "Installing Alexa Voice Service to Raspberry Pi" ( to setup the Amazon Alexa device service. This setup allows you to use the Amazon Alexa service on the device and provides you a device ID, security codes and permission via your Amazon account to use the service on your device.

    This step involves going to "" per the video above to setup the service. I would recommend reviewing the whole video but the interesting parts to setup the service starts at 3:37 minutes where the actual service is setup.

    You will end up with

    • a Product ID, mine was: "EchoCHIP" - you can name it whatever you like,
    • a Security Profile Description "Echo CHIP" - I kept it short but you can give a longer description,
    • a Client ID (long id string provided by Amazon) ,
    • a Client Secret (long string provided by Amazon).

    A "refresh token" will be need to be retrieved in our next step to complete the Alexa Service config.

    Copy and maintain a record of all these items (although you can always also go back to the Amazon site to get these).

    Step 3: Update C.H.I.P. With Alexa & Python3 Settings:

    Using the “The $10 Echo” setup from and the file from his github files at: do the following steps:

      Create the Alexa service credentials file and authorization files:

      1. Make a copy of to work with:

      Edit the to add the Alexa service device ID, security codes,etc and use your previous recorded details for the file:


      Run the authorization request from the device :

       sudo python ./   

      On your computer go to your web browser using your C.H.I.P. local ip address: http://192.168.###.###:5000 and then you can get the refresh token from Amazon to add to Copy this very long token into the

      Edit the file and now add the "refresh token" you got from the Amazon site on your browser. This authenticates your device with your Amazon account:


      Ready to Test

      Install a momentary push button switch across: GPIO1 and GND (pins 14 and 1 on U14). See C.H.I.P. connector pinouts: NOTE: I suggest doing this for test and prototyping purposes now without final mounting it yet.

      At the C.H.I.P. :

      sudo apt-get install python3-pip     
      sudo pip3 install python3-memcached
      sudo pip3 install pyalsaaudio

      For the USB microphone setup: edit your /usr/share/alsa/alsa.conf file so that "pcm.front cards.pcm.front" is renamed "pcm.front cards.pcm.default" (for correct audio device selection and identification)

      nano /usr/share/alsa/alsa.conf

      For USB microphone setup: edit /etc/asound.conf and add the following code. This initializes the microphone and audio settings:

      pcm.usb {
          format S16_LE
          rate 44100
          type hw
          card 1
          device 0
      pcm.!default {
          type asym
          playback.pcm {
            type plug
            slave.pcm "hw:0,0"
          capture.pcm {
             type plug
             slave.pcm "usb"

      "reboot your C.H.I.P."

      sudo reboot

      At this point in this process, I wanted to verify and test the use of the USB mic and the audio output before running the Python code. With the microphone installed and a speaker plugged in I manually tested this by using...

      arecord -D plughw:1,0 -f cd test.wav record some audio and...

      aplay test.wav play that recording. This allowed me to make sure before running the Python code that input and record of audio with my chosen microphone and audio output were working. You may need to use "amixer" and/or "alsamixer" commands at the command lines to adjust mic and audio output settings. See the links below for more information.

      Here are some references to getting audio and recording working. Some of these are Raspberry Pi articles and some are general Linux articles but they provide some guidance on audio architectures:

      1. Raspberry Pi microphone setup with USB sound card | Linux Circle:

      2. Using a USB Audio Device With a Raspberry Pi - Envato Tuts+ Computer Skills Article:
      1. Advanced Linux Sound Architecture - ArchWiki:

      Step 4: Update to New Python Code & Try It Out

      IMPORTANT Update: replace the "" in the AlexaCHIP folder with the following update from github: (Thanks to Justine Thomas). This update contains updates to the code to support the use of the USB Thumb Microphone. It uses "mplayer" to code to convert recordings to be compatible with the Alexa service. Unfortunately this adds some delay to the communication with the service. (A possible opportunity for optimization in the future).

      Let's now test the code. First let's enable the GPIO pins by running the setup script to enable pushbutton switch::

      sudo ./setup

      At this point you should be able to test your configuration to communicate with the Alexa service. Run the python code:

      sudo python3

      Alexa should respond after a few seconds by saying "Hello". At this point you are ready to ask your first question:

      Press the pushbutton switch and keep it pressed while asking your question. For example:

      "Alexa, who are you?"

      After at least 3 seconds Alexa will then respond with a short explanation of who she is. Other related questions you can ask are:

      "When is your birthday?" or "Who made you?" or "Where were you born"

      Alexa will respond to each of these differently. Notice you did not need to use the name "Alexa" in front of these questions while hold down the pushbutton switch. This is because the switch replaces the "keyword detection" mechanism mentioned previously.

      Here are some other questions you can test:

        What time is it? or What day is it? 
        What is the weather? or What's new? or Who is JJ Watt? 

        If you setup Alexa with location settings it can respond with weather from your location. To do this you can setup the Alexa service settings using an iPhone app (Alexa app) or an Android app (Alexa app) or at this address: Here you can customize Alexa (i.e. setup your zip code & location etc).

        Now, it's just a matter of putting it all together in the hardware. But first let's button up the software automation a bit before that....

        Step 5: Automate the Software & Bootup

        In order to get the python code to run automatically you will need to set it up to run at bootup. I used a script in /etc/init.d to accomplish this.

        The following script allows you to stop, start and restart the Alexa service python application. See the script contents for the syntax for doing this.

        NOTE: using this script the Python code will start automatically when you apply power to the box and Alexa will be accessible without having to start it in any other way.

        Below is the code that should be copied to /etc/init.d as /etc/init.d/,

        ### BEGIN INIT INFO
        # Provides:          alexa-service
        # Required-Start:    $remote_fs $syslog
        # Required-Stop:     $remote_fs $syslog
        # Default-Start:     2 3 4 5
        # Default-Stop:      0 1 6
        # Short-Description: Simple script to start a Alexa Service program at boot
        # Description:       A simple script which will start / stop a program a boot / shutdown.
        ### END INIT INFO
        start() {
            echo "Starting service..."
            cd $workdir
        stop() {
            pid=`ps -ef | grep '[p]ython3' | awk '{ print $2 }'`
            echo $pid
            kill $pid
            sleep 2
            echo "Server killed."
        case "$1" in
            echo "Usage: /etc/init.d/alexa-service {start|stop|restart}"
            exit 1
        exit 0 

        After you copy the above script to /etc/init.d as /etc/init.d/, do the following:

          Make the script executable:

          sudo chmod 755/etc/init.d/

          Register script to be run at start-up:

          sudo update-rc.d defaults

          If you ever want to remove the script from start-up, run the following command: "sudo update-rc.d -f remove"

          The setup script: "" script, used and refrerenced in the above startup script, is what I used to keep the python code running continuously. I first created it to invoke the "python3" command to troubleshoot the code. It helped me manage what I wanted to execute and do some troubleshooting. When I did not use it, there were too many times where there were errors that halted the code with no response from Alexa, even though it would be working correctly when it did respond. These errors tended to be communications or software latency issues I suspect, so the "" script allowed me to keep it running. THis is not the best solution but it works, and keeps the service running for me. It just re-executes the code again if there was an error.

          Below is the contents of the "" script:

          PROGNAME='sudo python3'
          cd /home/chip/AlexaCHIP
          # Run the code until CTRL-C 
          while [ $? -ne 130 ]; do
              sleep 5
          exit $?

          Step 6: Modifying the Hardware

          Disassembly of the speaker box and modifications depend on the speaker or enclosure you decide to use. I used a set of HP Multimedia Speakers, Model no. UC236. These are USB powered speakers with a standard audio plug for audio input. For my purposes I eliminated the second speaker and kept the control speaker that had power, volume and tone controls. I also removed the audio plug since I intended on using it internally.

          The speaker board used in the control speaker has a power circuit to turn power to the speakers on/off and also has volume & tone controls.

          The control speaker PCB board had solder pads (connections for the audio plug which I removed). These I used to for input from the C.H.I.P. board so that you can hear Alexa's response.

          The control speaker enclosure also had to be modified to mount a pushbutton switch for activation of the Alexa service.

          Concerns: while the C.H.I.P computer does not usually get hot I realized after completing this that the control speaker enclosure does NOT have vents or ventilation of any kind. Before running it for too long I intend on making some vent holes in the enclosure to ensure it has some ventilation for the C.H.I.P.

          Step 7: Wiring the Power to the C.H.I.P. and the Speaker Board

          I did not want to take the chance of damaging my C.H.I.P. with power from the speaker PCB since I did not have a schematic and was not sure that switching the speaker board on / off would spike the C.H.I.P input.

          I also was not sure it drove enough current to power the C.H.I.P. So I wired power for the C.H.I.P. directly from the USB input power connection.

          So I have to live with the fact that as soon as I plug in the USB power connector the C.H.I.P would power on rather than using the control speaker power switch.

          The board has PCB pads for USB power input which I used to wire to the the C.H.I.P. board power pins on U13 header pins 1 (GND) & 3 (VCC-5V). These connections are not switched on by control speaker and therefore not susceptible to electrical noise from the power switch. Also, not having a schematic or knowing too much about this board I could not count on it providing enough power for the C.H.I.P.

          At later time I will look at this and see how I can improve on this.

          Step 8: Wiring the Audio Connections From the Speaker Board to the C.H.I.P.

          The speaker board had connections for audio input (from the audio plug I removed) and therefore I used these inputs to wire output audio from the C.H.I.P. You may ask why I did not use the TRRS 3.5mm jack. Using the jack would take up too much space and not allowed me to fit the C.H.I.P. board in the speaker enclosure.

          The USB Thumb Microphone: I used a USB Thumb Microphone (see Amazon: This provided a better solution for me since it is low power, and does not require any amplification or other wiring. I also wanted to be able to re-use it, like the C.H.I.P. board, in case one day I wanted to disassemble this project and reuse the materials.

          Therefore I decided to cut a hole in the speaker box with my Dremel tool for the USB mic (see picture below). This allowed me to take it out and put it back in, in case I needed to use it with my Raspberry Pi units or other uses. Cutting this hole also worked out well since it allowed for more room in the speaker enclosure.

          Step 9: Wiring the Momentary Pushbutton Switch

          As mentioned above the pushbutton switch is used to initiate Alexa service and ask it questions. I mounted a large red switch (see Amazon: to the front panel and wired one side of the switch to U14 header connector pin 1 (GND) and the other to U14 header connector pin 14 (XIO-P1).

          Mounting the switch required me to drill out a hole for it with my Dremel tool to the front of the control speaker.

          Step 10: Mounting the C.H.I.P. Board Inside the Speaker Enclosure

          I wanted to be able to possibly reuse the C.H.I.P. board again. They are not readily available as of this writing. But you can preorder on the website for June 2016 delivery so I am waiting for my 2nd one.

          So I may reuse this one until I get another one. Therefore I decide to use velcro (handy man secret weapon #3, besides duck tape #1 and WD-40 #2). So I applied velcro to the back of the C.H.I.P. board and to the top of the inside of the speaker enclosure.

          NOTE: this is an important point, I had enough clearance for the board to fit behind the speaker and toward the top of the enclosure. I got lucky, since it can be hard to find room in most speaker boxes.

          I also plugged in the USB thumb mic.

          Step 11: Test and Reassemble the Whole Thing

          I then tested the unit with power without closing up the speakers to make sure everything was working correctly. Afterwards I closed it up and tested it again.

          As I mentioned above, while the C.H.I.P computer does not usually get hot I realized after completing this that the control speaker enclosure does NOT have vents or ventilation of any kind. Before running it for too long I intend on making some vent holes in the enclosure to ensure it has some ventilation for the C.H.I.P.

          Code Sources & Information References

          • Video on Alexa service setup: Use the following video on Installing Alexa Voice Service to Raspberry Pi and it is the same for C.H.I.P.:
          • Below are some questions you can try with the device:
          • Alexa, What time is it?
          • What day is it?
          • What's the weather? (make sure and set your location in Alexa app or @ )
          • What's new?
          • What is 2 + 2?
          • How many days until September 1?
          • What are some movies playing nearby?
          • What movie won best picture in 1991?
          • Who are you?
          • Where do you live?
          • Who made you?
          • When is your birthday?
          • Where were you born?
          • How many cups are in a quart?
          • How many tablespoons are in a stick of butter?
          • Do aliens exist?
          • What is the answer to life, the universe, and everything?
          • What are you going to do today?
          • Tell me a joke.
          • Meow
          • Do you know Siri?
          • Can you rap?
          • Can you beatbox?
          • Who is the real slim shady?
          • Beam me up
          • Close the Pod Bay Doors
          • Tea. Earl Grey. Hot
          • What are the Laws of Robotics
          • What are the rules of fight club?
          • Do you have Prince Albert in a can?
          • Surely you can't be serious
          • Who's on first
          • To be or not to be...
          • Who is the fairest of them all? (ask this one twice)
          • What came first, the chicken or the egg?
          • How much wood would a wood chuck chuck if a wood chuck could chuck wood?\
          • How many licks does it take to get to the center of a tootsie pop?
          • Who loves ya baby?
          • What is love?.
          • How much is that doggie in the window?

          • Who let the dogs out?
          • Play a song. - NOT SUPPORTED FOR THIS DEVICE
          • Set a timer for 10 minutes. - NOT SUPPORTED FOR THIS DEVICE

          Although there are some differences & limitations to this device compared to the Amazon products, this link may be helpful also:

          I hope that making this will be as much fun for you as it has been for me. I take very little credit for originating any of this code or process. I take credit for compiling it all and for being too verbose here.... :-)

          Now go find a great way to build your own.

          2 People Made This Project!


          • Pocket-Sized Contest

            Pocket-Sized Contest
          • Pro Tips Challenge

            Pro Tips Challenge
          • Paper Contest 2018

            Paper Contest 2018

          We have a be nice policy.
          Please be positive and constructive.




          I made the listed changes for 4.4 (gpio1017) and my recording test worked fine.

          I run and get the "Hello"

          That's about it though. I see these errors when I run

          ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sun4i-codec.pcm.front.0:CARD=0'

          ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

          ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory

          Not sure where to go from here. Thanks for the great project though. I know I'll get it working at some point

          Nice project,May i customize the questions and Alexa's answers?

          I did and it works but my Chip (4.4) uses systemd and not init.d

          Can anyone help me to start it on boot using systemd?


          I'm sort of stuck in that I don't think my gpio pins are activating anything.

          Running kernel 4.4. Gpiochip1016 is what's in my directory (versus 408 or 409 in the documentaton).

          I've modified the python code for this gpio1016 directory.

          I have the USB mic running. I can make a test recording and play it back.
          I run the using python3 and I get a "hello"

          I've activated the gpio script and I get returned the following...

          But pressing the push button, or even shorting out the leads from pin 1 and pin 14 on U14 does nothing....

          It sort of stops after Hello.

          Well, I installed Kernel 4.3 and went through everything again and it works. Something about GPIO director of 1016 versus 409 that's preventing this from working in kernel 4.4.

          Hi: I made mine work on 4.4 kernel. The pin base is differnet on both kernels, on 4.3 it starts at 408 and on 4.4 it starts at 1016 for the zero pin. Since in this example we are using the pin #1 then you need to change the to echo 1017 and the paths to point to the directory gpio1017. Also you need to change the, find the line of code that's looking for the gpio path and change the 408 reference to 1017 as well. Make sure you run it with the python3 command. Hope this helps.


          Yeah, I have not tried 4.4 yet. I repurposed my CHIP (only have one... waiting on another) and have been using it for something else. Still on 4.3. I remember seeing something about GPIO and 4.4 on Sam Machin's GITHUB and/or on CHIP community pages, you may want to check there.

          Hi! First off, great project!

          I was wondering if there was any chance we could modify the code to take the input from a headphone, and also output Alexa's response through the headphone. I've ordered the USB Mic but it's gonna be a while before it gets to me, and don't want to wait till then to get this to work

          Hi! First off, great project!

          I was wondering if there was any chance we could modify the code to take the input from a headphone, and also output Alexa's response through the headphone. I've ordered the USB Mic but it's gonna be a while before it gets to me, and don't want to wait till then to get this to work

          Hi! First off, great project!

          I was wondering if there was any chance we could modify the code to take the input from a headphone, and also output Alexa's response through the headphone. I've ordered the USB Mic but it's gonna be a while before it gets to me, and don't want to wait till then to get this to work