Mapping buttons on an Existing Remote (Humax FOXSAT HDR)

While having a dedicated remote for specific devices can be helpful sometimes the reverse is true.

In this example I'm adding EXISTING but unused buttons on the Humax FOXSAT HDR to invoke web service calls on an ESP8266 used for home automation in an AV Room.

The plan is to grab an IR signal from the existing remote and decode it. If it is one of the buttons we want to repurpose then we call the web service / action required. This means WE DO NOT NEED more remotes we can just use unused or low use buttons on an existing remote.

For my set up I took the never used coloured buttons on the remote and them up to

RED) Power up the amp / TV / Sub / DI injection / Active Speakers etc
GREEN) AV switch SAT TV
YELLOW) AV switch to KODI
BLUE) Power off items in  by RED

For my Kodi use I have an advanced remote which is fine. However for using the Humax SAT receiver the humax remote is nice and simple. Now watch SAT TV is a one remote experience. Cost ESP 8266 12 on WEMOS Mini clone $3, 5V PSU, IR Receiver (10 for $1) the output side of the device are web server calls to another ESP with a 433Mhz Controller

First we need to map out the remote control buttons. The coloured  Red, Green, Yellow and Blue buttons are not widely used

Run the IRrecvDump program from the IR sample sketches for the Arduino Uno board and then pressing the buttons yields these codes for the Humax Red, Green, Yellow and Blue buttons respectively - note each button is pushed twice to check we grabbed the right code / the code does not change between presses.

RED
7F0838C7
Decoded NEC: 7F0838C7 (32 bits)
Raw (68): 8950 -4350 600 -500 600 -1600 650 -1550 600 -1650 600 -1600 650 -1550 650 -1600 600 -1600 600 -500 600 -500 600 -500 600 -500 650 -1600 600 -500 600 -500 600 -500 600 -500 600 -500 600 -1600 600 -1650 600 -1600 600 -500 600 -500 600 -500 600 -1650 600 -1600 600 -500 600 -500 650 -450 600 -1650 600 -1600 600 -1650 550 
7F0838C7
Decoded NEC: 7F0838C7 (32 bits)
Raw (68): 8900 -4400 600 -500 600 -1650 550 -1600 600 -1650 600 -1600 600 -1600 600 -1650 600 -1600 600 -500 600 -500 600 -500 650 -450 650 -1600 600 -500 600 -500 600 -500 650 -450 650 -450 650 -1600 600 -1600 600 -1600 650 -450 650 -450 600 -500 650 -1600 600 -1600 650 -450 650 -450 650 -450 650 -1600 600 -1600 650 -1550 650 


GREEN
7F08B847
Decoded NEC: 7F08B847 (32 bits)
Raw (68): 8950 -4350 650 -450 650 -1550 650 -1550 650 -1600 600 -1600 650 -1550 650 -1550 650 -1600 650 -450 650 -450 650 -450 650 -450 650 -1550 650 -500 650 -450 650 -450 650 -1550 650 -450 650 -1600 600 -1600 650 -1550 650 -450 650 -450 650 -500 600 -500 650 -1550 650 -450 650 -450 650 -450 650 -1600 600 -1600 650 -1550 650 
7F08B847
Decoded NEC: 7F08B847 (32 bits)
Raw (68): 8950 -4350 650 -450 650 -1550 650 -1550 650 -1600 650 -1550 650 -1550 650 -1550 650 -1600 650 -450 650 -450 650 -450 650 -450 650 -1600 600 -500 650 -450 650 -450 650 -1550 650 -450 650 -1600 650 -1550 650 -1550 650 -450 650 -450 650 -500 600 -500 650 -1550 650 -450 650 -450 650 -450 650 -1600 650 -1550 650 -1550 650 


YELLOW
7F0858A7
Decoded NEC: 7F0858A7 (32 bits)
Raw (68): 8950 -4350 650 -450 650 -1550 650 -1550 650 -1600 650 -1550 650 -1550 650 -1550 650 -1600 650 -450 650 -450 650 -450 650 -450 650 -1600 600 -500 650 -450 650 -450 650 -450 650 -1500 700 -450 650 -1600 650 -1550 650 -450 650 -450 650 -450 650 -1600 650 -450 650 -1550 650 -450 650 -450 650 -1600 600 -1600 650 -1550 650 
7F0858A7
Decoded NEC: 7F0858A7 (32 bits)
Raw (68): 9000 -4300 650 -450 650 -1550 650 -1600 650 -1550 650 -1550 650 -1600 650 -1550 650 -1550 650 -450 650 -450 650 -500 600 -500 650 -1550 650 -450 650 -450 650 -450 650 -450 650 -1600 650 -450 650 -1550 650 -1550 650 -500 600 -500 650 -450 650 -1550 650 -450 650 -1550 650 -500 650 -450 650 -1550 650 -1550 650 -1600 600 


