Programming and decoding universal remote IR codes

I got a bunch of cheap “keychain” remote controls off eBay (picture attached). They can be programmed by holding Mute button, which after about 3-5 seconds goes into search mode sending various IR codes for Mute function. My goal is to program all remotes to a same code (doesn’t really matter which as long as all of remotes sending same codes). I’m using Ken Sheriff’s IRremote library for this. However I’m yet to detect any noticeable pattern with it :frowning: It works if I use TV, but not reliably if I use Arduino.
I’m attaching Serial output generated when I held Mute button for about 1-2 minutes. Any suggestions what logic I can use to program these remotes (other than using TV)?
Here’s the code I’m using (it’s slightly modified IRrecvDemo sketch that came with the library). I found that this code “20DF906F” for mute works with my TV so I’ve been searching for it in the output. I do find it occasionally but when I see it and release button, it doesn’t always “stay in the remote”… I wish I knew algorithm that remote uses for sending these codes…

#include <IRremote.h>

int RECV_PIN = 11;
byte i=0;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(115200);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    if (results.value==0x20DF906F) Serial.println ("*** FOUND 20DF906F ***");
    irrecv.resume(); // Receive the next value
    i++;
    if (i==3) {
      Serial.println ("----------------------------------------------------");
      i=0;
    }
    
  }
}

IR_results.txt (17.1 KB)

keychain_remote.JPG

OK It looks like this remote sends many commands for each key press. This is to try to get the correct code for every TV. This is why you only get the corecct mute signal for your TV every so often in the output. When you press mute, it sends the mute for most of the popular TVs - not just one. Normal remotes will only send one up to 4 of the same codes for each key press.

Also note the the repeat code on NEC protocol is FFFFFFFF and some protocols have a toggle bit which changes on every key press.

IRremote can also print out the protocol name (type). So add a statement to your code to also print out the time ( millis() ) and the protocol type ( eg Serial.println(results->decode_type); )

and leave out the count to 3 and the dashed line and then repost.

Hope this helps.

PS Our AnalysIR project was featured on the Arduino blog this week, details in signature below.

Thank you! :) I will try it and post result tonight!

AnalysIR:
try
Serial.println(results.decode_type);

Thanks. I actually just copied parts of the dump function form IRDump example.
Here’s result from holding mute button for about 2 minutes.

IR_decode.txt (37.2 KB)

As suspected it looks like its repeatedly sending mute signals up to 10 times per sec - most of the mute codes for every device.

See if the same code comes out first every time you press the mute. (or at least early on in the sequence.)

You should be able to pick say any one NEC type code for each button press and use that to control your device and ignore the repeated unwanted signals

Then see if a similar thing happens on each other key.

Even though it is sending 10's of different codes for each key press, you only need to latch on to one at your recevier end and ignore the others.

Hope thats clear

some further thoughts...

The setup for your keychain remote says to hold the mute key until the tv remote turns off. I suspect what happens is that it then only sends a small number of signals for each key until programmed again using the mute key. (it probably sends the codes for the devices either side of when you released the mute button - as early on in your 2 min sequence it was only sending 3 codes and then repeating, after a while it went into the longer sequence)

If its just for your own use its not a problem, but if you have other users this could be confusing. It might be better getting another single code remote, rather than this multi code one.

Another possiblity is to train any existing tv remote into the device you are controlling. You would have to lead the user through the training process (eg press key 1 now, press mute now etc etc). Although more complex for the user, you wouldnt have to supply a remote with the device.

Thanks a lot for your suggestions! I just tried something and yeah it works. Basically I already programmed my clock to recognize specific set of IR codes (i.e. mute button triggers clock to start talking), so that's what I'm using to program remotes. I just hold Mute until clock responds and from that point remote remembers which code it was. That's what I'll write in manual for users in case they need to reprogram it (although remote seems to keep latest code in EEProm, battery removal doesn't trigger memory loss)

Great that you got it working....had look at your clock very cool you should try out a crowdfunding effort!

AnalysIR: Great that you got it working....had look at your clock very cool you should try out a crowdfunding effort!

Thanks! :) Yeah I've been thinking about putting it on Kickstarter...