Finished product |
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
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:
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.
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 |