Sunday, December 13, 2015

Internet-Connected Speakers

Finished product

When I watch TV, I find certain commercials to be very annoying. Usually I try to mute them myself before the rage sets in. Unfortunately I can't always find the remote, and sometimes I forget to un-mute the TV and I'll miss actual programming.

Jeep commercials are particularly bad for me

Ideally, I could train a system to pick up on sounds from certain commercials and mute them automatically. I think this is too large of a scope for me and I would lose interest. The next best thing is to have an Alexa skill to control my TV. (If you're not familiar with Alexa skills, they are essentially apps you can install on your Amazon Echo.) "Alexa, mute this commercial," might mute the speakers for exactly 30 seconds, solving both the can't-find-the-remote problem and the accidentally-muted-real-programming problem. If I built this skill, I would also be able to control any aspect of my speakers or TV, like "Alexa, channel up."

My goal was to build an IR blaster (basically a smart remote) that would be connected to my Amazon Echo. In this post I'll show how the IR blaster is assembled and programmed, and later on I'll show the Alexa skill to control it.

The heart of the project is an ESP8266 chip in an ESP-01 breakout.
We'll program this chip to host a webserver and control the infrared LED, which will control the speakers.

Materials needed:
  • ESP8266 controller with ESP-01 breakout
  • USB cable
  • USB-B breakout (or any USB breakout)
  • AMS1117 3.3v voltage regulator
  • 22uF and 10 uF capacitors (for the voltage regulator)
  • 10k ohm and 200 ohm resistors
  • On/off switch (optional)
  • Infrared LED
  • Jumper wires and solder
  • Small PCB
  • 2N2222 transistor
If you're keeping track, the most expensive thing on here is the ESP-8266, which retails for about $7. After it's all said and done, this internet-connected IR blaster can easily be put together for about $20, and could be mass produced for far less.

Tools needed:
  • Dremel for shaping the PCB
  • FTDI controller to program the ESP chip
  • Soldering iron
  • Benchtop power supply and breadboard (Recommended for prototyping)
  • Regular LED for prototyping
First, I wanted to re-flash my ESP chip to get a simple LED blinking. Alasdair Allan has an awesome article demonstrating how to flash your ESP8266 chip using an FTDI controller. You can follow these instructions to get an LED blinking.

When you're comfortable programming the ESP-8266 chip, you can start experimenting with Mark Szabo's IRRemoteESP8266 Arduino library. Specifically, I worked from the IRServer example. I had to make three important changes:

1. For this build, I used the RX pin to control the LED. There is a specific reason why I chose not to use GPIO. Therefore you need to intitialize the IRsend object like so:

  IRsend irsend(3);

2. Using the MDNSResponder object caused my program to run into heap overflows very quickly, so I used static routing instead. I commented out all mention of MDNSResponder.

3. I added the codes for the Audioengine A5+ powered speakers. I discovered them listed here, but not in the format we need. I had to translate them to raw NEC hex codes by hand. If you've stumbled here from Google looking for A5+ codes, here they are:
  Power = 0xBF807F = 12550271
  Mute = 0xBFC03F = 12566591
  Vol- = 0xBFE01F = 12574751
  Vol+ = 0xBF906F = 12554351

Now let's verify that the webserver is running and functional. You'll need to discover the IP address of the IR blaster. You can do this by setting it yourself with static routing, or looking at your router's DHCP table, or through a separate sketch that outputs the IP address to serial. If you go to this IP address in your browser, you should see the landing page from Mark's example.

To verify that the blaster is blasting, let's wire up the circuit on a breadboard.

The ESP-01 breakout for reference
Circuit diagram for the IR blaster.
After uploading the sketch, you can keep the power and CH_PD hooked up to your FTDI controller. Connect the transistor, resistors and a regular (non-IR) LED according to the circuit above. Opening the IRServer website and sending commands should make your LED flash.

After verifying that the server works, you can prototype the rest of the circuit, including the voltage regulator and USB power, on a breadboard.

Here is my server on PCB:
IR blaster partially disassembled

Underside of the server

The IR blaster connected to my speakers
Luckily my Audioengine A5+ speakers had a built-in USB port, so I simply connected my server there and taped it to the side of the speakers. Using a modified IRServer example, I can send volume control and mute commands over the internet. With these ingredients, an Alexa sketch is not too far away.

7 comments:

  1. These can be put for individual and additionally bunch use and since they are not enormous, they may not bring about any deterrent regardless of the possibility that they are put amidst the gathering. http://carspeakerhub.com/

    ReplyDelete
  2. This is why nearly all the business companies nowadays want to get an internet connection that is extremely fast and reliable and can keep their business activities going on smoothly.http://www.envisageonline.com/

    ReplyDelete
  3. You could definitely see your expertise in the work you write. The sector hopes for more passionate writers such as you who aren’t afraid to say how they believe. All the time go after your heart. check here

    ReplyDelete
  4. You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant! Best Studio Monitor Speakers

    ReplyDelete
  5. Wonderful article, thanks for putting this together! This is obviously one great post. Thanks for the valuable information and insights you have so provided here.
    Keynote spekers

    ReplyDelete
  6. Consequently, going for ordinary speakers is definitely not an alluring alternative by any means. onlinemusicpromotion

    ReplyDelete
  7. It's a bit complex but still comprehend-able. I;m so lucky that I found this article. Thanks Mate! buy soundcloud

    ReplyDelete