A device to control an Onkyo AV receiver from Android TV.
This device allows you to control an Onkyo AV receiver from Android/Google TV. This means the AV receiver will turn on/off together with the TV, and you can adjust the receiver's volume using TV's remote. Additionally, you can decide to turn the receiver on only if a specific app is launched on the TV.
Note that the device only works with Onkyo AV receivers that support the RI (Remote Interactive) interface, and the TV must have the Android TV Remote Service installed (it is preinstalled on most TVs).
Although similar behavior can be achieved using HDMI CEC, it's not always fully supported by both devices, and the receiver might consume more power in standby mode when HDMI CEC is enabled.
The device is based on an ESP8266 module. Any module with at least 1MB of flash memory should work, but modules with built-in USB (such as Wemos D1 mini) are most convenient.
The ESP8266 should be connected to AV receiver's RI input via a 3.5mm mono jack cable. Connect the sleeve to GND. If you use a stereo cable, connect both ring and sleeve to GND. Connect the tip to a GPIO pin via a 1k series resistor (exact value isn't critical). The default is GPIO4, labeled as "D2" on Wemos D1 mini. Although the RI interface uses 5V logic and ESP8266 GPIO outputs 3.3V, it is likely to work without a level shifter. If it doesn't, you can try with a 3.3V to 5V level shifter.
Before compiling the code, you need to generate a public and private key pair, and perform pairing procedure with the
TV. The easiest way is to use androidtvremote2. Ensure you have a recent
version of Python 3 installed, clone that repository and follow the instructions from its readme file. Note that you can
skip some steps, only "Install dependencies" and "Run demo" are required. Follow the displayed instructions to pair with
the TV. You should see two new files: cert.pem and key.pem. Copy these files to the main directory.
To compile the project, you'll need the ESP8266 toolchain and the ESP8266 RTOS SDK. For installation instructions, refer to RTOS SDK docs. Optionally, you can also install protobuf-c if you'd like to regenerate C sources for remotemessage.proto (this is only needed if you intend to modify the proto file, as the generated C files are already included in this repository).
Once you have a working toolchain, run make menuconfig to configure settings according to your setup. Pay attention to
"AV Control Bridge", "Example Connection Configuration", and "Serial flasher config" submenus. Menu options have
built-in help messages, which can be accessed by pressing the ? key.
After adjusting the settings, run make app to compile the project, and make flash to upload it to ESP8266. You can
run make monitor to observe log messages printed by the device.
All necessary settings are embedded in the binary, so no additional configuration is required. Simply connect the module to AV receiver's RI input as described above and provide power to the module. When the device is powered on for the first time, it will perform volume synchronization after it receives a signal to turn the AV receiver on. Avoid changing volume externally (e.g. using the volume knob), as it will cause the volume to go out of sync.
I tested the device with an Onkyo TX-SR605 receiver. For other models you may need to adjust the settings or RI codes in av_ctrl.c. Refer to Onkyo-RI repository for a list of RI codes for some common models. If you get it to work with a different model, please let me know.
The following list indicates some features that may be added in the future:
- ESP32 support
- IR transmitter instead of the RI protocol, to support AV receivers from other brands
- Option to configure settings and pair with the TV directly from the device, without recompiling the code
This project is released under the MIT license. It uses the ESP8266 RTOS SDK which is released under the Apache-2.0 license. The remotemessage.proto file was taken from androidtv-remote by louis49, which is released under the MIT license.