06 Using a Custom IR Receiver and Remote - Resinchem/Arylic-Amp-MQTT GitHub Wiki
Using a Custom IR Receiver and Remote
This project includes an option to wire an IR receiver to the ESP32 for the purposes of using your own remote and own IR codes to control many features of the amp. There are a few steps you must complete to use your own remote with the custom IR receiver.
IF YOU ARE USING THE ONBOARD IR RECEIVER OR THE IR EXTENSION, THIS SECTION DOES NOT APPLY! The onboard IR receiver will only work with the Arylic remote codes. You will need to either purchase the Arylic remote or use a programmable remote programmed with the Arylic codes, which can be found on the Arylic site.
Determining your remote's codes
The first step to using the custom IR receiver and your own IR remote is to determine the code sent out by each button you want to use on your remote. If you do not know these codes and have no other way of determining their values, you can build a very simply IR code capture device with a breadboard, any ESP8266 or ESP32 board and an IR receiver. This will return the IR code in the Arduino IDE serial monitor each time you press a button on the remote. More details on the build of this simple capture device, along with the code, can be found in the /ir-capture folder of this repo.
However you opt to capture those codes, you want to tie those codes to the commands you wish to use for the amp (you can use any of the UART commands listed on the MQTT and UART commands page of this wiki). I mapped a simple low cost remote in a spreadsheet:

In this simple example, I used the IR capture device to get the IR code returned for each button of the remote. I then determined what command or option I wanted for the buttons. In my example, I've only mapped 16 of the buttons (the top two rows and two rows in the middle). I could have mapped more (or all) of the buttons if desired. The point here is that you need to map an IR code from the remote to a corresponding UART command for the amp.
Mapping your IR codes to the Amp UART commands
Once you know the IR codes and the UART commands you want assigned, you must now map these in the code. In the main arylic_amp.ino file, near the top, you should find a code block that looks like the following:
/* UPDATE COMMAND FOR YOUR REMOTE HERE:
first value is the code returned, second value is the UART command to issue
UART commands that only accept a numeric value (e.g treble, bass and balance), use ++ for increase and -- for decrease and the value will be increased or decreased by 1 within the permissible min/max values.
Other commands may be added... just assure the UART command is valid.
*/
//==============================
IRCommands remoteCommands[] = {
{16, "VOL:-;"}, //uses single dash to decrease vol by 5
{17, "TRE:--;"},
{18, "BAS:--;"},
{19, "BAL:--;"},
{20, "VOL:+;"}, //uses single + to increase vol by 5
{21, "TRE:++;"},
{22, "BAS:++;"},
{23, "BAL:++;"},
{65, "POP;"}, //toggles pause/play
{64, "SYS:STANDBY;"},
{68, "SRC:NET;"},
{69, "SRC:BT;"},
{88, "SRC:USB;"},
{89, "SRC:USBDAC;"},
{92, "MUT:T;"}, //toggles mute
{93, "DISPMODE"} //This is not a UART command, but local to change display home mode
};
//=============================
This is the mapping used for the above example. For each key, you specify the IR code followed by the UART command. See the wiki page on MQTT and UART Commands for information on what each UART command does and how to properly format UART codes. Note that most UART commands that accept a numeric value will also accept a minus (-) or plus (+) symbol to decrease or increase that setting by a set amount.
Once you have mapped your IR codes to UART commands, you can save, compile and upload to the ESP32. If you have previously loaded the sketch, you can update it over-the-air. See the wiki page on OTA Updates for more details.
Enable and Disabling the IR Receiver
First, for the IR receiver to be enabled each time the ESP32 boots up, you need to assure you have set the enableIR flag set to 1 in the Settings.h file (see the Credentials and Settings wiki page for more details). However, whether the IR receive is enable or not at boot time, you can toggle it off or on at any time via the MQTT /irmode command.
Why might you want to disable the IR receiver? Well, in my case I discovered that my nearby Harmony remote hub was sending out codes that occasionally corresponded to the same IR codes I had mapped... causing the amp to respond unexpectedly. So in my case, I enable the IR receiver if I want to use the remote and disable it the rest of the time so that commands sent by Harmony do not interfere with the amp's operation.