ESP8266 HomeKit Infrared Remote Blaster
Uses Arduino-HomeKit-ESP8266 and IRremoteESP8266.
This is an Arduino sketch that allows you to create HomeKit-integrated infrared blaster to e.g. power on your old television that doesn't support HDMI-CEC, a speaker set that is connected to it or just anything that may be controlled via infrared remote (even an A/C!).
This sketch has 3 switches implemented as an example:
- One stateful switch that turns itself off after 10 minutes
- Two stateless (momentary) switches
Note: As there is no push button (momentary) switch supported in HomeKit, the stateless switches turn off immediately once they're triggered.
- Obtain some ESP8266-based board, infrared sensor & infared transmitter module. All of this could be bought for like $6 and is very easy to put together.
- First, you need to read your infrared codes (or find them in the docs). For A/Cs, it's slightly more complicated as the codes are usually longer. Use the infrared sensor and connect it to your ESP board, then use the reader demo sketch. Make sure to use 3.3V to power the module, not the 5V pin (this does apply to the transmitter too).
- Once you get the codes to turn the device on, change volume, etc, you may use them in the
irsend.sendNEC()
(or other manufacturer-appropriate calls) to trigger the required infrared command. See the sketch code. - Like you've connected the sensor, you may connect the transmitter module to send out the commands. You may even keep both connected until you finish your project.
- Once the sketch is uploaded, follow the instructions on the Arduino-HomeKit-ESP8266 project page to pair the board with your Apple Home.
- Now you can control the infrared blaster with your iPhone, iPad, Watch or Siri!
I'm using the Wemos D1 module with an infrared trasmitter module inside a cool box that my work colleague Jirka have printed for me. The module lays nearby a Genius speaker set that I'm able to turn on and off + control volume (this may be implemented as a speaker accessory in the future, but it works as it is).
The auto turn-off function is needed as there is currently (as of 2/2022) no easy way to read the Apple TV status (whether it is on or off) and use that to turn the speakers on or off too. But once my TV is turned on, I may use the fact it's USB port is powered. This way I'm able to create a HomeKit sensor (see the esp8266-homekit-watchdog project) that gets triggered once the ESP module boots up & each 8 minutes. With a bit of HomeKit automation, I'm able to trigger the Remote module once the TV sensor is triggered to keep it on. And once the power from use TV USB goes away, the speakers are automatically turned off after 10 minutes of inactivity.