BLUE
7F087887
Decoded NEC: 7F087887 (32 bits)
Raw (68): 8950 -4350 600 -500 650 -1550 650 -1550 650 -1600 600 -1600 650 -1550 650 -1550 650 -1600 650 -450 650 -450 650 -450 650 -450 650 -1550 650 -500 600 -500 650 -450 650 -450 650 -1550 650 -1550 650 -1600 650 -1550 650 -450 650 -450 650 -450 650 -1600 650 -450 650 -450 650 -450 650 -450 650 -1550 650 -1600 650 -1550 650 
7F087887
Decoded NEC: 7F087887 (32 bits)
Raw (68): 9000 -4300 650 -450 650 -1550 650 -1600 650 -1550 650 -1550 650 -1600 600 -1600 650 -1550 650 -450 650 -450 650 -450 650 -500 650 -1550 650 -450 650 -450 650 -450 650 -450 650 -1600 650 -1550 650 -1550 650 -1550 650 -500 650 -450 650 -450 650 -1550 650 -450 650 -450 650 -500 600 -500 650 -1550 650 -1550 650 -1600 600 

Below is the output of IRrecvDumpV2 program from the IR sample sketches for the ESP8266 Libraries running on a Wemos D1 Mini - Pin D5 is pin 14 and then pressing the buttons yields these codes for the Humax Red, Green, Yellow and Blue buttons respectively - note each button is pushed once as this is just to check the ESP8266 code for IR receiving works as expected - it does!

Encoding  : NEC
Code      : 7F0838C7 (32 bits)
Timing[67]: 
     +9100, -4400     + 650, - 500     + 700, -1600     + 650, -1600
     + 700, -1600     + 650, -1600     + 700, -1600     + 650, -1600
     + 700, -1600     + 700, - 500     + 650, - 500     + 650, - 500
     + 650, - 500     + 650, -1600     + 700, - 500     + 650, - 500
     + 650, - 500     + 700, - 500     + 700, - 500     + 650, -1600
     + 650, -1600     + 700, -1600     + 650, - 500     + 700, - 500
     + 700, - 500     + 650, -1600     + 700, -1600     + 700, - 500
     + 700, - 500     + 650, - 500     + 700, -1600     + 650, -1600
     + 700, -1600     + 650
uint16_t  rawData[67] = {9100,4400, 650,500, 700,1600, 650,1600, 700,1600, 650,1600, 700,1600, 650,1600, 700,1600, 700,500, 650,500, 650,500, 650,500, 650,1600, 700,500, 650,500, 650,500, 700,500, 700,500, 650,1600, 650,1600, 700,1600, 650,500, 700,500, 700,500, 650,1600, 700,1600, 700,500, 700,500, 650,500, 700,1600, 650,1600, 700,1600, 650};  // NEC 7F0838C7
uint32_t  address = 0x10FE;
uint32_t  command = 0x1C;
uint64_t  data = 0x7F0838C7;

Encoding  : NEC
Code      : 7F08B847 (32 bits)
Timing[67]: 
     +9100, -4400     + 650, - 500     + 700, -1600     + 700, -1600
     + 700, -1600     + 700, -1600     + 700, -1600     + 700, -1600
     + 700, -1600     + 700, - 500     + 700, - 500     + 700, - 500
     + 700, - 500     + 700, -1600     + 700, - 500     + 700, - 500
     + 700, - 500     + 700, -1600     + 700, - 500     + 700, -1600
     + 650, -1600     + 700, -1600     + 650, - 500     + 700, - 500
     + 700, - 500     + 700, - 500     + 700, -1600     + 700, - 500
     + 700, - 500     + 700, - 500     + 700, -1600     + 700, -1600
     + 700, -1600     + 700
uint16_t  rawData[67] = {9100,4400, 650,500, 700,1600, 700,1600, 700,1600, 700,1600, 700,1600, 700,1600, 700,1600, 700,500, 700,500, 700,500, 700,500, 700,1600, 700,500, 700,500, 700,500, 700,1600, 700,500, 700,1600, 650,1600, 700,1600, 650,500, 700,500, 700,500, 700,500, 700,1600, 700,500, 700,500, 700,500, 700,1600, 700,1600, 700,1600, 700};  // NEC 7F08B847
uint32_t  address = 0x10FE;
uint32_t  command = 0x1D;
uint64_t  data = 0x7F08B847;

