January 27, 2019

How To Hack Alexa (Echo Dot) into Big Mouth Billy Bass

Alexa is fun and all, but combining her with animatronics such as the Big Mouth Billy Bass creates a much larger and weirder personality! In this post I'll walk you through how to make an Alexa device out of a Billy Bass toy. This isn't an original idea (kudos to Brian Kane for coming up with this project), but I've tried to make the steps as simple as possible.



Do It Yourself 

Tools: Soldering Iron, Hot Glue Gun, Torx Screwdriver, Philips Screwdriver

Materials:

Billy Bass in the Toronto Tool Library surgery room.
  1. Big Mouth Billy Bass*
  2. Echo Dot 2nd Generation
  3. Arduino Uno
  4. Arduino Motor Driver Shield
  5. LM386 Amplifier 
  6. 3.5mm Audio Cable  
  7. At least 4x C Cell Batteries 
*This Billy Bass seems closest to mine, any should work but some may contain only two motors 
  

Billy Bass Tear-down 

 

1. Billy bass should have some pretty obvious screws on the back. Trust your instincts and simply unscrew those (saving the screws), and pull the back off the fish. This should open up to reveal motors on the fish side, and a battery pack on the back plate.

Internals of Billy Bass. The white square contains all the motors with the 3 sets of motor wires coming out. The battery pack which we use as a power source can be seen on the back plate.

2. You will see a PCB inside with all the wires attached. Track the wires coming from the motors, and cut them free from the Billy PCB board leaving yourself as much wire as you can (there should be plenty). Tape or mark these wires. Identify the wires coming from the battery, and cut those free from the PCB as well. These will be used later to provide power to your Arduino through the Motor Shield.


Billy Bass PCB with some of the wires cut. You can cut this piece completely free, but I hadn't committed to that when I took this photo. 

3. (Optional) Identify the switch used to toggle the motion sensor for the fish on and off. Cut its wires and solder the positive lead from the battery terminal to pass through this switch instead, allowing it to be used for turning on and off Billy's power to the motors. This is for convenience and not strictly necessary.

The positive wire coming off the power source being connected to the back switch. The switch now turns the motors on and off by enabling and disabling the power.

4. Attach your motor shield to your Arduino, and connect the positive and negatives wires from the motors to the first three motor ports on the motor shield (labelled M1, M2, M3). Connect the positive and negative leads from Billy's battery pack to the terminals labelled EXT_PWR.

Motor shield with 3 motor wires attached - two at the bottom, one at the top, along with power from the battery pack on the right hand side with the black and red wires. The white wire is connected to the audio amplifier described in the next section.

Controlling the Motors

 

With all the wires attached, now you can upload your first sketch to the Arduino and confirm the motors are working as expected. You will first need to install the Adafruit Motor Library for controlling your motor shield by following the instructions on their site. Once that is done, you can upload this Motor Diagnostic sketch to your Arduino which should drive M1, M2, and M3 in sequence.

You should remain on this step until you are able to control the head, mouth, and tail by the motors of the same name in the Arduino sketch. This will be needed when we add more sophisticated actions.

If this is not working, you may have to assign the head, mouth, and tail variables in the sketch to a different motor number based on how you connected them. Additionally if the mouth, tail, or head seem to move the wrong direction, you can reverse the two wires attached to the motor shield.

 

Echo Dot Tear-down and Audio Detection  

 

1. Peel the rubber off the bottom of your Echo Dot (2nd Generation), which will reveal a clear adhesive layer which you can also peel off. This will reveal four torx screws. Unscrew and remove these four screws, and your dot should come apart into multiple pieces.

We are interested in the two circuit boards. Be careful with the ribbon cable connecting the two PCBs. This came unplugged for me about 20 times, so you may want to attach this to the fish case immediately (see photos near the end of this post for how I attached mine).

Echo Dot disassembled. The green PCBs connected by the ribbon cable are all we need. You can re-assemble the empty Dot case and gift it to a friend.

2. Cut your 3.5mm audio cable very close to the jack. Peel away the rubber to reveal the contacts at the base of jack. This will contain a left, right, and ground cable (in the form of many small loose wires). Solder a length of wire to both L and R (converting the signal to mono), and twist the loose wires together to form a ground wire. For more info on the audio jack, checkout this very helpful postAt this stage you can test that the audio output still works using a portable speaker.

Arduino connected to the audio output of the Echo using the stripped 3.5mm audio cable. The red wire carries the signal


3. Connect the signal wire (L and R mono) to the IN pin on the LM386 amplifier board, and connect the ground pin to the audio signal ground. Run wires from the Arduino 5V output / GND to the amplifier's VCC and 2nd GND pin (can also use Billy Bass battery pack for VCC and GND). Now attach the wires from Billy Bass' speaker to the amplifier.

At this point you should be able to plug the 3.5mm audio jack into the Echo Dot, and hear Alexa through the speaker. If you can not hear music, try turning the small screw (potentiometer) on the amplifier to increase the gain. This will introduce noise however, so try to keep the gain as low as possible.

Arduino and Echo Dot connected to the LM386 amplifier board and internal Billy Bass Speaker. Note the white signal cable from the amplifier speaker wire terminal running to the Analog input on the Arduino.