Encoding  : NEC (Repeat)
Code      : FFFFFFFFFFFFFFFF (0 bits)
Timing[3]: 
     +9100, -2150     + 700
uint16_t  rawData[3] = {9100,2150, 700};  // NEC (Repeat) FFFFFFFFFFFFFFFF
uint64_t  data = 0xFFFFFFFFFFFFFFFF;

Encoding  : NEC
Code      : 7F0858A7 (32 bits)
Timing[67]: 
     +9050, -4400     + 650, - 500     + 650, -1600     + 650, -1600
     + 650, -1600     + 650, -1600     + 650, -1600     + 650, -1600
     + 650, -1600     + 650, - 550     + 650, - 500     + 650, - 500
     + 650, - 500     + 650, -1600     + 650, - 550     + 650, - 500
     + 650, - 500     + 650, - 500     + 650, -1650     + 650, - 500
     + 650, -1600     + 650, -1600     + 650, - 500     + 650, - 500
     + 650, - 500     + 650, -1600     + 650, - 500     + 650, -1600
     + 650, - 500     + 650, - 500     + 650, -1600     + 650, -1600
     + 650, -1600     + 650
uint16_t  rawData[67] = {9050,4400, 650,500, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,550, 650,500, 650,500, 650,500, 650,1600, 650,550, 650,500, 650,500, 650,500, 650,1650, 650,500, 650,1600, 650,1600, 650,500, 650,500, 650,500, 650,1600, 650,500, 650,1600, 650,500, 650,500, 650,1600, 650,1600, 650,1600, 650};  // NEC 7F0858A7
uint32_t  address = 0x10FE;
uint32_t  command = 0x1A;
uint64_t  data = 0x7F0858A7;

Encoding  : NEC (Repeat)
Code      : FFFFFFFFFFFFFFFF (0 bits)
Timing[3]: 
     +9050, -2200     + 650
uint16_t  rawData[3] = {9050,2200, 650};  // NEC (Repeat) FFFFFFFFFFFFFFFF
uint64_t  data = 0xFFFFFFFFFFFFFFFF;

Encoding  : NEC
Code      : 7F087887 (32 bits)
Timing[67]: 
     +9050, -4400     + 650, - 500     + 650, -1600     + 650, -1600
     + 650, -1600     + 650, -1600     + 650, -1600     + 650, -1600
     + 650, -1600     + 650, - 500     + 650, - 500     + 650, - 500
     + 650, - 500     + 650, -1600     + 650, - 500     + 650, - 500
     + 650, - 500     + 650, - 500     + 650, -1600     + 650, -1600
     + 650, -1600     + 650, -1600     + 650, - 500     + 650, - 500
     + 650, - 500     + 650, -1600     + 650, - 500     + 650, - 500
     + 650, - 500     + 650, - 500     + 650, -1600     + 650, -1600
     + 650, -1600     + 650
uint16_t  rawData[67] = {9050,4400, 650,500, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,500, 650,500, 650,500, 650,500, 650,1600, 650,500, 650,500, 650,500, 650,500, 650,1600, 650,1600, 650,1600, 650,1600, 650,500, 650,500, 650,500, 650,1600, 650,500, 650,500, 650,500, 650,500, 650,1600, 650,1600, 650,1600, 650};  // NEC 7F087887
uint32_t  address = 0x10FE;
uint32_t  command = 0x1E;
uint64_t  data = 0x7F087887;

Encoding  : NEC (Repeat)
Code      : FFFFFFFFFFFFFFFF (0 bits)
Timing[3]: 
     +9050, -2200     + 650
uint16_t  rawData[3] = {9050,2200, 650};  // NEC (Repeat) FFFFFFFFFFFFFFFF

uint64_t  data = 0xFFFFFFFFFFFFFFFF;

This was done as I want to add the IR Receiver a VS1838B to an existing ESP8266 running the Home automation in the AV room hence the need for the ESP8266 library.

/*
 * IRremoteESP8266: IRrecvDumpV2 - dump details of IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Example circuit diagram:
 *  https://github.com/markszabo/IRremoteESP8266/wiki#ir-receiving
 * Changes:
 *   Version 0.2 April, 2017
 *     - Decode from a copy of the data so we can start capturing faster thus
 *       reduce the likelihood of miscaptures.
 * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com
 */

#include
#include
#include
#include
#include
#include
#define USE_SERIAL Serial
ESP8266WiFiMulti WiFiMulti;


// An IR detector/demodulator is connected to GPIO pin 14(D5 on a NodeMCU
// board).
uint16_t RECV_PIN = 14;

IRrecv irrecv(RECV_PIN);

decode_results results;  // Somewhere to store the results
irparams_t save;         // A place to copy the interrupt state while decoding.

void setup() {
    // Status message will be sent to the PC at 115200 baud
    Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
    irrecv.enableIRIn();  // Start the receiver
    USE_SERIAL.println();
    USE_SERIAL.println();
    USE_SERIAL.println();
    // initialize digital pin LED_BUILTIN as an output.
    pinMode(LED_BUILTIN, OUTPUT);

    //Flash LED as we start up this delay is just to let the ESP and PSU stablise not really needed
    for(uint8_t t = 4; t > 0; t--) {
        USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
        USE_SERIAL.flush();
        digitalWrite(LED_BUILTIN, HIGH);   
        delay(100);                       
        digitalWrite(LED_BUILTIN, LOW);    
        delay(200);                       
        digitalWrite(LED_BUILTIN, HIGH);  
        delay(100);                      
        digitalWrite(LED_BUILTIN, LOW);   
        delay(200);                       
    }
    WiFiMulti.addAP("WIFI", "SECRET");
    digitalWrite(LED_BUILTIN, LOW);   
}

void httpget(String web_address,int wait_time){
HTTPClient http;
USE_SERIAL.print("[HTTP] begin...\n");
// configure traged server and url
//http.begin("https://192.168.1.12/test.html", "7a 9c f4 db 40 d3 62 5a 6e 21 bc 5c cc 66 c8 3e a1 45 59 38"); //HTTPS
Serial.println(web_address);
http.begin(web_address); //HTTP
USE_SERIAL.print("[HTTP] GET...\n");
// start connection and send HTTP header
int httpCode = http.GET();

// httpCode will be negative on error
if(httpCode > 0) {
    // HTTP header has been send and Server response header has been handled
    USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);

    // file found at server
    if(httpCode == HTTP_CODE_OK) 
    {
        String payload = http.getString();
        USE_SERIAL.println(payload);
    }
  } 
  else 
  {
    USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
  }
http.end();
Serial.println("Sleep 10s..");
for(uint8_t t = wait_time; t > 0; t--) {
        USE_SERIAL.printf("[Delay] WAIT %d...\n", t);
        USE_SERIAL.flush();
        digitalWrite(LED_BUILTIN, HIGH);  
        delay(150);                       
        digitalWrite(LED_BUILTIN, LOW);   
        delay(200);                       
        digitalWrite(LED_BUILTIN, HIGH);  
        delay(150);                                         
        digitalWrite(LED_BUILTIN, LOW);   
        delay(200);                       
        digitalWrite(LED_BUILTIN, HIGH);  
        delay(50);                       
        digitalWrite(LED_BUILTIN, LOW);   
        delay(200);                       
        digitalWrite(LED_BUILTIN, HIGH);  
        delay(50);   
        digitalWrite(LED_BUILTIN, LOW);                                                               
  }
}

  
// The repeating section of the code
//
void loop() {
// wait for WiFi connection
if((WiFiMulti.run() == WL_CONNECTED)) {
    // Check if the IR code has been received.
    if (irrecv.decode(&results, &save)) {
      //dumpInfo(&results);           // Output the results
      digitalWrite(LED_BUILTIN, HIGH);   
      switch(results.value) {
          case 0x7F0838C7:  //Red
            Serial.println("Red;");
            httpget("http://192.168.0.237/AVSPEAKERSON",15);
            break;
          case 0x7F08B847:  //Green
            Serial.println("Green;");
            httpget("http://192.168.0.237/SAT",7);
            break;
          case 0x7F0858A7:  //Yellow
            Serial.println("Yellow;");
            httpget("http://192.168.0.237/KODI",7);
            break;
          case 0x7F087887:  //Blue
           Serial.println("Blue;");
           httpget("http://192.168.0.237/AVSPEAKERSOFF",7);
           break;
        }
      digitalWrite(LED_BUILTIN, LOW);   
      //dumpRaw(&results);          // Output the results in RAW format
      //dumpCode(&results);         // Output the results as source code
      Serial.println("");           // Blank line between entries
    }
}
delay(500);

}