4. With the 4 pins on the amplifier oriented at the bottom, you'll have the two speaker wire terminals at the "top". Attach an additional wire to the top left speaker terminal, and connect this to Analog pin 0 on your Arduino. For testing purposes this can be done without the motor shield attached. Once it is working however, you will have to solder this to the motor shield connection marked A0 (actually, I accidentally used A1 - any analog pin will suffice)

Audio Diagnostic Arduino Sketch

 

If you have followed the above steps correctly, there are two tests to confirm you are on the right track. You should make sure these two checks are working before proceeding to the next step!

1. When you play music from your Echo ("Alexa, play Slayer"), you actually hear something.

If this is not working, check the power going into the amplifier is setup correctly, and check your wires from the 3.5mm audio are properly connected.

2. When you load this audio diagnostic sketch to your Arduino and open the Serial Monitor (9600 baud), you can see a log message indicating if music is playing or not. You can also watch the onboard LED for the Arduino which should be illuminated when music is playing, and off otherwise.

If step 2 isn't working, try connecting your analog wire to the other terminal on the speaker ports coming from the amplifier. You may also need to adjust the "quietThreshold" value in the sketch to correctly calibrate for no sound playing, though in the next step we will average this value to make it more stable.

Putting it all Together

 

After independently determining we can make all the motors move, and that we can play music and measure from the Arduino when music is playing, we just need to combine the components.

This is done simply by connecting the amplifier signal to the A0 port on the motor shield, and plugging in all the motors. Pushing this sketch combining the audio signal reading with some more advanced motor movements to your Arduino should now trigger fish animations anytime music is playing.

Plug your echo into a power supply and connect it to the 3.5mm audio cable, and you should see your fish take on the personality of Alexa! We're in the home stretch now.

All the components connected and working, but not yet re-assembled into a coherent fish.

Now all that's left is attaching the electronic components inside Billy's case and closing it back up. I used the plastic spacer tabs on Billy Bass to hold the Dot in place by gluing the lower PCB to the case, and attaching a screw through the top PCB to one of existing screw risers for the case which I cut in half. The amplifier was glued to the backing plate (as far from the speaker as possible, as there is a crackling noise when they are close together), and the Arduino was hot glued in the remaining space. Keep in mind you may want to take this apart again, so use either long or detachable wire connections. 


On the top you can see the front plate. I used the plastic risers on Billy's case to hot glue the lower PCB, and then screw the other half right above. On the bottom you can see the amplifier which was simply glued to the back plate. I later ended up moving it to the left side so it did not pickup interference from the speaker being driven.

Drilling holes so Alexa can hear with the case closed.
Finally, you will probably want to drill some holes in Billy's plastic so audio can travel more easily to the the Echo Dot's microphone. I also cut a hole in the side of Billy's case so I could run two USB cables out of the body. One for programming the Arduino if I wanted to keep tinkering, and the other for powering the Echo Dot (using a portable USB battery pack). I think if you wired a USB cable to the battery pack on billy you could also power the Echo dot directly from that, but my one attempt was unsuccessful. I will update this page if I manage to get that done.


Conclusions

 

So here is one more blog post about how to make Billy Bass into a Smart Fish. By using the Echo Dot instead of a Raspberry Pi you get all the first party Alexa capabilities like Drop-In calling. That being said, you can't be quite as intelligent about what kind of sounds Billy is making. It might be fun to revisit this with Alexa in a Raspberry Pi so I could write some different animations when voice is detected, or even add another layer of audio processing so it sounds like the fish is under water. But I'll have to leave that for a rainy day.

Hope you enjoyed the write up, and good luck hacking! As always I will try to provide technical support in the comments, so please let me know if you have any trouble following.


11 comments:

  1. Your sketch is somehow broken.

    ReplyDelete
    Replies
    1. Is it? I thought I copy pasted verbatim from what I was running... Can you share your error message?

      Delete
    2. Note there is a header AND an ino file, you will need both

      Delete
    3. Both files have same content. Something went wrong.

      Delete
    4. Good point, bad copy paste. Travelling currently but I'll fix within a few days (or sooner)

      Delete
  2. https://developer.amazon.com/alexa/alexa-gadgets

    See bottom of the page for link to the current gen BMBB product available with Alexa support built-in.

    ReplyDelete
  3. Hey Alan, yes there is a pre-built bluetooth Billy you can buy that makes a cool toy. This post is for those who subscribe the the whole "it's about the journey not the destination" mantra when it comes to animatronic toys endowed with a smart assistant.

    ReplyDelete
  4. Hello I have was wondering if I could do the same with any other animatronic device, like this for example
    https://hasbropulse.com/products/marvel-legends-deadpool-s-premium-interactive-head

    ReplyDelete
  5. Will this work with the newest echo dot?

    ReplyDelete
  6. Hey man, following this guide and it's great but i'm at the bit of the LM386 amplifier and some of the photos in particular are difficult to follow. Just wondering if you've got any others you could share in terms of showing which wires are connected to what.

    ReplyDelete
  7. is anybody else seeing the motors move without battery power? Im at the "testing motors" stage and when i removed the batteries it kept moving! im guessing powered from the arduino USB power?

    ReplyDelete